开发者

how to read http response soap headers from web service response in proxy class

开发者 https://www.devze.com 2022-12-29 15:03 出处:网络
I\'m having some problems with one webservice that i\'m working with. I generated a proxy class with wsdl.exe that comes with .net framework. But that webservice return a header that isnt not mapped b

I'm having some problems with one webservice that i'm working with. I generated a proxy class with wsdl.exe that comes with .net framework. But that webservice return a header that isnt not mapped by the wsdl. I must map the header sop because it contains some properties that i have to read and work with. how can i read the soap's header collection?

Ex.:

<soap:Envelope xmlns:soap="开发者_Python百科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>

I need to read the SOAP:HEADER -> Session.


Have you tried this?

source: 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
    }
}


See this page for detailed instructions on defining custom SOAP headers. There only seem to be VB.net code examples, but it should be easy enough to translate the principles in C#.

0

精彩评论

暂无评论...
验证码 换一张
取 消