0

Any help please. I'm trying to consume a method in a WCF web service that has the envelop bellow :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:esig="http://test.com/test" xmlns:ser="http://test.com/test/service">
   <soapenv:Header/>
   <soapenv:Body>
      <es:meth>
         <ser:methRequest>
            <ser:meth>?</ser:meth>
         </ser:methRequest>
      </es:meth>
   </soapenv:Body>
</soapenv:Envelope>

The problem is I can't communicate with the ws because I have to pass a token inside soap:header. When I add manually the header in soapUI it works. But in my c# code I don't know how to do it.

     <soapenv:Header>
          <OTAuthentication xmlns="test.com">
                <AuthenticationToken>MyToken</AuthenticationToken>
          </OTAuthentication>
     </soapenv:Header>

Please any help to add the heade with c# before calling the web service in order to have envelop like this :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:esig="http://test.com/test" xmlns:ser="http://test.com/test/service">
   <soapenv:Header>
          <OTAuthentication xmlns="test.com">
                <AuthenticationToken>MyToken</AuthenticationToken>
          </OTAuthentication>
     </soapenv:Header>
   <soapenv:Body>
      <es:meth>
         <ser:methRequest>
            <ser:meth>?</ser:meth>
         </ser:methRequest>
      </es:meth>
   </soapenv:Body>
</soapenv:Envelope>
  • You can refer to [this post](https://stackoverflow.com/questions/964433/how-to-add-a-custom-http-header-to-every-wcf-call/1408177#1408177) and find some ways to solve it. – Lan Huang Nov 04 '21 at 09:36

0 Answers0