Web services response looks suspect, simplexml_load_string()
Posted: Fri May 15, 2009 8:34 pm
I am having a difference of opinion with a client about the XML he is sending me from his web service.
What I expect to get is something like this:
But what I get is like this. ( Actually it was full of & lt; and & gt; entities but I ran it through html_entity_decode() after the curl fetch.)
Parsing this with simplexml_load_string(), I get a warning: "XML declaration allowed only at the start of the document".
Questions:
1. It looks like their server is wrapping the xml doc with another xml wrapper, right? String tag? If so, would that likely to be caused by a server misconfiguration, or a programmer? I think that would explain the encoded brackets too.
2. When testing, I used Firefox to submit a request, then 'view source' to check the response. Is that valid? Will I see the actual response without artifacts, encoding, etc?
thx!
What I expect to get is something like this:
Code: Select all
<?xml version="1.0" encoding="UTF-16"?>
<Foo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<User ID="200" TOKEN="2343DD9C" />
</Foo>Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://foo.example.com/Authentication/">
<?xml version="1.0" encoding="UTF-16"?>
<Foo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<User ID="200" TOKEN="2343DD9C" />
</Foo>
</string>Questions:
1. It looks like their server is wrapping the xml doc with another xml wrapper, right? String tag? If so, would that likely to be caused by a server misconfiguration, or a programmer? I think that would explain the encoded brackets too.
2. When testing, I used Firefox to submit a request, then 'view source' to check the response. Is that valid? Will I see the actual response without artifacts, encoding, etc?
thx!