簡體   English   中英

即使服務器正在響應SOAP消息,Microsoft.Web.Services2.SoapClient.SendRequestResponse也會超時

[英]Microsoft.Web.Services2.SoapClient.SendRequestResponse timing out even though the server is responding with a SOAP message

據我了解,發布已學到的一些有用信息的最佳方法是親自提出問題,然后再回答,所以就到這里了。

場景:

  • 我們有一個應用程序可以構造來自模板xslt文件的SOAP請求,並包含一些參數中的subs,包括MessageID
  • 它像請求一樣訪問的真實服務,愉快地響應,我們的客戶愉快地處理響應
  • 我們正在嘗試構建一個模擬服務的存根/響應器
  • 存根僅實現IHttpHandler並響應任何POST操作
  • 存根從XML文件中讀取罐頭響應(這是真實響應的示例),並通過網絡發送
  • 可視往返分析儀(引擎蓋下的NetMon)和Fiddler都看到響應通過電線傳遞到客戶端
  • SendRequestResponse最終超時並引發異常

SoapClient.SendRequestResponse知道傳出請求SOAP標頭中的MessageID,並且直到收到包含與原始MessageID匹配的RelatesTo值的消息后,才能完成調用。 因此,如果您要設計響應者/存根,則需要從請求中解析出MessageID並將其注入到響應的SOAP標頭中的RelatesTo字段中。

奇怪的是,它不只是在任何有效的SOAP消息之后返回並由於不匹配而引發期望。 也許這是SOAP Web服務標准的一部分。 我沒有調查。

例:

請求:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance/" xmlns:xsd="http://www.w3.org/2001/XMLSchema/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility">
  <soap:Header>
    <wsa:MessageID soap:mustUnderstand="1">uuid:20E6C5D8-2E0D-48D0-863D-7789D2CA37A2</wsa:MessageID>
...

響應:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility">
  <soap:Header>
    <wsa:MessageID SOAP-ENV:mustUnderstand="1" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">uuid:bb1cf43050739c45:248138d0:1328e31d4e2:-5cf4</wsa:MessageID>
    <wsa:RelatesTo RelationshipType="wsa:Reply" SOAP-ENV:mustUnderstand="1" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">uuid:20E6C5D8-2E0D-48D0-863D-7789D2CA37A2</wsa:RelatesTo>
...

RelatesTo值與請求中的MessageID值相同。 響應中的MessageID是新的且唯一,因為響應消息不是請求消息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM