Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding a custom SOAP header using c#/ASP.NET
    primarykey
    data
    text
    <p>I am trying to use a traffic web service. An example of the SOAP request is given below.</p> <p>I have created a proxy class in c# using Wsdl.exe from the WSDL structure. </p> <p>What I think I need to do now in somehow insert the 'authenticate' SOAP header into the SOAP structure for the method call. I'm unsure how to add the header to the service method call?</p> <pre><code>&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.inteleacst.com.au/wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt; &lt;SOAP-ENV:Header&gt; &lt;ns1:authenticate&gt; &lt;SOAP-ENC:Struct&gt; &lt;username&gt;username&lt;/username&gt; &lt;password&gt;password&lt;/password&gt; &lt;/SOAP-ENC:Struct&gt; &lt;/ns1:authenticate&gt; &lt;/SOAP-ENV:Header&gt; &lt;SOAP-ENV:Body&gt; &lt;ns1:getAllTraffic&gt; &lt;States SOAP-ENC:arrayType="xsd:string[3]" xsi:type="ns1:State_Arr"&gt; &lt;item xsi:type="xsd:string"&gt;VIC&lt;/item&gt; &lt;item xsi:type="xsd:string"&gt;NSW&lt;/item&gt; &lt;item xsi:type="xsd:string"&gt;NT&lt;/item&gt; &lt;/States&gt; &lt;EventCodes SOAP-ENC:arrayType="xsd:int[1]" xsi:type="ns1:EventCode_arr"&gt; &lt;item xsi:type="xsd:int"&gt;802&lt;/item&gt; &lt;/EventCodes&gt; &lt;/ns1:getAllTraffic&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>Here is the code in the proxy class for calling the web service method.</p> <pre><code>[System.Web.Services.Protocols.SoapRpcMethodAttribute("http://webservice.intelecast.com.au/traffic/PublicSoap/server.php#getAllTraffic", RequestNamespace="http://webservice.intelecast.com.au/traffic/PublicSoap/server.php", ResponseNamespace="http://webservice.intelecast.com.au/traffic/PublicSoap/server.php")] [return: System.Xml.Serialization.SoapElementAttribute("return")] public TrafficInfo[] getAllTraffic(string[] States, int[] EventCodes) { object[] results = this.Invoke("getAllTraffic", new object[] { States, EventCodes}); return ((TrafficInfo[])(results[0])); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload