开发者

I fail to see why web services need to be uniquely identified using namespaces

开发者 https://www.devze.com 2023-01-23 17:58 出处:网络
Each XML Web Service needs a unique namespace in order for client applications to distinguish it from other services on the Web.By

Each XML Web Service needs a unique namespace in order for client applications to distinguish it from other services on the Web. By default, ASP.Net Web Services use http://tempuri.org/ for this purpose. While this suitable for XML Web Services under development, published services should use a unique, 开发者_C百科 permanent namespace. Your XML Web Service should be identified by a namespace that you control. For example, you can use your company's Internet domain name as part of the namespace. Although many namespaces look like URLs, they need not point to actual resources on the Web.

I understand that XML namespaces help us uniquely identify vocabularies defined by XML Schemas. But I fail to see why web services also need to be uniquely identified using namespaces?!

Namely, for client to be able to communicate with a service, it needs to know the service’s address, binding and a contract and that’s it. So why would two different services using the same namespace cause any problems to client trying to use these two services?


I understand that Xml namespaces help us uniquely identify vocabularies defined by Xml Schemas. But I fail to see why web services also need to be uniquely identified using namespaces?!

For the same reason. To uniquely identify the service(s).

Services can have multiple endpoints. If two endpoints were running the same service, the namespace helps you recognize that they are implementations of the same service.

A unique service namespace can also be used to indicate the version of a particular service.


You're essentially correct: You get one namespace per service, so if you know the URL of the WSDL (or if you have a copy of it), the namespace is not particularly helpful. However, the namespace is permanent, whereas the WSDL is not. In services where you look up the location of the WSDL for services -- a UDDI server, for instance -- the namespace is a way to know that you're really talking about the service you're interested in.

As always, we use namespaces as an abstraction layer, so we're not dependent on the WSDL (or worse, endpoints') location to know which service we're talking about.

That said, the namespace really doesn't make much of a difference in most of our WS uses, since we use the physical location of the WSDL to figure out where the service is. You could use tempuri, but people would laugh, though the joke is really is on them.

0

精彩评论

暂无评论...
验证码 换一张
取 消