473,779 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.writexm l (...) 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 33402
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]
[SoapDocumentMet hod(ParameterSt yle=SoapParamet erStyle.Bare)]
public XmlDataDocument ReturnXmlDataDo cument()
{
MyTypedDataSet myDataSet = this.MagicallyF illMyTypedDataS et();

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.co m> wrote in message
news:%2******** ********@TK2MSF TNGP12.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]
[SoapDocumentMet hod(ParameterSt yle=SoapParamet erStyle.Bare)]
public XmlDataDocument ReturnXmlDataDo cument()
{
MyTypedDataSet myDataSet = this.MagicallyF illMyTypedDataS et();

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.writexm l (...) 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 ExecuteXmlReade r 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
3440
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 now I'm trying an XmlTextWriter instead. I whipped-up another webservice based on this: http://www.codeproject.com/aspnet/RSSviaXmlTextWriter.asp?print=true This example isn't set up strictly as a webservice. It seems to output to an aspx...
2
14346
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 need to do. And all that fancy ASP.NET serialization really got in my way. Reading articles by Yasser Shohoud, Tim Ewald, and Matt Powell led me down many promising paths, along the way writing an XSD schema file for my messages, trying to...
1
20953
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 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...
16
4929
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 Microsoft must be installed on their servers. Now german Umlaute (ä, ü, ö) and quotes are returned incorrectly in SOAP fault responses. This can be easily verified: Implement the following in a web service method (just raises a SOAPException with a...
9
3220
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. What it does is to call a webservice with two parameters, one being a integer, the other one being a "String" which contains XML (not the best practice, however that is the target interface and we cannot change that).
1
2862
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 types and of more elaborate classes implementing IXmlSerializable. The resulting WSDL file for the webservice has two separate schemas in its <types> sections, and the client proxy (generated with wsdl.exe) is missing the definitions of the...
5
6973
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 returns it to the calling client. Maybe I don't understand all I know about this but for some reason what is returned is an XMLNode, not a document. How does one usually return an XML Document from a web service? SHould I be using...
2
3104
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 transactionStatement; import javax.xml.transform.TransformerFactory; import javax.servlet.*; import org.jdom.*; import java.io.ByteArrayOutputStream; import java.io.File;
8
2073
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 building a text string in XML format to return, there should be some way to directly return the XML I get from SQL Server. What I seem to be getting is a properly formatted XML string that is not identified as XML (not sure why), but I want this to...
5
5174
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 xml file with the data. How do I best proceed? Best regards, Tom
0
9632
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9471
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10302
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10136
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10071
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8958
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7478
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.