Oct 15
Watch out for whitespace in PHP SOAP classes
Posted by James Netherton | Monday 15 October 2007 8:49 PM | In PHP
A small gotcha when I was testing out the native PHP SOAP libraries. No doubt this is documented somewhere and more seasoned PHP programmers will be aware of this.....
Whilst testing out a simple webservice that I had created, I had problems invoking the service methods that I had defined. The error message was suggesting that the SOAP response was not well formed XML. On investigating further, I noticed that a number of characters were missing off of the SOAP XML response. Specifically the closing '/>' characters to close the XML document root node.
After much head scratching, I turned to Google where it took me a long time to track down the cause of the problem. In my web service class file, I had a number of blank lines after the closing '?>' scriplet block. For every blank line, a character would be stripped off the SOAP response XML.
After I cleaning up the whitespace I started getting valid responses again.
0 Comments
[Post comment]