0

I'm new to using Web Services and I've been struggling a bit with the following problem.

I was given a WSDL from an external provider for the use of their webservice. I´m using VB.NET and have already added the web reference to the project. With this I can now access the proxy class providing the method and structure in the WSDL. The problem is that the webservice requires a header, but it's not declared within the WSDL so I can't access any attributes of the header needed.

I've been reading quite a bit and it seems I must add manually the header data, but I don´t know how to do this using the proxy objects.

The header needs the following data

POST https://ipGoesHere:7070/ HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "urn:TimbradoCFD"
CUSTOMERKEY: 00000000000000
User-Agent: Jakarta Commons-HttpClient/3.1
Host: ipGoesHere:7070
Content-Length: 22165

The SOAP envelope needed must look something like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:new="http://new.webservice.namespace">

 <soapenv:Header/>
   <soapenv:Body>
      <cfdi:Document xmlns:cfdi="http://something" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <cfdi:Concepts>
            <cfdi:Concept quantity="1" Identifier="001" description="article"/>
         </cfdi:Concepts>
      </cfdi:Document>
   </soapenv:Body>
</soapenv:Envelope>

I don't know if I'm going about this correctly or if someone knows how I can implement this header in combination with the proxy objects.

ChuckzM
  • 81
  • 1
  • 5
  • Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on [so]. See "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). – John Saunders Mar 07 '14 at 22:37
  • Are you using service references, or the legacy web references? – John Saunders Mar 07 '14 at 22:38
  • I'm using service reference – ChuckzM Mar 07 '14 at 22:55
  • Which part of the text you posted is the header you need to add? – John Saunders Mar 07 '14 at 22:57
  • "SOAPAction", "CUSTOMERKEY" are the fields the will help the authentication but the whole text should form the complete header – ChuckzM Mar 07 '14 at 23:06
  • Most of that should be generated for you by .NET. The user-agent certainly should not be set by you. It looks like only "CUSTOMERKEY" is to be added, and it is _not_ a "SOAP Header" - it's an HTTP header. – John Saunders Mar 07 '14 at 23:15
  • Oh I see, I thought SOAPAction had to be added also. And what would be a way set an HTTP header using the proxy class the WSDL created? I will look into the HTTP header more. – ChuckzM Mar 07 '14 at 23:22
  • If the SOAP request (envelope) my provider sent me has an"" tag with the example header I show in the question does it still mean its an HTTP header ? – ChuckzM Mar 08 '14 at 00:29
  • No. The `` element contains all SOAP headers. – John Saunders Mar 08 '14 at 06:17
  • I have added the text of how the SOAP message should be sent. This is why I am confused since the envelope asks for a soapenv:Header and the header as you said before looks more like an HTTP header. – ChuckzM Mar 24 '14 at 23:35
  • I think it's likely that `CUSTOMERKEY` _is_ an HTTP Header, which does not mean that there is no SOAP header. – John Saunders Mar 24 '14 at 23:51
  • Yes, reading further it is part of an http header but I still can´t find the way to implement the CUSTOMERKEY in an HTTP request while still being able to use the proxy class. All I've been able to dig out is to create the envelope manually which I don't believe is a good option – ChuckzM Mar 25 '14 at 00:07
  • See http://stackoverflow.com/questions/964433/how-to-add-a-custom-header-to-every-wcf-call, which I found by searching for [add http header to wcf request](https://www.google.com/search?q=add+http+header+to+wcf+request) – John Saunders Mar 25 '14 at 00:15

0 Answers0