Output XML from a .net webservice

M

Mahesha

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,
Mahesha
 
J

Jan Tielens

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
 
T

Trebek

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top