Hey guys,
I recently lost hours to the PHP 5.2.1 SoapClient when trying to use a remote webservice. There are two methods I have to use, the first one worked like a charm and the second one has me fuming mad. The two methods are "GetSessionToke n" which expects two strings, and "SetProjectData " which expects XML wrapped in a CDATA tag.
My problem is that the XML I pass to SetProjectData is being escaped by the PHP SoapClient and I don't know how to turn this off. The XML characters < > and & are being escaped to < > and & -- I need this to stop! It's not documented on php.net anywhere and I don't know where to turn.
Sample:
[code=php]
$client = new SoapClient('my. wsdl',array('tr acing'=>1));
$getSessionToke nParams = array('username '=>$username,'p assword'=>$pass word); //When passed to the webservice in the next line, this creates two XML tags, <username> and <password> with the appropriate values inside
$client->GetSessionToke n($getSessionTo kenParams); //Runs properly, gives me a session token.
$setProjectData Payload = "<![CDATA[<data><projecti nfo>details</projectinfo></data>]]>"; //Webservice expects inside XML to be wrapped in CDATA
$setProjectData Param = array("sdsXML" => $setProjectData Payload); //Webservice expects CDATA to be inside one sdsXML tag
//Here's where it breaks:
$client->SetProjectData ($setProjectDat aParam); //Remote webservice fails with "not properly formated XML" error
echo $client->__getLastReque st(); //Output the Webservice request and what do I find? $setProjectData Payload has all of the XML tags <, > and & have all been escaped and I didn't do it. The sdsXML tag itself is not escaped, only its contents. Why is this happening? Where is this documented?
[/code]
[Please use CODE tags when posting source code. Thanks! --pbmods]
Most importantly: How the heck do I turn "feature" off? I just want it to pass the literal data I send to it, please no chracter escaping!
I recently lost hours to the PHP 5.2.1 SoapClient when trying to use a remote webservice. There are two methods I have to use, the first one worked like a charm and the second one has me fuming mad. The two methods are "GetSessionToke n" which expects two strings, and "SetProjectData " which expects XML wrapped in a CDATA tag.
My problem is that the XML I pass to SetProjectData is being escaped by the PHP SoapClient and I don't know how to turn this off. The XML characters < > and & are being escaped to < > and & -- I need this to stop! It's not documented on php.net anywhere and I don't know where to turn.
Sample:
[code=php]
$client = new SoapClient('my. wsdl',array('tr acing'=>1));
$getSessionToke nParams = array('username '=>$username,'p assword'=>$pass word); //When passed to the webservice in the next line, this creates two XML tags, <username> and <password> with the appropriate values inside
$client->GetSessionToke n($getSessionTo kenParams); //Runs properly, gives me a session token.
$setProjectData Payload = "<![CDATA[<data><projecti nfo>details</projectinfo></data>]]>"; //Webservice expects inside XML to be wrapped in CDATA
$setProjectData Param = array("sdsXML" => $setProjectData Payload); //Webservice expects CDATA to be inside one sdsXML tag
//Here's where it breaks:
$client->SetProjectData ($setProjectDat aParam); //Remote webservice fails with "not properly formated XML" error
echo $client->__getLastReque st(); //Output the Webservice request and what do I find? $setProjectData Payload has all of the XML tags <, > and & have all been escaped and I didn't do it. The sdsXML tag itself is not escaped, only its contents. Why is this happening? Where is this documented?
[/code]
[Please use CODE tags when posting source code. Thanks! --pbmods]
Most importantly: How the heck do I turn "feature" off? I just want it to pass the literal data I send to it, please no chracter escaping!
Comment