Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to generate a soap request in php from this xml?
    primarykey
    data
    text
    <p>I'm tired of trying to send a request with SOAP. this is my xml</p> <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:bpf="http://schemas.datacontract.org/2004/07/Bpf.Security.Common" xmlns:bpf1="http://schemas.datacontract.org/2004/07/Bpf.Security.Authentication.Common"&gt; &lt;soapenv:Header&gt; &lt;InfoTag xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org/BaufestProductivityFramework"&gt; &lt;ClientIp xmlns="http://schemas.datacontract.org/2004/07/Bpf.Common.Service"&gt;200.125.145.10&lt;/ClientIp&gt; &lt;CompanyId xmlns="http://schemas.datacontract.org/2004/07/Bpf.Common.Service"&gt;1&lt;/CompanyId&gt; &lt;UserName xmlns="http://schemas.datacontract.org/2004/07/Bpf.Common.Service"&gt;someUser&lt;/UserName&gt; &lt;/InfoTag&gt; &lt;/soapenv:Header&gt; &lt;soapenv:Body&gt; &lt;tem:LogIn&gt; &lt;tem:token&gt; &lt;bpf:type&gt; &lt;bpf1:Description&gt;someDesc&lt;/bpf1:Description&gt; &lt;bpf1:Id&gt;1&lt;/bpf1:Id&gt; &lt;bpf1:Name&gt;someDesc&lt;/bpf1:Name&gt; &lt;/bpf:type&gt; &lt;bpf:password&gt;somePass&lt;/bpf:password&gt; &lt;bpf:userName&gt;someUser&lt;/bpf:userName&gt; &lt;/tem:token&gt; &lt;/tem:LogIn&gt; &lt;/soapenv:Body&gt; &lt;/soapenv:Envelope&gt; </code></pre> <p>this function send the header with a namespace, but there are more than one... I have to send them all?</p> <pre><code> private function __getHeaders() { $ns = 'http://schemas.xmlsoap.org/soap/envelope/'; //Namespace of the WS. $ip = $_SERVER['REMOTE_ADDR']; //Body of the Soap Header. $headerbody = array('ClientIp' =&gt; $ip, 'CompanyId' =&gt; 1, 'UserName' =&gt; 'someUser' ); //Create Soap Header. $header = new SOAPHeader($ns, 'InfoTag', $headerbody); return $header; } public function prepareWs(){ $wsdl="the web service"; $client = new SoapClient($wsdl, array('trace' =&gt; true)); //Set the Headers of Soap Client. $header = $this-&gt;__getHeaders(); $client-&gt;__setSoapHeaders($header); </code></pre> <p>I try to send this body, I inspected exception with soap fault but the message only returns "bad request NULL NULL NULL".</p> <pre><code>$params = new stdClass(); $params = new SoapVar("&lt;tem:token&gt; &lt;bpf:type xmlns:bpf="http://schemas.datacontract.org/2004/07/Bpf.Security.Common"&gt; &lt;bpf1:Description xmlns:bpf1="http://schemas.datacontract.org/2004/07/Bpf.Security.Authentication.Common"&gt;someDesc&lt;/bpf1:Description&gt; &lt;bpf1:Id xmlns:bpf1="http://schemas.datacontract.org/2004/07/Bpf.Security.Authentication.Common"&gt;1&lt;/bpf1:Id&gt; &lt;bpf1:Name xmlns:bpf1="http://schemas.datacontract.org/2004/07/Bpf.Security.Authentication.Common"&gt;someName&lt;/bpf1:Name&gt; &lt;/bpf:type&gt; &lt;bpf:password xmlns:bpf="http://schemas.datacontract.org/2004/07/Bpf.Security.Common"&gt;somePass&lt;/bpf:password&gt; &lt;bpf:userName xmlns:bpf="http://schemas.datacontract.org/2004/07/Bpf.Security.Common"&gt;someUser&lt;/bpf:userName&gt; &lt;/tem:token&gt;", XSD_ANYXML); $response = $client-&gt;Login($params); } </code></pre> <p>With CURL I can send this XML and recieved the XML response too, but with SOAPClient I can't send this request.</p> <p>I hope someone can help me, thanks.</p> <p>This is the code I can see with firebug, the only thing I get is "bad request". When I use __getLastRequest() I see the same... I guess the headers should not be sent correctly, however the __setSoapHeaders function returns true. This is the output:</p> <pre><code>&lt;soap-env:envelope xmlns:ns1="http://tempuri.org/" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;soap-env:header&gt; &lt;soap-env:contextinformation&gt; &lt;item&gt; &lt;key&gt;ClientIp&lt;/key&gt; &lt;value&gt;127.0.0.1&lt;/value&gt; &lt;/item&gt; &lt;item&gt; &lt;key&gt;CompanyId&lt;/key&gt; &lt;value&gt;1&lt;/value&gt; &lt;/item&gt; &lt;item&gt; &lt;key&gt;UserName&lt;/key&gt; &lt;value&gt;someUser&lt;/value&gt; &lt;/item&gt; &lt;/soap-env:contextinformation&gt; &lt;/soap-env:header&gt; &lt;soap-env:body&gt; &lt;tem:login&gt; &lt;tem:token&gt; &lt;bpf:type&gt; &lt;bpf1:description&gt;someDesc&lt;/bpf1:description&gt; &lt;bpf1:id&gt;1&lt;/bpf1:id&gt; &lt;bpf1:name&gt;someName&lt;/bpf1:name&gt; &lt;/bpf:type&gt; &lt;bpf:password&gt;somePass&lt;/bpf:password&gt; &lt;bpf:username&gt;someUser&lt;/bpf:username&gt; &lt;/tem:token&gt; &lt;/tem:login&gt; &lt;/soap-env:body&gt; &lt;/soap-env:envelope&gt; </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.
 

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