Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / February 2005

Tip: Looking for answers? Try searching our database.

Reading XML data returned back from a web service method

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ian Meakin - 01 Feb 2005 17:45 GMT
I am trying to consume a web service i have written.  The web service returns
to the client an array of objects.  The web service when tested via inetrnet
explorer retruns the correct xml data.  I just dont understand how in my
client application to read the xml returned back.  How do i capture the xml
stream and then read it to use on the client?

--------------------------------
Copy of some xml outputted by the web service when invoked via IE:

<?xml version="1.0" encoding="utf-8" ?>
<ArrayOfWmpLibItem xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://tempuri.org/">
<wmpLibItem>
 <artist>Cooper Temple Clause</artist>
<songs>
 <anyType xsi:type="xsd:string">Cooper Temple Clause - Who Needs Enemies
When You Got Friends</anyType>
 <anyType xsi:type="xsd:string">Did You Miss Me?</anyType>
 <anyType xsi:type="xsd:string">Let's Kill Music</anyType>
 <anyType xsi:type="xsd:string">Digital Observations</anyType>
 </songs>
 </wmpLibItem>

----------------------------------
Web service:

[WebMethod]
  [XmlInclude(typeof(IRemotePlayer.wmpLibItem))]
         public IRemotePlayer.wmpLibItem[] listDB()

        {
            IRemotePlayer.wmpLibItem[] db;
            registerChannel();
            db = remLibObj.createDB();   
            unregisterChannel();       
                       
            return db;
        }

--------------------
Client method

proxy = new ws.wmpWebServices();

--> need to read the xml returned from this method --> proxy.listDB();
-------------
Scott M. - 01 Feb 2005 18:50 GMT
You could have the XML stream returned read directly into a new XMLDocument
object using its LoadXML method

(XMLDocument.LoadXML = webMethod.getSomeXML)

From there, you can parse the XML yourself or even load that up into a
DataSet.

>I am trying to consume a web service i have written.  The web service
>returns
[quoted text clipped - 46 lines]
> --> need to read the xml returned from this method --> proxy.listDB();
> -------------
Ian Meakin - 01 Feb 2005 19:11 GMT
The method returns an array of objects.  How can get the xml stream to feed
into XMLDocumentLoadXML? I see the xml stream when i use the web service test
page in IIS.

> You could have the XML stream returned read directly into a new XMLDocument
> object using its LoadXML method
[quoted text clipped - 54 lines]
> > --> need to read the xml returned from this method --> proxy.listDB();
> > -------------
Dilip Krishnan - 01 Feb 2005 20:10 GMT
Hello Ian,
  You should be able to access serialized array of IRemotePlayer.wmpLibItem
objects. Why would u need to access the xml stream? Am I missing something?

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com

> The method returns an array of objects.  How can get the xml stream to
> feed into XMLDocumentLoadXML? I see the xml stream when i use the web
[quoted text clipped - 54 lines]
>>> --> need to read the xml returned from this method -->
>>> proxy.listDB(); -------------
Ian Meakin - 01 Feb 2005 20:39 GMT
I can access the array object but i cannot get the items out of the array.  
The items fields such as <artist> and <songs> seem to be inaccesaible. I want
to be able to get the values out of the array but do not know what i am doing
wrong? The client does not have access to the class wmpLibItem so how can I
deserialize the object back so i can get the <artist> and <song> values?

> Hello Ian,
>    You should be able to access serialized array of IRemotePlayer.wmpLibItem
[quoted text clipped - 65 lines]
> >>> --> need to read the xml returned from this method -->
> >>> proxy.listDB(); -------------
Dilip Krishnan - 01 Feb 2005 20:47 GMT
Hello Ian,
Make your songs an XmlElement and mark them with the XmlAny attribute. Then
you'll get an xml element in your songs variable.

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com

> I can access the array object but i cannot get the items out of the
> array.  The items fields such as <artist> and <songs> seem to be
[quoted text clipped - 73 lines]
>>>>> --> need to read the xml returned from this method -->
>>>>> proxy.listDB(); -------------

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.