I\'m tired of trying to send a request with SOAP. this is my xml
SoapHeader
treats arrays rather arbitrarily. If you ever want to use an array, consider using ArrayObject instead of the native construct.
However, you don't need an array at all since you're only trying to construct a single element in your header. And because each of your internal elements (eg. ClientIP) has a unique namespace, you can't just pass in a basic object. Instead, you have to specify a particular namespace for each element using the SoapVar
class, which allows you to wrap normal PHP data in a "SOAP-ready" container that SoapClient
can understand and translate.
$innerNS = "http://www.w3.org/BaufestProductivityFramework";
$outerNS = "http://schemas.datacontract.org/2004/07/Bpf.Common.Service";
$tag = new stdClass();
$tag->ClientIP = new SoapVar("200.125.145.10", XSD_STRING, null, null, null, $innerNS);
$tag->CompanyId = new SoapVar(1, XSD_INT, null, null, null, $innerNS);
$tag->UserName = new SoapVar("someUser", XSD_STRING, null, null, null, $innerNS);
$client->__setSoapHeaders(new SoapHeader($outerNS, 'InfoTag', $tag));
Finally, as a rule, don't manually write XML! Consider re-writing your SOAP body code like the header code shown here. You ought to be able to deal specifically with the content of the XML, not its structure.