I wanted to generate the following SOAP header format,
<soapenv:Header>
<SoapHeaderMsg xmlns="http://xyz.com.au">
<opt:UserSoapHeader>
<opt:IdentityName>TEST</opt:IdentityName>
<opt:AuthenticationToken>jjjkjkjkjkjkj</opt:AuthenticationToken>
</opt:UserSoapHeader>
</SoapHeaderMsg>
</soapenv:Header>
So i am using the following php functions to generate this,
$this->__setSoapHeaders(array(
new SoapHeader('http://xyz.com.au', 'SoapHeaderMsg', array(
new SoapHeader('http://xyz.com.au', 'IdentityName', 'TEST'),
new SoapHeader('http://xyz.com.au', 'AuthenticationToken', 'jkjkjkk')
)),
));
Which generates following headers which is completely different to what i wanted above ? how do i generate exact same headers using PHP functions like above ?
<SOAP-ENV:Header>
<ns1:SoapHeaderMsg>
<SOAP-ENC:Struct>
<namespace>http://xyz.com.au</namespace>
<name>IdentityName</name>
<data>TEST</data>
<mustUnderstand>false</mustUnderstand>
</SOAP-ENC:Struct>
<SOAP-ENC:Struct>
<namespace>http://xyz.com.au</namespace>
<name>AuthenticationToken</name>
<data>hjhhjjhjhjhj</data>
<mustUnderstand>false</mustUnderstand>
</SOAP-ENC:Struct>
</ns1:SoapHeaderMsg>
</SOAP-ENV:Header>
array
is mostly used on the PHP side, which gets converted to Struct
. Can you please try to use object
and see if you have any success with it.
$this->__setSoapHeaders(array(
new SoapHeader('http://xyz.com.au', 'SoapHeaderMsg',
(object)array(
'opt:UserSoapHeader' => (object)array(
'opt:IdentityName' => 'TEST',
'opt:AuthenticationToken' => 'jkjkjkk'
)
)),
));
The request looks like below:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://test.domain.com/"
xmlns:ns2="http://xyz.com.au">
<SOAP-ENV:Header>
<ns2:SoapHeaderMsg>
<opt:UserSoapHeader>
<opt:IdentityName>TEST</opt:IdentityName>
<opt:AuthenticationToken>jkjkjkk</opt:AuthenticationToken>
</opt:UserSoapHeader>
</ns2:SoapHeaderMsg>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
......
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>