Welcome to MSDN Blogs Sign in | Join | Help

.net ready !!!

        Maxime Lamure
          MCS France
How to customize the Web Service proxy generated by wsdl.exe (or add web references)

The goal of this article is to explain how we can share and use messages definitions in Web Services architecture.

When you design your application, you need to specify messages to allow communication between layers. Messages definitions will be shared and distributed in a separate assembly. But, when you generate your proxy with wsdl.exe (or add web reference), the definition of your messages is the same but with a different namespace defined in you shared assembly.

With the framework 2.0, there are two possibilities to resolve this problem:

I : Expand the Generated Code

The goal is to use the partial class notion. Here, you don’t modify but you expand the generated code with partial class.

On the shared assembly (messages definitions):

1. Messages objects in your shared assembly should implement interface

On the server side:

1. Create a Web Method which returns an object defined in your shared assembly

On the client side:

1. Create a partial class with the same name that Messages define in the generated proxy

2. Call the Web Service and get the result :-)

II: Modify the generated code

The second solution is to use the Schema importer service which allows you to customize the code generated by wsdl.exe. The following article explain what is Schema importer service and how to use it:

http://www.microsoft.com/belux/msdn/nl/community/columns/jdruyts/wsproxy.mspx

Posted: Friday, August 31, 2007 9:44 PM by Maxime LAMURE

Comments

wsdl exe said:

# July 21, 2008 5:15 PM

Steven Cheng's MSDN Notes said:

Sometimes we may need to customize the auto-generated webservice proxy(such as change some type definition

# March 8, 2009 11:54 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker