soapClient not creating XML request correctly
| From: | Bilig Ordos | Date: | Tue, 07 Aug 2012 16:39:47 +0000 |
| Subject: | soapClient not creating XML request correctly | ||
| Groups: | php.soap | ||
| Request: | Send a blank email to php-soap+get-3364@lists.php.net to get a copy of this message | ||
Hi,
I'm trying to work with an existing SOAP/XML web services that is working fine with clients
written in Java and .Net. Any help/idea is greatly appreciated!
I need the soapClient to send the following XML request. I tested this request with a third-party
tool and made sure it works fine:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:con="http://www.xyz.com/product/schema/config"
xmlns:com="http://www.xyz.com/product/schema/common">
<soapenv:Header>
</soapenv:Header>
<soapenv:Body>
<con:getConfig>
<com:credential>
<com:user>user</com:user>
<com:password>pass</com:password>
<!--Optional:-->
<com:group>group</com:group>
</com:credential>
<!--Zero or more repetitions:-->
<con:orderPlanFilter>
<!--Optional:-->
<deviceName>abc</deviceName>
</con:orderPlanFilter>
</con:getConfig>
</soapenv:Body>
</soapenv:Envelope>
The "credential" is used for authentication and the "orderPanFilter" is used for
filtering the data by available fields in the WS/DB.
My problem is that I was only able to have the soapClient send the following request:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://www.xyz.com/product/schema/common"
xmlns:ns2="http://www.xyz.com/product/schema/config">
<SOAP-ENV:Body>
<ns2:getConfig>
<ns1:credential>
<ns1:user>user</ns1:user>
<ns1:password>pass</ns1:password>
<ns1:group>group</ns1:group>
</ns1:credential>
</ns2:getConfig>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
As you can see, the soapClient does not send the "orderPlanFilter" part. I tried a few
variations of the code, but it basically goes like the following:
$op = "http location to URL";
try {
$x = @new SoapClient($op,
array('local_cert'=>file_get_contents('./client.trustore'),'passphrase'=>abcdef,
'trace
'=>1));
} catch (SoapFault $E) {
echo $E->faultstring;
}
$results =
$x->getOrderPlanConfig(array('credential'=>array('user'=>'user',
'password'=>'pass', 'group'=>'group')
, array('orderPlanFilter'=>array('deviceName'=>'abc'))));
echo "REQUEST:<br />" . htmlentities($x->__getLastRequest()) . "<br
/>";
echo "<br /><br />";
var_dump_pre($results);
echo "<br /><br />";
And the response I received is (line break inserted manually for convenience):
REQUEST:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://www.xyz.com/product/schema/common"
xmlns:ns2="http://www.xyz.com/product/schema/config">
<SOAP-ENV:Body>
<ns2:getConfig>
<ns1:credential>
<ns1:user>user</ns1:user>
<ns1:password>pass</ns1:password>
<ns1:group>group</ns1:group>
</ns1:credential>
</ns2:getConfig>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
object(stdClass)#2 (3) {
["ok"]=>
string(2) "ok"
["error"]=>
NULL
["data"]=>
NULL
}
I expected to receive some data based on the orderPlanFilter but since the request does not contain
the "orderPlanFilter" part, I'm not getting any data back.
Following is the result of "getFunctions()" and "getTypes()" from the WSDL:
Available Functions:
reply editorderPlanConfig(editConfig $orderPlanConfigEditRequest)
reply getorderPlanConfig(getConfig $orderPlanConfigGetRequest)
Available Types:
struct credentialsType { string user; string password; string group; }
string ErrorTypes
string ErrorTag
struct dataErrorInfo { short sequenceNumber; string message; }
struct errorInfoType { dataErrorInfo badAttribute; dataErrorInfo badElement; dataErrorInfo
okElement; dataErrorInfo errElement; dataErrorInfo noopElement; }
string ErrorSeverity
string errorOptionType
struct errorType { ErrorTypes errorTtype; ErrorTag errorTag; ErrorSeverity errorSeverity; string
erroAppTag; string errorPath; int errorNumber; string errorMessage; errorInfoType errorInfo; }
string IP
string filterType
struct filter { filterType type; positiveInteger pageIndex; positiveInteger pageSize; }
string mediaRoutingType
struct webServiceFilter { webServiceFilterType type; positiveInteger pageIndex; positiveInteger
pageSize; short sequenceNumber; }
string webServiceFilterType
struct intFilter { intOperator operator; string value; }
string intOperator
struct dateFilter { dateOperator operator; string value; }
string dateOperator
struct dateTimeType { dateTime dummy; }
struct config { credentialsType credential; orderPlanConfigType orderPlanConfig; }
struct dataType { orderPlanConfigType orderPlanConfig; }
struct reply { string ok; errorType error; dataType data; }
struct editConfig { config config; errorOptionType errorOption; }
struct getConfig { credentialsType credential; orderPlanFilterType orderPlanFilter; }
struct orderPlanFilterType { string deviceName; string group; string planName; dateFilter created;
dateFilter lastModified; }
struct orderPlanType { deviceName deviceName; group group; planName planName; dateTime created;
dateTime lastModified; }
string deviceName
string group
string planName
struct orderPlanConfigType { orderPlanType orderPlan; orderPlanConfigCommand command; short
sequenceNumber; }
string orderPlanConfigCommand
Thanks,
Bilig