I am getting a web service response as below. It has additional XML tag and string tag in the response. I was not able to load this response into XMLDocument object in Dot Net. I have asked web service provider to remove those tags before sending response. But they said that this is the web service standard. Is it how web service suppose send the response?
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/"><?xml version="1.0" encoding="UTF-8"?><?ACORD version="1.7.0"?>
<ACORD><InsuranceSvcRs></InsuranceSvcRs></ACORD></string>
Here is the code that calls web service
using (var webClient = new WebClient())
{
webClient.Credentials = Credentials;
byte[] responseArray;
NameValueCollection postValues = GetParameters();
responseArray = webClient.UploadValues(GetUploadURL(), "POST", postValues);
responseString = Encoding.ASCII.GetString(responseArray);
}
Since I am using WebClient (not web service proxy), does web client class format the response like this?
EDIT: When I tried with sample HelloWorld webservice with the above code, I got the response like this
<?xml version=\"1.0\" encoding=\"utf-8\"?><string xmlns=\"http://tempuri.org/\">Hello World</string>
Having said that, I am repharasing my question Is it how webservice suppose send the response, when client proxy POST to the webservice?
they said that this is the web
service standard
All that I could recommend you is switching service provider :-)
If you don't, long and painful string manipulation is awaiting you unless your service provider doesn't provide you with an API capable of parsing this standard.
Duplicated <?xml version="1.0" encoding="UTF-8"?>
If the service is giving you that answer, they have a bug.
- If you can, use another service.
- If you can't, you can always delete it from the XML and later process it.
Hey guys thank you for all you responses. Since I am using the WebClient class to Post to thier webservice, response content does include "String" tag. But if I use web service proxy, .net does extract the content and remove the string tag for us. So the response is web service standard. When I tested with sample service I got the response like this
<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<string xmlns=\"http://tempuri.org/\">Hello World</string>
Yes you are correct John Saunders. .Net does nothing as I said in my earlier answer. Response itself different when I post versus use proxy.
When I use proxy I got response like this as a Soap<HttpResponse>
<StatusCode>OK</StatusCode>
<StatusDescription>OK</StatusDescription>
<WebHeaders>
<Content-Length>363</Content-Length>
<Cache-Control>private, max-age=0</Cache-Control>
<Content-Type>text/xml; charset=utf-8</Content-Type>
<Date>Mon, 12 Jul 2010 20:01:17 GMT</Date>
<Server>Microsoft-IIS/6.0</Server>
<X-AspNet-Version>2.0.50727</X-AspNet-Version>
<X-Powered-By>ASP.NET</X-Powered-By>
</WebHeaders>
</HttpResponse>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"></s:Header>
<soap:Body>
<HelloWorldResponse xmlns="http://tempuri.org/">
<HelloWorldResult>Hello World</HelloWorldResult>
</HelloWorldResponse>
</soap:Body>
</soap:Envelope>