Web References & WSE 2 in Visual Studio

Maybe this is a well known, or even documented issue, but I’m jotting it down so I don’t forget it -

If you have a reference set to Microsoft Web Service Enhancments (WSE 2.0), and you add a web reference to a project in VS.NET, by default the proxy class will inherit from Microsoft.Web.Services2.WebServicesClientProtocol. This is so that you get the WSE 2.0 Enhancements.

Media_httpblogdavebou_pajfd

However, by default, the URL Behavior is set to “static”, which means the URL is hardcoded in the proxy…

Media_httpblogdavebou_emikc

But this is not too handy for moving things between dev / test / production. But VS lets you change the URL Behavior to “Dynamic”

Media_httpblogdavebou_tezui

It re-creates the proxy class when you do this. Only now, it inherits from System.Web.Services.Protocols.SoapHttpClientProtocol, which is not what you wanted. (Because you’re doing something with SOAP Attachements or other WSE niceties).

Media_httpblogdavebou_mgnow

Anyhow, you can solve this problem by right-clicking on the web reference in the Solution Explorer, and selecting “Update Web Reference”, which will respect both the WSE2 and the URL Behavior. Just remember to do this after you select dynamic, otherwise you code blows up all over the place.

Media_httpblogdavebou_ofimf
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s