SOAP Parsing in windows phone
hi please help me with this,
I want to parse SOAP response so i used LINQ for that,
below is my soap response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getTermsAndConditionsResponse xmlns:ns5="http://pat.ws.com/webService/Folder" xmlns:ns4="http://pat.ws.com/webService /Contact" xmlns:ns3="http://pat.ws.com/webService/Group" xmlns:ns2="http://pat.ws.com/webService/MobileSubscriber" xmlns:ns1="http://pat.ws.com/webService/Common">
<ns2:terms>
<versionID>2.2</versionID>
<lang>ENGLISH</lang>
<text>Terms Text</text>
</ns2:terms>
</ns2:getTermsAndConditionsResponse>
</S:Body>
</S:Envelope>
and i used foll code to parse this response
string XMLresponse = data;
var XResult = XElement.Parse(XMLresponse);
XNamespace ns2 = "http://pat.ws.aab.att.com/webService/MobileSubscriber";
var result = XResult.Descendants(ns2+"terms")
.Select(t => new
{
tag1 = t.Descendants("versionID").First().Value,
tag2 = t.Descendants("lang").First().Value,
tag3 = t.Descendants("text").First().Value,
});
then tag1,tag2,tag3 gives me proper values,
but when i just add one more namespace in getTermsAndConditionsResponse (xmlns=http://pat.ws.aab.att.com/webService/Folder) then my parsing fails means tag values are not initialized, what i found is if i add namespace with colon included like (xmlns:ns1=http://pat.ws.aab.att.com/webService/Folder) it works fine.
help me what is problem.
Re: SOAP Parsing in windows phone
The two variants, xmlns=... and xmlns:ns1=... have different meanings, thus if you have not modified anything else in the XML document, one of them has to fail.
When overriding the default namespace, the contained tags (versionID, lang, text) are also going to be in the given namespace.
So[CODE]tag1 = t.Descendants([COLOR="red"]ns2+[/COLOR]"versionID").First().Value[/CODE]may work better for that case.
Re: SOAP Parsing in windows phone
Try adding thos SOAP webservice as a servicereference with visual studio , you wont have to do the parsing yourself and everything will be serialized properly