1

One of the web services I inherited in my current job contains a WSDL schema with the following namespace definition:

<xs:schema 
  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
  xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
  xmlns:mns="http://my.example.com/sumproj/msgs.xsd" 
  xmlns:tns="http://my.example.com/sumproj" 
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
  targetNamespace="http://my.example.com/sumproj/msgs.xsd" 
  elementFormDefault="qualified">

All of the external URLs listed above can be accessed through a web browser, but the internal ones (my.example.com domain) only produce a "Not Found" error:

Not Found

The requested URL /sumproj/msgs.xsd was not found on this server.

Since the person to ask about why certain things are implemented the way they are has left, I am wondering whether this is a bug or a feature:

  • Has the authoring developer intended to place the namespace XSD on that http://my.example.com server and simply didn't get to implementing it?

  • Or is it some type of security feature in which the URL is only accessible by the web service through a config XML, effectively defining this URL as virtual when it actually access localhost or similar?

If the latter, how does this work and where I can learn more about it?

(Note: example.com above is only used for illustration, I can't really disclose my employer's internal URL)

4

2 回答 2

2

XML 命名空间是 URI(统一资源标识符),旨在区分作者对元素“book”的含义,例如,与可能出现在任何其他 XML 文档中的元素“book”的含义。

如果我为我的模式选择一个命名空间,我需要绝对确定它不会与其他人可能选择的命名空间相同。为了确保不会发生这种冲突,作者通常使他们的命名空间以他们拥有的域名开头。这使它们看起来像 URL,但实际上并没有要求让命名空间 URI 实际上指向一个有用的资源,或者实际上是任何东西。有用的组织,如 w3c,实际上在这些 URI 上发布资源,这就是上述文档中的外部命名空间起作用的原因。

于 2013-07-22T13:31:59.663 回答
2

Has the authoring developer intended to place the namespace XSD on that http://my.example.com server and simply didn't get to implementing it?

That's possible, but not certain; without reading the developer's mind no firm answer is possible. A rational developer might do it either way -- even if many people including me would say it's better practice and more rational to put namespace documentation (possibly in the form of a schema document, possibly in the form of a RDDL document, possibly in another form) at the namespace URI.

Or is it some type of security feature in which the URL is only accessible by the web service through a config XML, effectively defining this URL as virtual when it actually access localhost or similar?

Not impossible, but this is not a design technique that seems to be widely documented. (At least, there's at least one XML geek who's never heard it suggested.) So I would guess the answer is: probably not the original author's intent.

Can you point me to an authoritative source where I can read about this?

The authoritative source for XML namespaces are the documents "Namespaces in XML 1.0 (Third Edition)" and "Namespaces in XML 1.1 (Second Edition)", edited by Tim Bray et al. and published by the World Wide Web Consortium in 2009 and 2006, respectively.

It's difficult to prove a negative concisely, but examination of the spec should make clear that it imposes no requirement that URIs used as namespace names should be dereferenceable. Section 2.1 says "An XML namespace is identified by a URI reference [RFC3986]" but nothing in the spec requires that namespace names be dereferenced. Section 2.3 defines the process of namespace-name matching as a test for string identity and points out that this means that equivalent forms of the same URI (e.g. http://www.example.org/wine and http://www.Example.org/wine) do not count as equal for purpose of namespace-name matching. This would make no sense at all if namespace processors were required to dereference namespace names.

The W3C Technical Architecture Group (TAG) discusses this complex of questions from a higher-level point of view in it document Architecture of the World Wide Web, Volume One. See in particular

  • section 3.5 (which enunciates the principle that "Reference does not imply dereference": "An application developer or specification author SHOULD NOT require networked retrieval of representations each time they are referenced."
  • section 4.5.3 on XML namespaces
  • section 4.5.4 on namespace documents (which the TAG recommends)

See also this related question (and my answer to it).

if a name space URL does point to a resource, does this necessarily imply that the WSDL schema must consult with it at runtime?

No. WSDL can impose extra rules on the use of namespace names in WSDL documents, but the document fragment you quote is from an XSD schema document. The XSD spec does not require that namespace names be dereferenced (although it does suggest it as one possible strategy for locating XSD schema documents for use in a validation episode).

If the answer is no, can it consult with it at runtime? or is it only for human reading?

It is not forbidden for processors to dereference namespace name, but some authorities discourage it. When widely deployed software dereferences namespace names every time it runs, or every time it reads an XML document, the result can be excessive and unnecessary network traffic. W3C has been suffering under such unnecessary traffic for some years and now serves all schemas at artificially slow rates in order to persuade users to complain to their software vendors. (See Ted Guild's blog post of 2008 for details.)

于 2013-07-23T00:56:04.407 回答