Groups | Blog | Home
all groups > dotnet distributed apps > november 2005 >

dotnet distributed apps : getting a XML output from a WebMethod function


Ross
11/22/2005 6:09:02 PM
Hi folks

I am told that for interop purposes it is better to have a procedure that
returns XML rather than a DataSet.

How do you do this?

Is it just a matter of having a public function (with WebMethod) that
returns XML?
eg Public function(args) as XML

etc

Then in the body of the function using the fill method of the DataAdaptor.
eg adAdaptor.Fill(xml variable)
return(xmlvariable)

or something like that?

If somebody could head me in the right direction I would muchly appreciate it.

Kind regards & thanks in advance

Luxspes [MCP]
11/22/2005 8:47:30 PM
[quoted text, click to view]
Haven't heard of that... the DataSet "is" XML...

[quoted text, click to view]

Perhaps Public function(args) as String ? (XML... is finally a string of
characters...)

[quoted text, click to view]

AFAIK it is not possible to return an object of type "XML" you have to
return a DataSet... or a string, or an integer... or any other
serializable object...

[quoted text, click to view]

For what exactly do you want to use the webservice? (interop with what?)

[quoted text, click to view]
Paul Gielens
11/27/2005 12:00:00 AM

Hi Ross,

Actually... imagine the following service operation:

[WebMethod]
public DataSet FindCustomerOrder(string customerId) {}

With an ASP.NET Web Services you can create a full-blown web service by
decorating an arbitrary method with the WebMethod attribute. The .NET Web
Services infrastructure will then serialize the resulting DataSet to an XML
message and pass it on the wire. The consumer of your service (non .NET
consumer) receives the XML message as plain text. In case you use the Web
Service wizard in Visual Studio.NET it will autogenerate a proxy which lets
you believe objects are passed across the wire but underneath the
infrastructure takes care of serializing/deserialising your objects
instances to XML messages and visa versa. I would certainly advise you to
read up on ASP.NET Web Service internals to get a complete picture
(http://msdn.microsoft.com/webservices/).

Whether or not it is the right thing to use .NET specific objects in your
web services is another discussion.

Best regards,
Paul Gielens

Visit my blog @ http://weblogs.asp.net/pgielens/
###

[quoted text, click to view]


AddThis Social Bookmark Button