Search code examples
phpsoapnusoapsoap-clientsoapheader

PHP Soap Header help


I have a fairly simple php/soap header question.

Here's what I need.

<ns1:Identity token="123456789"></ns1:Identity>

Here's what I get...

<ns1:Identity><item><key>token</key><value>123456789</value></item></ns1:Identity>

using this code...

$headers[] = new SoapHeader('http://qpricer.com/Services/Pricing','Identity',array('token'=> '123456789'));
$client->__setSoapHeaders($headers);

Using soapui, I have narrowed my issue down to this right here.

How do I go from the second one to the first one?

An help would be greatly appreciated, thanks for your time.


Solution

  • Because this was the only header I had to set, I was able to fix it using the following code.

    $headers[] = new SoapHeader('http://www.qpricer.com/Services/Pricing','Identity token="123456789"',null);
    

    This produced the following XML

    <ns1:Identity token="123456789"/>
    

    and it worked!