Consuming XML Web Service

Discussion in 'ASP .Net' started by =?Utf-8?B?UGV0ZXI=?=, Mar 8, 2005.

  1. Hi!

    Please, could You advice me to complete the following task:

    We have a Web Service that returns XML document with some data about our
    customers.

    [WebMethod]
    public XmlDocument getCustInfo()
    {
    //some implementation
    }

    I am trying to parse that document and to print customers' names and email
    addresses. If some custorem does not have an email address I print "no email
    address found". I have to go throught the xml document and it's nodes using
    eg. foreach statement and resolve whether customer has an email address with
    if else statements.

    Please, could You tell me, how can I load this Xml document which WebService
    provides? I tried to load it into XmlDocument object with Load method, but
    beacause it is not xml file I get errors. The help is very much appreciated.

    Thanks.

    Peter
    =?Utf-8?B?UGV0ZXI=?=, Mar 8, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?UGV0ZXI=?=

    gaidar Guest

    Hi, Peter,

    You can get text from your Web Service. I see no problem in transmitting
    XML-formatted string. Anyway, you can get string data and produce XML
    document manually.
    Could you explain your problem? I just don't understand...

    Best Regards,
    Gaidar

    "Peter" <> wrote in message
    news:...
    > Hi!
    >
    > Please, could You advice me to complete the following task:
    >
    > We have a Web Service that returns XML document with some data about our
    > customers.
    >
    > [WebMethod]
    > public XmlDocument getCustInfo()
    > {
    > //some implementation
    > }
    >
    > I am trying to parse that document and to print customers' names and email
    > addresses. If some custorem does not have an email address I print "no
    > email
    > address found". I have to go throught the xml document and it's nodes
    > using
    > eg. foreach statement and resolve whether customer has an email address
    > with
    > if else statements.
    >
    > Please, could You tell me, how can I load this Xml document which
    > WebService
    > provides? I tried to load it into XmlDocument object with Load method, but
    > beacause it is not xml file I get errors. The help is very much
    > appreciated.
    >
    > Thanks.
    >
    > Peter
    >
    >
    gaidar, Mar 8, 2005
    #2
    1. Advertising

  3. Hello!

    Thank you for the reply! I managed to resolve the issue. I just had to use
    XmlNode, eg.

    XmlNode custInfo;
    custInfo = service.getCustInfo();

    foreach (XmlNode Node in custInfo)

    if (Node.ChildNodes[1].InnerText !="") //No email found

    Now I can process the xml document returned by web service.

    Peter

    "gaidar" wrote:

    >
    > Hi, Peter,
    >
    > You can get text from your Web Service. I see no problem in transmitting
    > XML-formatted string. Anyway, you can get string data and produce XML
    > document manually.
    > Could you explain your problem? I just don't understand...
    >
    > Best Regards,
    > Gaidar
    >
    > "Peter" <> wrote in message
    > news:...
    > > Hi!
    > >
    > > Please, could You advice me to complete the following task:
    > >
    > > We have a Web Service that returns XML document with some data about our
    > > customers.
    > >
    > > [WebMethod]
    > > public XmlDocument getCustInfo()
    > > {
    > > //some implementation
    > > }
    > >
    > > I am trying to parse that document and to print customers' names and email
    > > addresses. If some custorem does not have an email address I print "no
    > > email
    > > address found". I have to go throught the xml document and it's nodes
    > > using
    > > eg. foreach statement and resolve whether customer has an email address
    > > with
    > > if else statements.
    > >
    > > Please, could You tell me, how can I load this Xml document which
    > > WebService
    > > provides? I tried to load it into XmlDocument object with Load method, but
    > > beacause it is not xml file I get errors. The help is very much
    > > appreciated.
    > >
    > > Thanks.
    > >
    > > Peter
    > >
    > >

    >
    >
    >
    =?Utf-8?B?UGV0ZXI=?=, Mar 8, 2005
    #3
  4. > Please, could You tell me, how can I load this Xml document which
    > WebService
    > provides? I tried to load it into XmlDocument object with Load method, but
    > beacause it is not xml file I get errors. The help is very much
    > appreciated.


    What errors are you getting? Here's why I'm asking:

    According to your WebMethod declaration, it returns a
    System.Xml.XmlDocument. I don't believe this class is serializable. It isn't
    marked as serializable It is important to note the difference between an
    XmlDocument class and an XML Document. An XmlDocument class is a class for
    working with XMLDocuments.

    A WebMethod returns an instance of a class, as an XML Document (NOT a
    System.Xml.XmlDocument). The class must be serializable. At the client end,
    the class is deserialized back into a class. So, as you can see, it isn't
    necessary to create an XML Document; the response is one already. It is
    necessary to create a serializable class that can be returned and
    de-serialized back into a class.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    What You Seek Is What You Get.

    "Peter" <> wrote in message
    news:...
    > Hi!
    >
    > Please, could You advice me to complete the following task:
    >
    > We have a Web Service that returns XML document with some data about our
    > customers.
    >
    > [WebMethod]
    > public XmlDocument getCustInfo()
    > {
    > //some implementation
    > }
    >
    > I am trying to parse that document and to print customers' names and email
    > addresses. If some custorem does not have an email address I print "no
    > email
    > address found". I have to go throught the xml document and it's nodes
    > using
    > eg. foreach statement and resolve whether customer has an email address
    > with
    > if else statements.
    >
    > Please, could You tell me, how can I load this Xml document which
    > WebService
    > provides? I tried to load it into XmlDocument object with Load method, but
    > beacause it is not xml file I get errors. The help is very much
    > appreciated.
    >
    > Thanks.
    >
    > Peter
    >
    >
    Kevin Spencer, Mar 8, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. xml .NET group

    Consuming NOAA XML web service

    xml .NET group, Apr 9, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    710
  2. DNB
    Replies:
    1
    Views:
    245
  3. dgleeson422111

    Consuming local web service - ok, remote web service -problem?

    dgleeson422111, Jan 26, 2010, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    892
    dgleeson422111
    Jan 26, 2010
  4. Curt K
    Replies:
    3
    Views:
    441
    John Saunders [MVP]
    Jun 15, 2007
  5. DNB
    Replies:
    1
    Views:
    297
    John Saunders [MVP]
    Jan 20, 2008
Loading...

Share This Page