• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            qiezi的學(xué)習(xí)園地

            AS/C/C++/D/Java/JS/Python/Ruby

              C++博客 :: 首頁 :: 新隨筆 ::  ::  :: 管理 ::
            首先寫一個(gè)簡(jiǎn)單的webservice:

            using?System;
            using?System.Web;
            using?System.Web.Services;
            using?System.Web.Services.Protocols;

            [WebService(Namespace?
            =?"http://tempuri.org/")]
            [WebServiceBinding(ConformsTo?
            =?WsiProfiles.BasicProfile1_1)]
            public?class?Service?:?System.Web.Services.WebService
            {
            ????[WebMethod]
            ????
            public?string?HelloWorld(string?name)?{
            ????????
            return?"Hello,?"?+?name;
            ????}
            ????
            }

            在RoR項(xiàng)目里,添加app/apis/test_api.rb:

            class?TestApi?<?ActionWebService::API::Base
            ??api_method?:HelloWorld,?:expects?
            =>?[{:name?=>?:string}],?:returns?=>?[:string]
            end

            這是RoR里面通用的webservice元信息描述。

            添加app/controllers/test_controller.rb:

            class?TestController?<?ApplicationController
            ??web_client_api?:test,?:soap,?
            "http://localhost/test/Service.asmx",?
            ?????????????????:namespace?
            =>?"http://tempuri.org/",
            ?????????????????:soap_action_base?
            =>?"http://tempuri.org",
            ?????????????????:driver_options
            =>{:default_encodingstyle?=>?SOAP::EncodingStyle::ASPDotNetHandler::Namespace?}

            ??
            def?hello
            ????render_text?test.HelloWorld(
            "Li?Jie")
            ??end
            end

            :soap_action_base選項(xiàng)是一個(gè)修補(bǔ),不加這個(gè)選項(xiàng)會(huì)產(chǎn)生SOAPAction頭錯(cuò)誤。

            運(yùn)行服務(wù)器,在瀏覽器中訪問/test/hello,發(fā)現(xiàn)名字為空。經(jīng)過長(zhǎng)時(shí)間調(diào)試,發(fā)現(xiàn).Net在解析SOAP消息體時(shí),不能處理這種命名空間:

            ????<n1:HelloWorld?xmlns:n1="http://tempuri.org/"
            ????????soap:encodingStyle
            ="http://schemas.xmlsoap.org/soap/encoding/">
            ??????
            <name?xsi:type="xsd:string">Li Jie</name>
            ????
            </n1:HelloWorld>

            把n1去掉就行了。不過這部分實(shí)現(xiàn)在rubylib/soap/rpc/proxy.rb里面,實(shí)在不方便修改。為了讓這個(gè)測(cè)試通過,暫時(shí)做了點(diǎn)小修改:

            ??def?route(req_header,?req_body,?reqopt,?resopt)
            ????req_env?
            =?::SOAP::SOAPEnvelope.new(req_header,?req_body)
            ????unless?reqopt[:envelopenamespace].nil?
            ??????set_envelopenamespace(req_env,?reqopt[:envelopenamespace])
            ????end
            ????reqopt[:external_content]?
            =?nil
            ????conn_data?
            =?marshal(req_env,?reqopt)
            ????
            if?ext?=?reqopt[:external_content]
            ??????mime?
            =?MIMEMessage.new
            ??????ext.each?do?
            |k,?v|
            ??????????mime.add_attachment(v.data)
            ??????end
            ??????mime.add_part(conn_data.send_string?
            +?"\r\n")
            ??????mime.close
            ??????conn_data.send_string?
            =?mime.content_str
            ??????conn_data.send_contenttype?
            =?mime.headers['content-type'].str
            ????end

            ????conn_data.send_string.gsub!(
            /:n1/,?'')
            ????conn_data.send_string.gsub!(
            /n1:/,?''
            )

            ????conn_data?
            =?@streamhandler.send(@endpoint_url,?conn_data,
            ??????reqopt[:soapaction])
            ????
            if?conn_data.receive_string.empty?
            ??????
            return?nil
            ????end
            ????unmarshal(conn_data,?resopt)
            ??end

            加粗的2行是我添加的代碼,勉強(qiáng)可以讓它工作,不過顯然不是正確的方法。

            不知道是不是.Net庫(kù)里面的BUG。
            posted on 2006-05-14 20:08 qiezi 閱讀(480) 評(píng)論(0)  編輯 收藏 引用 所屬分類: 自家破爛Ruby
            久久国产精品99国产精| 伊人久久精品无码av一区| www久久久天天com| 久久综合亚洲欧美成人| 久久久久久夜精品精品免费啦| 久久久噜噜噜久久中文字幕色伊伊| 色婷婷久久综合中文久久一本| 久久精品人妻一区二区三区| 久久无码国产| 一级做a爰片久久毛片免费陪| 日韩中文久久| 狠狠色综合网站久久久久久久高清 | 亚洲精品99久久久久中文字幕| 精品乱码久久久久久夜夜嗨| 国产激情久久久久影院| 久久亚洲国产精品五月天婷| 日韩久久无码免费毛片软件| 国产亚洲美女精品久久久2020| 久久亚洲AV成人无码电影| 九九久久99综合一区二区| 国产激情久久久久影院老熟女| 久久强奷乱码老熟女| 亚洲中文字幕久久精品无码喷水| 五月丁香综合激情六月久久| 久久免费美女视频| 色天使久久综合网天天| 无码伊人66久久大杳蕉网站谷歌| 久久精品一区二区国产| 久久久久国产| AAA级久久久精品无码片| 久久久久亚洲AV无码专区网站 | 婷婷久久综合| 精品熟女少妇a∨免费久久| 精品无码久久久久久久动漫| 97精品国产97久久久久久免费 | 久久精品国产清自在天天线| av色综合久久天堂av色综合在| 久久精品国产69国产精品亚洲| 午夜精品久久久久久影视riav| 99国产欧美久久久精品蜜芽| 狠狠色丁香婷婷久久综合 |