469,344 Members | 5,952 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,344 developers. It's quick & easy.

Namespaces in Vs.net 2005 web service

You know they say there is no such thing as a dumb question? This
might be the exception...I'm not sure. :)

In VS.NET 2003, if you create a web service it is namespaced like so:

namespace WebService156
{
...
}

If you do the same thing in VS.NET 2005, there is no namespace. I do
see something like this though:

[WebService(Namespace = "http://tempuri.org/")]

That isn't the equivalent is it? If not, where did the namespace go
in 2005? I know in Windows apps they have it hidden in a separate
file (because they can do that with partial classes). But I see
nothing like that in the web service.

If there is no namespace any more for web services, how did they get
around the issue of having an app reference two web services with the
same class (i.e. two web services with a "Customer" class)?

Apr 4 '07 #1
8 2661
"Doogie" <dn******@dtgnet.comwrote in message
news:11**********************@b75g2000hsg.googlegr oups.com...
You know they say there is no such thing as a dumb question? This
might be the exception...I'm not sure. :)

In VS.NET 2003, if you create a web service it is namespaced like so:

namespace WebService156
{
...
}

If you do the same thing in VS.NET 2005, there is no namespace. I do
see something like this though:

[WebService(Namespace = "http://tempuri.org/")]

That isn't the equivalent is it? If not, where did the namespace go
in 2005? I know in Windows apps they have it hidden in a separate
file (because they can do that with partial classes). But I see
nothing like that in the web service.

If there is no namespace any more for web services, how did they get
around the issue of having an app reference two web services with the
same class (i.e. two web services with a "Customer" class)?
These two things called namespaces are two different things.

The namespace WebService156 {} is a C# namespace. It creates a scope for the
names of types declared within it. For instance:

namespace WebService156
{
public class Foo {}
}

The full name of class Foo is WebService156.Foo.

The [WebService(Namespace = "http://tempuri.org/")] is an XML namespace.
When a WSDL file is generated from your web service, the targetNamespace
will be http://tempuri.org. This provides a scope for the names of types
declared within the WSDL file. For instance, if there were a <wsdl:message>
declaration for a message named "foo", then the qualified (full) name of foo
would be http://tempuri.org:foo.

BTW, the http://tempuri.org is only a placeholder. You should create your
own unique namespace scheme. You needn't use a URL for the namespace,
either. You might try something like:
urn:service.application.businessDomain.company.com .

John
Apr 4 '07 #2
Hi John,

I knew most of what you are saying. My question though is that in
Vs.net 2005 I cannot see a "namespace WebService156" anywhere. It's
as if the web service has no namespace. In vs.net 2003 it's there, in
vs.net 2005 it's not. So I'm curious as to where it might be (in a
file I'm not seeing, etc.)

Apr 4 '07 #3
"Doogie" <dn******@dtgnet.comwrote in message
news:11**********************@n76g2000hsh.googlegr oups.com...
Hi John,

I knew most of what you are saying. My question though is that in
Vs.net 2005 I cannot see a "namespace WebService156" anywhere. It's
as if the web service has no namespace. In vs.net 2003 it's there, in
vs.net 2005 it's not. So I'm curious as to where it might be (in a
file I'm not seeing, etc.)
If you don't see it, then it isn't there.

John
Apr 4 '07 #4
If you don't see it, then it isn't there.
Then my next question still remains. Does this mean that in VS.NET
2005 they don't have namespaces for a web service?

If there is no namespace any more for web services, how did they get
around the issue of having an app reference two web services with the
same class (i.e. two web services with a "Customer" class)?
Apr 5 '07 #5
"Doogie" <dn******@dtgnet.comwrote in message
news:11**********************@y66g2000hsf.googlegr oups.com...
>
>If you don't see it, then it isn't there.

Then my next question still remains. Does this mean that in VS.NET
2005 they don't have namespaces for a web service?

If there is no namespace any more for web services, how did they get
around the issue of having an app reference two web services with the
same class (i.e. two web services with a "Customer" class)?
It would only mean that VS.NET, when you create a new web service, doesn't
necessarily put it into a namespace. You could put it into a namespace if
you wanted.

Also, server namespaces have nothing at all to do with the client. The
client refers to proxy classes, not to the server classes. The namespace for
proxy classes is generated based on the name specified in the Add Web
Reference dialog.

John
Apr 5 '07 #6
Hi John, I am still confused. I understand the difference between
client/server namespaces. But take out the fact that we're talking
about a web service altogether here and let's just deal with the fact
that it is a .NET dll.

If I have a windows application in .NET and I reference two dlls and
they both happened to have a class name of Customer, without the
unique namespace attached to them, I could not reference them both and
use them or else I'd have a conflict because .NET would not know which
dll's methods I am referring to (now I understand that you can get
around that with aliases and such but that's not relevant to my
overall question).

If in VS 2005, namespaces are not a part of webservice component, then
if I have a web application that references two web services with a
class name of Customer, aren't I going to run into the same problem?
If not, why not? It seems strange to me that namespaces would just
not be there at all but could be added, because that seems to leave
open the strong possibility that someone is going to do something
wrong.

Am I way off base here or not understanding what you are getting at?

Apr 10 '07 #7
"Doogie" <dn******@dtgnet.comwrote in message
news:11**********************@e65g2000hsc.googlegr oups.com...
Hi John, I am still confused. I understand the difference between
client/server namespaces. But take out the fact that we're talking
about a web service altogether here and let's just deal with the fact
that it is a .NET dll.

If I have a windows application in .NET and I reference two dlls and
they both happened to have a class name of Customer, without the
unique namespace attached to them, I could not reference them both and
use them or else I'd have a conflict because .NET would not know which
dll's methods I am referring to (now I understand that you can get
around that with aliases and such but that's not relevant to my
overall question).

