Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    6

    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.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,807

    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(ns2+"versionID").First().Value
    may work better for that case.

  3. #3
    Regular Contributor
    Join Date
    Jul 2012
    Posts
    88

    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

Similar Threads

  1. SOAP web service request with credentials for Windows Phone 7
    By sreerajvr in forum Windows Phone General
    Replies: 16
    Last Post: 2012-04-03, 10:17
  2. XML Parsing for windows phone 7
    By sreerajvr in forum Windows Phone General
    Replies: 2
    Last Post: 2012-03-19, 08:41
  3. Reg:soap message parsing
    By gurubai in forum Symbian
    Replies: 3
    Last Post: 2010-08-10, 15:54
  4. How to deploy the Soap.py library in the S60 phone?
    By bharatan.vk in forum Symbian
    Replies: 1
    Last Post: 2008-08-24, 01:09
  5. Replies: 1
    Last Post: 2002-07-16, 06:44

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×