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.


  • Thanks Christian,

    I have noticed your blog long time ago and keep on watching the good stuff you have there :-)

  • Hi, Did you find out how to achieve same thing from VS 2005? Right now, if I add web reference to 2 difference webservice, which share same Server class, I end up with TWO different proxy types.
    So annoying. Did you have a way around it? ( I don't find anything for this problem in Christian Weyer's post)

  • As you had said, We can sharetypes using command line: wsdl /sharetypes , but now I have local wsdl files (together with xsd files) and I want to generate the service proxy classes using wsdl . Unfortunately, the command: wsdl can't use with the parameter /sharetypes. After I generated the proxies, I got "the already contains a definition" error. Can you give some advices to share types using wsdl ? Thanks a million!

Comments have been disabled for this content.