SoapClient.SendRequestResponse意识到在传出请求SOAP标头中的邮件ID的和,直到它接收到具有RelatesTo值的消息将不完成呼叫与原始MessageID匹配。所以,如果你正在制作一个响应者/存根,你可以从请求中解析出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值是一样的,在请求的邮件ID值。响应中的MessageID是新的且唯一的,因为响应消息不是请求消息。