Groups | Blog | Home
all groups > asp.net webservices > january 2004 >

asp.net webservices : Output XML from a .net webservice


ycmahesh NO[at]SPAM hotmail.com
1/28/2004 4:20:22 PM
Hello,
I want to write a .net webservice which returns the data as a xml.
I get this xml from a dataset by calling GetXml method.This web
service will be used by clients who donot use .net or microsoft
platforms. This size of the xml string could be quite big.I would like
to know whats the best method to return the data.

a)Should I just return this xml as a string from my webservice.
b)Is there a better efficient approach to handle this using SOAP.

I'm a newbie and it would be great if someone could direct me to a
tutorial/link which can help me on this.

Regards,
Trebek
1/29/2004 7:38:37 AM
My advice would be to simply return the string as you are doing. If it
becomes unreasonably large, I would consider DIME as an alternative, but
only if the string return doesn't work.

Alex

[quoted text, click to view]

Jan Tielens
1/29/2004 8:04:43 AM
If you're clients are not .NET clients, it's still possible to return custom
classes for example. So if your only concern is interoperability you may
want to check out these as well.

Concerning your question, you can return an XMLDocument. Here's an example:
http://www.xmlwebservices.cc/index_Samples.htm

Source:
<!--StartFragment--><%@ WebService Language="vb" Class="XMLTest" %>

Imports System.Web.Services
Imports System.Xml
Imports System.Xml.Serialization

<WebService(Namespace:="http://eyesoft.de/webservices/")> _
Public Class XMLTest
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function _
GetXML() As System.Xml.XmlDocument
Dim myXML As New XmlDocument()
myXML.Load(Server.MapPath(".\") & "AddrBook.xml")

GetXML = myXML
End Function
End Class


--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan


[quoted text, click to view]

AddThis Social Bookmark Button