Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User mandardac's Avatar
    Join Date
    Sep 2011
    Posts
    6
    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 wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    27,744
    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
    Nokia Developer Champion WPMorocco's Avatar
    Join Date
    Jul 2012
    Posts
    78
    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, 07:41
  3. Reg:soap message parsing
    By gurubai in forum Symbian C++
    Replies: 3
    Last Post: 2010-08-10, 15:54
  4. 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
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved