best practicies

F

Fabiano

Please,

what's the best practicies when creating a webservice? Should i use XML
parameters, Object Parameters or dataset?

Is there any tutorial, about it?

tks in adv.

Fabiano
 
G

Guest

Hello Fabiano!

In my experience, there are no problems using DataSets as Parameter or
ReturnValue of a WebMethod, because there is some kind of 'extra-support'
within the Framework.
Also with simple classes (string, integer, ...) there should be no problem.

What I've experienced is, that it is very complicated to use own classes as
Parameters, because then you have to implement the serialisation to xml for
these classes.

What worked for me was to define 'ParameterClasses' (within a separate
project) that have at least two methods (that can call the same methods of
their members):

1) toXml() as System.Xml.XmlElement
2) ReadXml(pXml As System.Xml.XmlElement)
The WebService then takes XmlElements as Paramters. The workflow is like

1) Client: xmlParam = objParam.toXml
2) Client: xmlResult = WebService.ReturnSomething(xmlParam)
-----
3) Server: objParam = objParam.ReadXml(xmlParam)
....
4) Server: return = objResult.toXml
-----
5) Client: objResult = xmlResult.ReadXml(xmlResult)

I had no luck to define Serialisation the 'default-.NET-way" but the given
solution works good for me.

Good luck,
D.Barisch
 
H

Harris Reynolds

It's probably a bit early to be talking about best practices with web services. :) But there do seem to be some reasonable guidelines

Primarily sticking with strongly typed parameters is one of the more important things. Typically things like complex data structures, datasets, primitives etc. are all fine; you'll start to run into problems however once you try to expose things like heterogenous collections etc. (what would the Xml schema for that look like?? :-

Also it seem to be a "best practice" with web services to use document/literal style SOAP. That's the default with .Net though so you shouldn't have to worry about thata

One other point is versioning of web services. It has been suggested that an open content model is a good way to achieve this (see Doug Purdy's MSDN TV appearance). The basic approach here is to have a generic XmlElement that is part of the contract that can be used in the future to add data without breaking old clients

hope that helps some

~harri
weblog: http://www.harrisreynolds.net/weblog
 

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,770
Messages
2,569,584
Members
45,078
Latest member
MakersCBDBlood

Latest Threads

Top