473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to return xml document from a web service

Hi,

I have an web service method that accept an xml document and returns a
different xml document.

Based on the input xml I fill a dataset with information from a database.
If the dataset has rows then I need to return those rows to the consumer.
I can't tell if the consumer of the web service will use .Net or maybe java.
1) If the web service method returns a Dataset then the consumer will get
information on the Dataset. What if the consumer has no knowledge what a
Dataset is at all (for example jave)? I know that the datase is returned in
xml represantation - but how will the consumer deal with the data to extract
the rows returned by the dataset?
2) For resone explained in section 1, I chose to return an xml document.
When I use the dataset.writexml (...) it writes only thetables rows
information and doesn't write the xml header. Am I to use XmlDocument to
construct the xml and write to it the datase and then send it as a string
back to the consumer? How can I tell the consumer where is the xsd for this
xml document?
3) How do I pass an XmlDocument to a web service method?

Which of the following will best fit the web service consumer?

XmlDocument webservice method (XmlDocument my xml)
XmlDocument webservice method (string my xml)
Dataset webservice method (Dataset my xml)
Dataset webservice method (string my xml)
string webservice method (XmlDocument my xml)
string webservice method (string my xml)
Thanks
Nov 21 '05 #1
4 33380
R.A. wrote:
I have an web service method that accept an xml document and returns a
different xml document.

Based on the input xml I fill a dataset with information from a
database.
If the dataset has rows then I need to return those rows to the
consumer.
I can't tell if the consumer of the web service will use .Net or maybe
java.

... snipped for brevity ...


The best way to work with DataSets in WebMethods is to encapsulate them and use XmlDataDocument to get to/from the XML. Here's an example:

<codeSnippet language="C#">
[WebMethod]
[SoapDocumentMethod(ParameterStyle=SoapParameterSty le.Bare)]
public XmlDataDocument ReturnXmlDataDocument()
{
MyTypedDataSet myDataSet = this.MagicallyFillMyTypedDataSet();

XmlDataDocument result = new XmlDataDocument(myDataSet);

return result;
}
</codeSnippet>

HTH,
Drew
Nov 21 '05 #2
How would you validate the incomming xml?

Thanks

"Drew Marsh" <dr****@hotmail.no.spamming.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
R.A. wrote:
I have an web service method that accept an xml document and returns a
different xml document.

Based on the input xml I fill a dataset with information from a
database.
If the dataset has rows then I need to return those rows to the
consumer.
I can't tell if the consumer of the web service will use .Net or maybe
java.

... snipped for brevity ...
The best way to work with DataSets in WebMethods is to encapsulate them

and use XmlDataDocument to get to/from the XML. Here's an example:
<codeSnippet language="C#">
[WebMethod]
[SoapDocumentMethod(ParameterStyle=SoapParameterSty le.Bare)]
public XmlDataDocument ReturnXmlDataDocument()
{
MyTypedDataSet myDataSet = this.MagicallyFillMyTypedDataSet();

XmlDataDocument result = new XmlDataDocument(myDataSet);

return result;
}
</codeSnippet>

HTH,
Drew

Nov 21 '05 #3
R.A. wrote:
Hi,

I have an web service method that accept an xml document and returns a
different xml document.

Based on the input xml I fill a dataset with information from a database.
If the dataset has rows then I need to return those rows to the consumer.
I can't tell if the consumer of the web service will use .Net or maybe java.
1) If the web service method returns a Dataset then the consumer will get
information on the Dataset. What if the consumer has no knowledge what a
Dataset is at all (for example jave)? I know that the datase is returned in
xml represantation - but how will the consumer deal with the data to extract
the rows returned by the dataset?
If you don't know what the client is going to be, then XML is the best
standard.

Quite frankly, I find the XmlDocument a preferrable datatype to the
DataSet or DataReader because it's searchable, it's persistent, and it
doesn't require open connections to the database. I can use an XPath
query to find data within the document.

2) For resone explained in section 1, I chose to return an xml document.
When I use the dataset.writexml (...) it writes only thetables rows
information and doesn't write the xml header. Am I to use XmlDocument to
construct the xml and write to it the datase and then send it as a string
back to the consumer? How can I tell the consumer where is the xsd for this
xml document?
I've used this technique and found that the XML delivered with the
automatic ExecuteXmlReader is really messy.

I ended up putting together my own Xml from the data piece by piece
including the header.

PS -- the consumer will not see the result as an XmlDocument, but as an
XmlNode -- there's an article on the knowledgebase about how to deal
with it.
3) How do I pass an XmlDocument to a web service method?
Just make the return type of your method an XmlDocument

Which of the following will best fit the web service consumer?

XmlDocument webservice method (XmlDocument my xml)
XmlDocument webservice method (string my xml)
Dataset webservice method (Dataset my xml)
Dataset webservice method (string my xml)
string webservice method (XmlDocument my xml)
string webservice method (string my xml)
Thanks

Nov 21 '05 #4
R.A. wrote:
How would you validate the incomming xml?


I just answered this yesterday I believe. Check out this post: http://groups.google.com/groups?q=cu...phx.gbl&rnum=1

HTH,
Drew
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bruce W.1 | last post by:
The intent of my web service is an RSS feed from a blog. Originally I used a StringBuilder to make the XML and returned a string from the webmethod. But this doesn't display properly in IE. So...
2
by: Richard A. Wells | last post by:
All I wanted to do was implement a web service where I'd receive an XML document and return one in response. I'd already figured out how to use XmlReader and XmlWriter classes to do the XML work I...
1
by: R.A. | last post by:
Hi, I have an web service method that accept an xml document and returns a different xml document. Based on the input xml I fill a dataset with information from a database. If the dataset has...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
1
by: louis_la_brocante | last post by:
Dear all, I am having trouble generating a client proxy for a webservice whose methods return a "complex" type. The type is complex in that it is a class whose members are a mix of primitive...
5
by: GH | last post by:
Can someone point me to an example of a VB.Net client that reads an XML Document from a web service? I have a web service that successfully creates an XML document, saves it on the server and...
2
by: crabsdf | last post by:
My project is a single method class which takes a xml object and, using Apache FOP, transforms it into a PDF which is returned as an output stream. Here is full code package...
8
by: Anthony Bollinger | last post by:
This is my first attempt at writing an XML web service. I have a query successfully written for SQL Server that returns XML data using FOR XML AUTO. It seems rather than processing the XML and...
5
by: TompIfe | last post by:
Hi, I have a web service that reads data from an Access database using datareader and place the data in an array that the web method returns. Now, I want to make the web service also to return an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.