Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I change SOAP Namespaces in PHP to match a WSDL?
    primarykey
    data
    text
    <p>I am currently working on a project for the company that I work for. The project will need to make a SOAP request to another company (by means of PHP). I have the SoapClient in my PHP code communicating with the SOAP server of the other company, but all I get is "INVALID XML." After examining their WSDL and the response I notice that their namespaces are different. I need to change my namespaces to match theirs. </p> <p>For example: The tags in my request show "ns1." and "env.", but theirs show "soap."</p> <p>How can I change this?</p> <p>Here is an example of my code, the request that is sent out and the response that is received.</p> <pre><code>---------------- CODE ---------------- $client = new SoapClient("http://ws.example.com/test/test.asmx?WSDL", array('soap_version'=>SOAP_1_2, 'trace' => 1)); $result = $client->TestFunction(array('Packet'=&gt;'&lt;Email&gt;test@example.com&lt;/Email&gt;&lt;Password&gt;examplepassword&lt;/Password&gt;')); $sessionid = $result->TestFunctionResult; print $sessionid; echo "REQUEST HEADER:\n" . htmlentities($client->__getLastRequestHeaders()) . "\n"; echo "REQUEST:\n" . htmlentities($client->__getLastRequest()) . "\n"; echo "RESPONSE HEADER:\n" . htmlentities($client->__getLastResponseHeaders()) . "\n"; echo "RESPONSE:\n" . htmlentities($client->__getLastResponse()) . "\n"; ------------ REQUEST SENT ------------- POST /test/test.asmx HTTP/1.1 Host: ws.example.com Connection: Keep-Alive User-Agent: PHP-SOAP/5.3.4 Content-Type: application/soap+xml; charset=utf-8; action=&quot;http://ws.example.com/test/TestFunction&quot; Content-Length: 352 &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;env:Envelope xmlns:env=&quot;http://www.w3.org/2003/05/soap-envelope&quot; xmlns:ns1=&quot;http://ws.example.com/resumes/&quot;&gt; &lt;env:Body&gt; &lt;ns1:TestFunction&gt; &lt;ns1:Packet&gt; &lt;Email&gt;test@example.com&lt;/Email&gt; &lt;Password&gt;examplepassword&lt;/Password&gt; &lt;/ns1:Packet&gt; &lt;/ns1:TestFunction&gt; &lt;/env:Body&gt; &lt;/env:Envelope&gt; ---------- RESPONSE RECEIVED ---------- HTTP/1.1 200 OK Cache-Control: private, max-age=0 Content-Length: 450 Content-Type: application/soap+xml; charset=utf-8 Server: Microsoft-IIS/7.0 X-AspNet-Version: 2.0.50727 X-Powered-By: ASP.NET X-PBY: BEARWS2 Date: Mon, 18 Apr 2011 15:33:51 GMT Connection: close &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;soap:Envelope xmlns:soap=&quot;http://www.w3.org/2003/05/soap-envelope&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt; &lt;soap:Body&gt; &lt;TestFunctionResponse xmlns=&quot;http://ws.example.com/test/&quot;&gt; &lt;TestFunctionResult&gt; &lt;Packet&gt; &lt;Error&gt;Invalid XML&lt;/Error&gt; &lt;/Packet&gt; &lt;/TestFunctionResult&gt; &lt;/TestFunctionResponse&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p><br /></p> <p>How can I get around this problem?</p>
    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.
    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