Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with Nusoap & Header authentication
    text
    copied!<p>For some strange reason, I have to work with a webservice that cannot be called via WSDL.</p> <p>The sample XML Request has to be something like this - </p> <pre><code>&lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;s:Header&gt; &lt;Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;http://tempuri.org/check_Ref_No&lt;/Action&gt; &lt;h:ServiceAuthHeader xmlns="http://tempuri.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://tempuri.org/"&gt; &lt;Username&gt;theusername&lt;/Username&gt; &lt;Password&gt;thepassword&lt;/Password&gt; &lt;/h:ServiceAuthHeader&gt; &lt;/s:Header&gt; &lt;s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;check_Ref_No xmlns="http://tempuri.org/"&gt; &lt;refno&gt;123456789&lt;/refno&gt; &lt;PRDFRM&gt;0001-01-01T00:00:00&lt;/PRDFRM&gt; &lt;PRDTO&gt;2013-12-18T16:19:00&lt;/PRDTO&gt; &lt;covers /&gt; &lt;err&gt;0&lt;/err&gt; &lt;/check_Ref_No&gt; &lt;/s:Body&gt; &lt;/s:Envelope&gt; </code></pre> <p>What I cannot understand is </p> <ol> <li>How can I use Nusoap and pass the Soap Header as mentioned above</li> <li>What is <code>&lt;Action s:mustUnderstand="1"&gt;</code></li> <li>How to form this request using Nusoap</li> </ol> <p>What I did so far - </p> <pre><code>//Loading NuSoap Library require 'nusoap/nusoap.php'; $client = new nusoap_client($ServiceURL, FALSE); $client-&gt;setUseCurl(false); $client-&gt;soap_defencoding = 'utf-8'; // Setting username and password provided by Walid $client-&gt;setCredentials("theusername","thepassword","basic"); //make the call $result = $client-&gt;call('check_Ref_No', array('refno'=&gt;'123456789','PRDFRM'=&gt;'0001-01-01T00:00:00','PRDTO'=&gt;'2013-12-18T16:19:00','covers'=&gt;'','err'=&gt;0), 'http://tempuri.org/', 'http://tempuri.org/check_Ref_No', false, true); $err = $client-&gt;getError(); if ($err) { echo '&lt;h2&gt;Constructor error&lt;/h2&gt;&lt;pre&gt;' . $err . '&lt;/pre&gt;'; } // Now checking is the Server Code of the webservice has a fault. if ($client-&gt;fault) { echo '&lt;h2&gt;Fault&lt;/h2&gt;&lt;pre&gt;'; print_r($result); echo '&lt;/pre&gt;'; } else { // echo the actual raw webservice XML data sent echo htmlspecialchars($client-&gt;request, ENT_QUOTES) // echo the actual raw webservice XML data received. echo htmlspecialchars($client-&gt;response, ENT_QUOTES) } </code></pre> <p>... and this results in - complete success in connecting and receiving a response, but with an error - something about Soap Header not understood by the server. Anyone got a solution?</p> <p>P.S The use of Nusoap is not mandatory - I can shift to anything else or even the native SoapClient of PHP, I just need help in understanding how to setup the headers to form the request.</p>
 

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