【问题标题】:how to read http response soap headers from web service response in proxy class如何从代理类中的Web服务响应中读取http响应soap标头
【发布时间】:2010-05-03 20:39:52
【问题描述】:

我正在使用的一项网络服务存在一些问题。我使用 .net 框架附带的 wsdl.exe 生成了一个代理类。但是该 web 服务返回一个不是由 wsdl 映射的标头。我必须映射标题 sop,因为它包含一些我必须阅读和使用的属性。我如何阅读肥皂的标题集合?

例如:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Header xmlns="http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd">
      <Session>
         <SessionId>545784545</SessionId>
         <SequenceNumber>1</SequenceNumber>
         <SecurityToken>asd7a87sda89sd45as4d5a4</SecurityToken>
      </Session>
   </soap:Header>
   <soap:Body>
      <TAM_Altea_Seguranca_AutenticarRS xmlns="http://xml.amadeus.com/2009/04/TAM/TAM_Altea_Seguranca_AutenticarRS_2.0">
         <statusDoProcesso>
            <codigoDoStatus>P</codigoDoStatus>
         </statusDoProcesso>
      </TAM_Altea_Seguranca_AutenticarRS>
   </soap:Body>
</soap:Envelope>

我需要阅读 SOAP:HEADER -> Session。

【问题讨论】:

    标签: c# .net soap wsdl web-services


    【解决方案1】:

    你试过了吗?

    来源:Handle SOAP Headers Required by an XML Web Service Client

    public class MyWebService
    {
        public SoapUnknownHeader[] unknownHeaders;
    
        [WebMethod]
        [SoapHeader("unknownHeaders")]
        public string MyWebMethod() 
        {
            foreach (SoapUnknownHeader header in unknownHeaders) 
            {
                // process headers
            }
    
            // handle request
        }
    }
    

    【讨论】:

      【解决方案2】:

      有关定义自定义 SOAP 标头的详细说明,请参阅 this page。好像只有 VB.net 的代码示例,但是用 C# 翻译原理应该很容易。

      【讨论】:

      • 这个地址告诉你如何包含一个 HEADER 而不是读取一个 SOAP 响应的 HEADER。
      猜你喜欢
      • 1970-01-01
      • 2021-05-26
      • 1970-01-01
      • 1970-01-01
      • 2012-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多