|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-02-02 06:05 UTC] bink at eezi dot net dot au
Description:
------------
Possibly a documentation issue
=====================================
When using a php object to create SOAP request headers, the SoapVAR($obj, SOAP_ENC_OBJECT....) and SoapHeader($namespace, $name, $soapvar) does not set the namespace of the object properties to the same as the object itself.
Reproduce code:
---------------
$client = new SOAPClient($wsdl, array('trace' => '1'));
class headers {
function __construct($val1, $val2){
$this->val1 = $val1;
$this->val2 = $val2;
}
}
$obj = new headers('val1','val2');
$svval=new SoapVar($obj,SOAP_ENC_OBJECT, NULL, NULL, "", "http://url.com/namespace2");
$header = new SoapHeader("http://url.com/namespace2",
"SoapHeaderMsg",
$svval, false);
$client->__setSoapHeaders(array($header));
$client->ping();
print_r($client->__getLastRequest());
Expected result:
----------------
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://url.com/namespace1" xmlns:ns2="http://url.com/namespace2">
<SOAP-ENV:Header>
<ns2:SoapHeaderMsg>
<ns2:val1>val1</val1>
<ns2:val2>val2</val2>
</ns2:SoapHeaderMsg>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:PingRequest/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Actual result:
--------------
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ow.optus.com.au/b2b/bwsgservices/schema/version/2.0/bilpm" xmlns:ns2="http://ow.optus.com.au/b2b/xwsgservices/schema/wscommon">
<SOAP-ENV:Header>
<ns2:SoapHeaderMsg>
<val1>val1</val1>
<val2>val2</val2>
</ns2:SoapHeaderMsg>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:PingRequest/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 07:00:01 2025 UTC |
Without WSDL file ext/soap cannot know that "val1" element must be namespace qualified and it cannot guess which namespace to use. WSDL file may specify the encoding rules for the soap header, but without WSDL we must not add any namespace. If you really need namespace qualification, but don't declare SOAP header in WSDL file, you can add namespaces manually using SoapVar. Replace header constructor with the following code and you will get that you like (or write proper WSDL). class headers { function __construct($val1, $val2){ $this->val1 = new SoapVar($val1, XSD_STRING, NULL, NULL, "val1", "http://url.com/namespace2"); $this->val2 = new SoapVar($val2, XSD_STRING, NULL, NULL, "val1", "http://url.com/namespace2"); } }