• <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的學習園地

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

              C++博客 :: 首頁 :: 新隨筆 ::  ::  :: 管理 ::
            首先寫一個簡單的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項目里,添加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選項是一個修補,不加這個選項會產生SOAPAction頭錯誤。

            運行服務器,在瀏覽器中訪問/test/hello,發現名字為空。經過長時間調試,發現.Net在解析SOAP消息體時,不能處理這種命名空間:

            ????<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去掉就行了。不過這部分實現在rubylib/soap/rpc/proxy.rb里面,實在不方便修改。為了讓這個測試通過,暫時做了點小修改:

            ??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行是我添加的代碼,勉強可以讓它工作,不過顯然不是正確的方法。

            不知道是不是.Net庫里面的BUG。
            posted on 2006-05-14 20:08 qiezi 閱讀(484) 評論(0)  編輯 收藏 引用 所屬分類: 自家破爛Ruby
            午夜不卡久久精品无码免费| 亚洲国产精品无码久久SM| 久久国产色AV免费看| 精品久久一区二区三区| 欧美精品丝袜久久久中文字幕| 热re99久久精品国99热| 国产色综合久久无码有码| WWW婷婷AV久久久影片| 久久久久久久亚洲精品| 新狼窝色AV性久久久久久| 国产精品久久久久乳精品爆| 中文字幕乱码人妻无码久久| 精品国产一区二区三区久久蜜臀| 久久精品国产一区二区电影| 久久国产色av免费看| 91麻精品国产91久久久久| 久久免费大片| 国产99久久久国产精品~~牛| 午夜视频久久久久一区| 久久91精品国产91久久小草| 香蕉久久夜色精品国产2020| 亚洲午夜精品久久久久久人妖| 2021久久精品免费观看| 国产精品久久久久久久| 久久这里有精品| 激情五月综合综合久久69| …久久精品99久久香蕉国产| 77777亚洲午夜久久多人| 亚州日韩精品专区久久久| 99热热久久这里只有精品68| 东京热TOKYO综合久久精品| 色8久久人人97超碰香蕉987| 中文字幕无码久久精品青草| 久久婷婷人人澡人人| 精品无码久久久久久久动漫| 一本久久久久久久| AAA级久久久精品无码区| 品成人欧美大片久久国产欧美| 91精品国产91久久久久久蜜臀| 久久国产乱子伦免费精品| 国产A级毛片久久久精品毛片|