Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy isn't my SOAP request working?
    primarykey
    data
    text
    <p>I am trying to make a SOAP request with PHP. It seems my request matches the request detailed in the SOAP server's documentation (but with slightly different methods), yet I'm getting an authentication error, as if the header is not being included.</p> <p>The documentation's request sample</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;soap:Header&gt; &lt;AuthHeader xmlns="http://novosolutions.com/"&gt; &lt;SessionId&gt;string&lt;/SessionId&gt; &lt;/AuthHeader&gt; &lt;/soap:Header&gt; &lt;soap:Body&gt; &lt;ViewTicket xmlns="http://novosolutions.com/"&gt; &lt;Id&gt;int&lt;/Id&gt; &lt;/ViewTicket&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p>The request my PHP code outputs:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://novosolutions.com/"&gt; &lt;SOAP-ENV:Header&gt; &lt;ns1:AuthHeader&gt; &lt;SessionId&gt;623&lt;/SessionId&gt; &lt;/ns1:AuthHeader&gt; &lt;/SOAP-ENV:Header&gt; &lt;SOAP-ENV:Body&gt; &lt;ns1:ViewTicket&gt; &lt;Id&gt;1355110&lt;/Id&gt; &lt;/ns1:ViewTicket&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>My PHP code is rather simple. Am I doing something wrong?</p> <pre><code>$url = URL_BASE . URL_TICKET . '?WSDL'; $soapStruct = new SoapVar(array('SessionId' =&gt; SESSION_ID), SOAP_ENC_OBJECT); $header = new SoapHeader('http://novosolutions.com/', 'AuthHeader', $soapStruct, false); try { $client = new SoapClient($url, array('trace' =&gt; 1)); } catch (SoapFault $exception) { echo 'Exception='.$exception; } $client-&gt;__setSoapHeaders(array($header)); var_dump($client); $soapData = new SoapVar(array('Id' =&gt; 1355110), SOAP_ENC_OBJECT); $result = $client-&gt;__soapCall('ViewTicket', array('parameters' =&gt; $soapData)); var_dump($result); echo $client-&gt;__getLastRequest(); </code></pre> <p>EDIT: By testing the request with a curl, I've narrowed it down to the fact that PHP's SoapClient uses a variable for the namespace. is not accepted by the SoapServer, but is. Now I just need to figure out how to prevent SoapClient from using variables.</p>
    singulars
    1. This table or related slice is empty.
    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