If in VS 2005, namespaces are not a part of webservice component, then
if I have a web application that references two web services with a
class name of Customer, aren't I going to run into the same problem?
If not, why not? It seems strange to me that namespaces would just
not be there at all but could be added, because that seems to leave
open the strong possibility that someone is going to do something
wrong.

Am I way off base here or not understanding what you are getting at?
You're not alone in being off-base in this way. In fact, Microsoft seems to
encourage it.

A large proportion of the confusion I hear about from web service newbies
stems from the fact that Microsoft has tried too hard to make Web Services
just magically work. This is good in one sense. On the other hand, it means
that people can get quite far in before understanding the ways in which web
services are different from other development models.

So, if you don't need to look "under the covers", it's perfectly fine to go
ahead and think of Web Services as just another kind of RPC; in fact, to
think of it just like a local procedure call. But occasionally, the
difference will show itself and bite you when you don't know to be looking!
In those situations, please keep the following in mind, even though it
contradicts the "magic" model:

******* The client and the server are totally unrelated *******
One implication of this is that the namespace of some class on the server it
totally irrelevant to any discussion about the client.

In fact, I think the best way to think about web services is to pretend you
don't know what platform the client and server are running on. Just assume
that you've got some Perl script or something running on a web server, and
that you've got, say, a VBScript file running on the client. The VBScript
client sends some "<XML/>" to the server and the server parses it with
regular expressions or something, then sends some "<XML/>" back.

Notice: there are no namespaces in the above example. There are no classes.
There are no methods. There was (implicitly) a WSDL somewhere, but it's all
XML itself!

It's all just XML traveling over the wire. This is not only the underlying
implementation, it is also the source of the limitations. No namespaces, no
classes, no constructors, no nothing except XML.
Now, as to your original question, Visual Studio.NET is clever enough to not
allow you to name two Web References the same thing, and to use the name of
the Web Reference in the namespace of the generated proxy classes. This will
cause them to be in different namespaces. So, even if you have two
references to the exact same service, you'll be ok because the Web
References have different names, hence different namespaces.

I hope that helps more than the lecture hurts! ;-)

John Saunders [MVP]
Apr 10 '07 #8
Now, as to your original question, Visual Studio.NET is clever enough to not
allow you to name two Web References the same thing, and to use the name of
the Web Reference in the namespace of the generated proxy classes. This will
cause them to be in different namespaces. So, even if you have two
references to the exact same service, you'll be ok because the Web
References have different names, hence different namespaces.

I hope that helps more than the lecture hurts! ;-)

Yes it did. That last statement made a lot of sense (and I probably
should have known that!) Thanks!

Apr 10 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by M Shafaat | last post: by
4 posts views Thread by mabster | last post: by
1 post views Thread by Jeremy Chapman | last post: by
reply views Thread by Igor | last post: by
2 posts views Thread by Amil | last post: by
16 posts views Thread by TT (Tom Tempelaere) | last post: by
5 posts views Thread by Simon | last post: by
6 posts views Thread by =?Utf-8?B?TUNN?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.