webservices, return xml without .net injecting xml schema

Discussion in 'ASP .Net' started by Peter Nofelt, Sep 13, 2005.

  1. Peter  Nofelt

    Peter Nofelt Guest

    Hey all,

    I want to return an xml structure without .net trying to inject any of
    its xml schema? Can this be done?

    Here is the scenario:
    I'm running into an issue with the return string of my .NET
    webservice. I am attempting to return an xml string similar to this:

    <?xml version="1.0" encoding="utf-8" ?>
    <sInfo>
    <name>tom</name>
    <title>boss</title>
    <stuff>
    <anyType>wow</anyType>
    <anyType>wow2</anyType>
    </stuff>
    </sInfo>

    But instead I receive this:


    <?xml version="1.0" encoding="utf-8" ?>
    <sInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://tempuri.org/">
    <name>tom</name>
    <title>boss</title>
    <stuff>
    <anyType xsi:type="xsd:string">wow</anyType>
    <anyType xsi:type="xsd:string">wow2</anyType>
    </stuff>
    </sInfo>

    Note, for my webservice I am returning a struct. The definition of that


    struct is:
    public class sInfo{
    public string name;
    public string title;
    public ArrayList stuff;
    //public Array smArray;
    public sInfo()
    {
    stuff = new ArrayList();
    }
    }

    Most importantly I do not want any of the 'xsi:type=' attributes to
    be present in the return structure. Is there any way to override the
    return so that I can return self defined xml. I am even willing on
    returning hand built xml, but .NET encapsulates the structure within a
    <string> tag?

    So to summarize, I want to return an xml structure without .net trying
    to inject any of its xml schema? Can this be done?
     
    Peter Nofelt, Sep 13, 2005
    #1
    1. Advertising

  2. Peter  Nofelt

    Stefan Guest

    It'd be good if you could post some code for your example.

    I assume you are doing something like this:

    [WebMethod]
    public sInfo MyService()
    {
    ...
    }

    If that is the case you could simply change it to

    [WebMethod]
    public string MyService()
    {
    /// return custom serialized xml string here
    }

    Of course this new version would be no real help when creating client
    stubs to consume this service (no more strong typing
    because all type information which .Net injects automatically is lost)
     
    Stefan, Sep 13, 2005
    #2
    1. Advertising

  3. Peter  Nofelt

    Peter Nofelt Guest

    Hey Stefan,

    I tried returning a string, but .net encapsulates the xml string in a
    <string> tag, thus not rendering the hand build xml as xml (even though
    its valid).
     
    Peter Nofelt, Sep 13, 2005
    #3
    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. Christopher Ambler
    Replies:
    2
    Views:
    648
    Christopher Ambler
    Aug 27, 2003
  2. Markus
    Replies:
    1
    Views:
    1,632
    Markus
    Nov 23, 2005
  3. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,311
    Stanimir Stamenkov
    Apr 25, 2005
  4. Replies:
    3
    Views:
    3,059
  5. Peter  Nofelt

    webservices, return xml without .net injecting xml schema

    Peter Nofelt, Sep 13, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    119
    Peter Nofelt
    Sep 13, 2005
Loading...

Share This Page