Jump to content

[SOLVED] php5 SoapServer XML, almost....


mrgenericuser

Recommended Posts

I am writing a soap app. using php5 soapserver, and exteded DOMDocument class.

 

the whole app uses almost exclusively XML for data, even stores that way.  when i get data with xml special chars added to an xml document, i wrap with a CDATA tag so that when i transform the XML, you won't see entities in the select boxes and such.  the problem comes in when i want to send an XML to and from the soapserver, it will send my xml documents as a string, but not as part of the xml... then it winds up with all kinds of issues including nested CDATA tags or my xml entitied out...

 

is there any way to have the handle function append my xml to the soap return tag as a child tree to avoid these issues?  i can't find any exapmples of an alternative to the handle function or a way to modify it...

 

FYI: i am using the WSDL method, using a php class called 'WSDL_Gen.php' that i found via google.

Link to comment
https://forums.phpfreaks.com/topic/175558-solved-php5-soapserver-xml-almost/
Share on other sites

ok, tracked down an alternate way to fix this, i am posting it in case someone else can benefit.

 

soapserver is entity encoding the string before it returns, so my problem was actually that the js soap client was wrapping cdata tags around my xml.  the fix is to use cdata tag around individual values in my xml as i was already doing, but to entity encode &, ", ', <, > the ENTIRE xml into the soap request.  then html_entity_decode the whole xml document in my xml document classes in php and js, and update all of my 'isXML' functions to return true on both real xml and entity encoded xmls.

paraphrase of my old soap request (with failing nested cdata):

<soapenv>...

    <body>

        <function type="xsl:string"><![CDATA[<myxml><value><![CDATA[mom & dad]]></value></myxml>]]></function>

    </body>

</soapenv>

 

paraphrase of my new xml soap request:

<soapenv>...

    <body>

        <function type="xsl:string"><myxml><value><![CDATA[mom & dad]]></value></myxml></function>

    </body>

</soapenv>

 

 

then as i said, when you call  "$x=new myXMLDocument($xmlstring);" you just correct your constructor to check if the xml itself is entity encoded or not and decode if needed.  it is best if you just write a function that decodes ONLY these characters &, ", ', <, > because that is all you encode.  any other entities are there legitimately in the xml and should be untouched.

 

hope this helps someone else......

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.