Re: how to return xml document from a web service
From: R.A. (temp_at_hotmail.com)
Date: 11/24/04
- Next message: Carolina G?mez A: "Crystal Reports"
- Previous message: Dan Rogers: "RE: FileNotFoundException"
- In reply to: Dan Rogers: "RE: how to return xml document from a web service"
- Next in thread: Keith Chadwick: "Re: how to return xml document from a web service"
- Reply: Keith Chadwick: "Re: how to return xml document from a web service"
- Reply: Dan Rogers: "Re: how to return xml document from a web service"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 24 Nov 2004 11:59:44 -0600
Thanks for the information.
I was thinking on the following web method
string MyWebMethod (string inputXml)
{
validate the inputXml against a schema
process the information
return outputXml
}
Both consumer and provider have to validate the xml they recieve with the
same schema located at a known url.
Would that be a good approach? The schema contains simple data such as
string, int, dateTime
Thanks
"Dan Rogers" <danro@microsoft.com> wrote in message
news:ki8l%23wk0EHA.768@cpmsftngxa10.phx.gbl...
> Hi,
>
> One thing to think about is separating the way you think about programming
> methods from the wire transport. Specifically, the strongly typed XML
> document governed by a schema is something that is readily mapped to the
> wire. Working with XML as the data type in your method calls, however is
> not only unnecessary, but difficult and error prone.
>
> The easiest way to return well formed XML documents on the wire is to make
> a class on the ASP.NET side (or CLR side) and then take those class types
> as input arguments, and return classes as output types. Inside of your
web
> method, feel free to implement your data access logic any way you want,
but
> in the case of repeating elements, simply copy these to arrays or
> collections that are contained within your return class instances.
>
> An easy way to do this is to define your interface in schema first. This
> way you can quickly drive agreement as to what the on the wire contract
> needs to look like. If you are careful to follow cross-platform
guidelines
> such as those published in the WS-I.org basic profile, your .NET types
will
> readily map to the on the wire XML types, and then be easily consumed by
> other tool sets, be they Java, PERL, or other language based.
>
> Tools are then your friend for translating the schema contract into .NET
> implementations. Tools such as XSD.exe, XsdObjectGen.exe or a number of
> third party commercial tools that work with Visual Studio.NET help you
take
> the schema defined contracts and create class implementations that readily
> and reliably transofrm to the correct XML on the wire.
>
> Another great way to start is to simply deinfe your types as compound
> classes - and limit your member types to known cross platform capable data
> types (DataSet is not one of them). The trick is to avoid types that are
> not found in the intersection of the types supported natively in your
> favorite tools. or instance, in the set of Java, XSD XML Schema) and
java,
> restricting your data definitions to fields of types ( dateTime, double,
> float, int, enum and string, and avoiding schema constucts such as
> nillable, union, unnamed groups) and building your compound types form
> these (yes, repeating elements that contain these types are allowed) - you
> assure an automatic mapping between tools such as Visual Studio.NET and
> java tools such as Systinet, BEA and Websphere. A rule of thumb to
> consider is to avoid hand coding XML - this is error prone and requires a
> great deal of testing and rework to get right if all parties involved have
> to verify their implementations. For schema, a good rule of thumb is that
> if you can define it simply versus with some complex but cool schema
> construct, side towards the simple an inelegant approach - these have
> broader tool support.
>
> I hope this helps
>
> Dan Rogers
> Microsoft Corporation
> --------------------
> >From: "R.A." <temp@hotmail.com>
> >Subject: how to return xml document from a web service
> >Date: Wed, 24 Nov 2004 09:11:01 -0600
> >Lines: 34
> >X-Priority: 3
> >X-MSMail-Priority: Normal
> >X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
> >Message-ID: <uWFZQfj0EHA.3972@TK2MSFTNGP12.phx.gbl>
> >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
> >NNTP-Posting-Host: 204.124.82.48
> >Path:
>
cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12
> phx.gbl
> >Xref: cpmsftngxa10.phx.gbl
> microsoft.public.dotnet.framework.aspnet.webservices:26800
> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
> >
> >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
> >
> >
> >
>
- Next message: Carolina G?mez A: "Crystal Reports"
- Previous message: Dan Rogers: "RE: FileNotFoundException"
- In reply to: Dan Rogers: "RE: how to return xml document from a web service"
- Next in thread: Keith Chadwick: "Re: how to return xml document from a web service"
- Reply: Keith Chadwick: "Re: how to return xml document from a web service"
- Reply: Dan Rogers: "Re: how to return xml document from a web service"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|