NameSpaces for Web Services

Namespace assignment for Web Service proxies is not the most intuitive thing in the world since it's usually auto-generated. By default, the namespace is the name of the project dot name of the WebService.

Here's a little tip that I use when I can't get it right the first time: Go into the client project's Web References directory, the directory for your Web Service and open the generated proxy file (WebService.cs). At the very top you'll find the fully qualified namespace for the Web Service proxy which is what you need in order to access the Web Service methods from your code. You can either type the fully qualified namespace path plus the class name each time you create a reference to the object or you can add it to your namespace references at the top of the class.

Another hint – try to name your namespaces consistently. Avoid using the same name for a namespace and a class. When you create a project, create all client code in the scope of that namespace so other modules can reference each other by their specific single namespace name.

Comments

$ury@ said…
Thats nice, but do we really need to bother about a namespace for a web service proxy? I personally think it should be placed in the AppCode folder, there will be no issues in accessing it anywhere.

Popular posts from this blog

ASP.NET Compillation Error BC31007 - Solution

Test & Debug WCF service using WCFTestClient.exe

Microsoft Surface in brief