Framework 2.0 - WebServices Shared Types
One of the biggest problems when developing enterprise application is sharing types between web services.
Let’s take a look of an example:
We have a web service which create an employee and return it to the client.
We have another web service which take and employee and change something in it.
When we reference our client application to these web services the wsdl.exe is run behind the scans of the visual studio and creates two proxy classes for each of these web services.
When we try to pass the employee from one to the other you get an error indicating that it’s not the same type.
The only solution for now was to manually edit the proxy.
On framework 2.0 Microsoft had extended the ability of wsdl.exe to reference several web services and create a proxy’s with shared types.
To create such a proxy you need to run the wsdl.exe with resides in the visual studio dir, note that you need to run the Framework 2.0 wsdl.exe so if you are using vs 2003 and 2005 on the same machine give the full path name.
Add /sharetypes indication to the wsdl that you want to join the types and give it the addresses of the web services
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\wsdl.exe" /sharetypes http://localhost/MyClass1/Service.asmx?wsdl http://localhost/MyClass2/Service.asmx?wsdl
As an output you will get a proxy class consuming both of the proxys to the web services and the shared type.
The only things that is missing now is to have the same ability in the Visual Studio so we will not have to go out to the command line and run the wsdl.exe, I would have expected that there will be an option to reference several web services at one and that Visual Studio will understand that I want to join the types together.