webservices, return xml without .net injecting xml schema

  • Thread starter Thread starter AtariPete
  • Start date Start date
A

AtariPete

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?
 
AtariPete,

There is no schema that is being passed back. What you are seeing is
attributes that conform to a schema agreed upon for web services being
returned.

Why do you want to remove this? Why not expose your web service, create
your proxy (which will create the structure exposed by your web service),
and then use that? Why the concern over what is sent on the line?
 
Its a matter of not needing the schema. The return xml is predefined
(except for the total # of <anytype>'s returned). Thus it is of no need
to the clients.

Nicholas, Is there no way to prevent these attributes from being
injected into the xml? Let me know, your feedback is much appreciated.
 
If this is the case, you really don't want to use a web service, since
they conform to pre-defined schemas which you need to abide by.

There isn't way to strip the attribute and namespace information
(technically, the schema is not in the XML that is being returned, it
conforms to a schema though) when using a web service.

What you really want is a http response that returns XML, not a web
service. I would just create an ASPX page that returns a content type of
"text/xml" and manually write the XML through the Response object exposed by
the page.
 
Back
Top