Click here to Skip to main content
13,256,123 members (41,913 online)
Click here to Skip to main content
Add your own
alternative version


19 bookmarked
Posted 25 Jun 2003

Modifying the Web References for Visual Studio .NET

, 1 Jul 2003
Rate this:
Please Sign up or sign in to vote.
Modifying the Web References for Visual Studio .NET.


In this article, we will discuss a common problem with Visual Studio .NET Web Service development. Suppose you are building a project using Visual Studio .NET, and you decide that you want to start consuming Web Services. The first step that you will generally take is, you will add a Web reference to that particular Web Service which is residing on a certain server, say the localhost server for this example. Visual Studio .NET will then add a new item under Solution Explorer called Web References, and it will create a folder node underneath it called localhost. The localhost node will contain the WSDL and the proxy class files for the Web Service that was referenced. Later on, you find that you need to add another Web reference to a Web Service that is residing on the same server as the first Web Service. Visual Studio .NET will then create another folder node, and this time it will name this node localhost1. The localhost1 node is identical to the localhost node, except that it references the second Web Service that was added to the Visual Studio .NET project. Now, if you were to add a few more Web Services that were all located on that localhost server, you would end up with a couple of folder nodes with the name "localhost" appended with numeral values, like "localhost1", "localhost2", "localhost3", and so on.

When Add Web reference adds a new Web Service, it places the proxy in a separate namespace. So, when you create instances of your proxy classes, your code may look something similar to this...

Dim srv1 As New localhost.ClassNameA()
Dim srv2 As New localhost1.ClassNameB()
Dim srv3 As New localhost2.ClassNameC()

As you can see, the above code doesn't look very neat with the different namespaces. Instead, you may want your proxy classes to be all under one namespace like the following...

Dim srv1 As New localhost.ClassNameA()
Dim srv2 As New localhost.ClassNameB()
Dim srv3 As New localhost.ClassNameC()

To achieve this, you need to modify a few things. Each folder node under the Solution Explorer/Web References section has a file node called This file contains an XML pointer to the WSDL file. When you expand the file node, you will see a file called Reference.vb sitting right underneath it (if you are using C#, you will see a file called Reference.cs). The Reference.vb file is the proxy class file for the Web Service that the node is referencing to. You can manually edit the name of the namespace of the proxy class to a desired name. For example, if the proxy class is under a namespace called localhost2, you can change the name of the namespace to localhost. Alternatively, the file node has a property called "Custom Tool Namespace". Setting a value to this property will automatically update the namespace of the proxy class. Another thing that you may want to do is group all the proxy class files under one common folder node. To do this, you will need to rename each of the files to a unique name with .map extension. This will automatically rename the name of the proxy class file. Then drag the renamed .map file node to one particular folder node under the Solution Explorer/Web References section. Finally, delete the folder node where the renamed .map file previously existed in, because it is no more required. I have created a video demonstrating how this can be done, which can be downloaded from download area.

Related Article


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Saumendra Poddar
Web Developer
Canada Canada
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralResets on updating the webreferences Pin
Paulo19-Aug-03 15:43
memberPaulo19-Aug-03 15:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171114.1 | Last Updated 2 Jul 2003
Article Copyright 2003 by Saumendra Poddar
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid