This is an example, or rather a small story, that tries to show how schemas are used (or could be used) when a web service method is called. The example shows a document-oriented solution to this problem. That means that we only use one parameter as the input to the method and only one parameter as output from the method. Each of these parameters is an xml document that contains several elements.
THE STORY - CARL SHOULD RENEW HIS DRIVING LICENSE
Carl's, the little yellow guy, has to renew his rather old driving license with a new one.
In Sweden this is done (or was until 1993) at a central Motor Vehicles office called TSV. This office has several different services, where Driving License is just one of them. This service is represented by the little green guy. We could call her Greta.
The first thing that Carl needs to do is to get an application form for renewing his driving license. He gets that from TSV.
The next thing that Carl does is to fill out the form and return it to Greta. It is now that the process, for Greta anyway, starts.
Greta takes the supplied form and check first if it is correctly entered. That's no problem because Carl has very carefully filled in the form. The next thing that Greta does is to start the process to renew his license. This is not a simple task. She has to look in three registers. You located in the basement and open only on Thursdays between nine and eleven.
Fourteen days later the paperwork for Greta is finished and everything has gone very well. Now is the time for Greta to return the new Driving License to Carl. She takes an empty driving license template and fills it out.
The last thing that she does is to send it to Carl.
This rather silly example tries to show how a web service method, here called RenewDrivingLicense is processed. The method is document-oriented in its communication. Carl had first to get an application form. This is the schema (Xsd) for the request parameter of the method. He acquires this (and other thing such as the name of the methods that the organization has and the returning schemas) from TSV. (In Visual Studio .NET it could be done by adding a Web Reference to a project.)
When he has the schema for the request, he starts to fill out it. In .NET this is usually done by instantiate an object and assign values to its properties. When he has finished this, he sends the request to Greta.
The first thing that RenewDrivingLicense do is to validate the request. And it validates the request according to the same schema that Carl used to make the request. (Other validations could also be done here as well.) I'm sorry to say that these validation functions are not automatically done for us. We have to build them ourselves. But do not despair; they are rather simple to build. Here is a good example.
After the validation the real work begins. This work is complete hidden for Carl. This is the internal part of the method.
In our example this work turns out well and the method (or Greta) gets the schema that defines the response from the method. This could include some conversions of the returning data.
This object is returned to Carl and everybody is happy thereafter.
The Wsdl describes the method and its parameters. Xsd is used to describe the data that will be communicated.
Dag, I like your story, frankly.
This may be how I would explain why I (and a lot of other people) think that a contract-first approach to Web services is better than thinking in objects, methods, and RPCs.
FYI:
http://www.thinktecture.com/Resources/Software/WSContractFirst/default.html
And this walkthrough might be updated with yellow and green characters ;)
http://www.thinktecture.com/Resources/Software/WSContractFirst/WSCF04Walkthrough1.html
Thanks.
Posted by: Christian Weyer | 2004-12-08 at 09.16
I think you are not quite right and you should still studying the matter.
Posted by: RamonGustav | 2010-08-26 at 06.43