Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > webservices, return xml without .net injecting xml schema

Reply
Thread Tools

webservices, return xml without .net injecting xml schema

 
 
Peter Nofelt
Guest
Posts: n/a
 
      09-13-2005
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 xmlnssd="http://www.w3.org/2001/XMLSchema"
xmlnssi="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?

 
Reply With Quote
 
 
 
 
Stefan
Guest
Posts: n/a
 
      09-13-2005
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)

 
Reply With Quote
 
 
 
 
Peter Nofelt
Guest
Posts: n/a
 
      09-13-2005
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).

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
web.xml / XML schema issue, why do some XML schema attributes disappear asciz@starmail.com Java 3 02-20-2007 09:56 AM
webservices, return xml without .net injecting xml schema Peter Nofelt ASP .Net Web Services 0 09-13-2005 02:48 PM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
XML schema regular expressions question and recommended XML Schema book Fred Smith XML 1 02-05-2004 11:12 AM
Injecting image page element without calling ASPX page? Christopher Ambler ASP .Net 2 08-27-2003 04:15 PM



Advertisments