XML 命名空间名称 URI 必须是可检索的吗? [英] Must an XML namespace name URI be retrievable?

查看:39
本文介绍了XML 命名空间名称 URI 必须是可检索的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 WSDL 上有以下标签:

<类型><xsd:schema attributeFormDefault="合格"elementFormDefault="合格"targetNamespace="http://xxxxx/ws/comments"xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"xmlns:s0="http://xxxxx/ws"xmlns:s1="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"xmlns:tns="http://xxxxx/ws"xmlns:tnsc="http://xxxxx/ws/comments"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:y="http://new.webservice.namespace">

此后,这些类型被限定为 s0,s1... 命名空间中的 a be.

问题是命名空间端点(="http://xxxxx/ws") 是否需要是一个有效的 url?
如果端点不再存在 - 是否意味着我们需要再次为 Web 服务重新生成存根代理?

注意:Web Service 本身的端点与命名空间的端点不同,并且仍然存在.

解决方案

命名空间是不需要可检索的 URI

<块引用>

来自@jww 问题:

问题是namespace end-point(="http://xxxxx/ws")必须是有效的网址?

不,XML 命名空间采用 URI 的词法形式,但根据 W3C 建议:XML 1.0 中的命名空间(第三版):

<块引用>

属性的规范化值必须是一个 URI 引用——标识命名空间的命名空间名称 - 或空字符串.这命名空间名称,为了达到其预期目的,应该具有具有独特性和持久性的特点.这不是目标它可以直接用于检索模式(如果有的话)存在).

如果 URI 不需要可检索,为什么要使用它们?

<块引用>

来自@jww 在评论中的跟进:

如果 http: 不可 可检索,它的目的是什么?他们不应该使用类似 null: 的东西来表示它的私有?不然怎么办像我这样的人知道什么时候它是私有的,什么时候被弃用或撤销?我想我要问的是,信号是什么机制?

许多人,包括我自己,确实建议将命名空间 URI 作为文档或作为管理 XSD 本身进行检索.但是,如上所示,它不是必需的.此外,当命名空间名称不是一个 URI:

<块引用>

为了符合本规范,处理器必须报告违规行为命名空间格式良好,除了它不是需要检查命名空间名称是否为 URI 引用 [RFC3986].

出于这个原因,您有时会在命名空间名称中看到使用非 URI,尤其是对于快速、一次性的示例.(但是,在这种情况下,最好使用 http://www.example.org/topic 以确保正确.)

使用 URI 是因为它们是一种方便的机制,用于表达具有内置权限规范的资源的唯一性 -- 域的所有者是负责的人用于使用域定义的命名空间.

命名空间作为端点

<块引用>

来自@jww 在评论中的跟进:

如果端点不再存在 - 是否意味着我们需要再次为网络服务重新生成存根代理?

不,您甚至不应将命名空间称为端点.命名空间名称 URI 的可检索性在任何时候都与您的 Web 服务的规范或操作无关.

I have the following tags on my WSDL:

<?xml version='1.0' encoding='UTF-8'?>
<definitions name="" targetNamespace="http://xxxxx/ws"
             xmlns="http://schemas.xmlsoap.org/wsdl/"
             xmlns:s0="http://xxxxx/ws"
             xmlns:s1="http://schemas.xmlsoap.org/wsdl/soap/">
  <types>
    <xsd:schema attributeFormDefault="qualified" 
                elementFormDefault="qualified"
                targetNamespace="http://xxxxx/ws/comments" 
                xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
                xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
                xmlns:s0="http://xxxxx/ws" 
                xmlns:s1="http://schemas.xmlsoap.org/wsdl/soap/" 
                xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
                xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
                xmlns:tns="http://xxxxx/ws" 
                xmlns:tnsc="http://xxxxx/ws/comments" 
                xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
                xmlns:y="http://new.webservice.namespace">

The types are thereafter qualified to a be in the s0,s1... namespaces.

The question is whether the namespace end-point(="http://xxxxx/ws") needs to be a valid url?
If the endpoint no longer exists - does it mean that we need to re-generate the stub proxy for the Web Service again?

Note: The endpoint of the Web Service itself is different from that of the namespaces and does still exist.

解决方案

Namespaces are URIs that need not be retrievable

From @jww question:

The question is whether the namespace end-point(="http://xxxxx/ws") needs to be a valid url?

No, an XML namespace takes the lexical form of a URI but does not have to be retrievable according to W3C Recommendation: Namespaces in XML 1.0 (Third Edition):

The attribute's normalized value MUST be either a URI reference — the namespace name identifying the namespace — or an empty string. The namespace name, to serve its intended purpose, SHOULD have the characteristics of uniqueness and persistence. It is not a goal that it be directly usable for retrieval of a schema (if any exists).

Why are URIs used if they need not be retrievable?

From @jww follow-up in comments:

What is the purpose of http: if its not retrievable? Shouldn't they use something like null: to signal its private? Otherwise, how do folks like me know when it's private, and when it's deprecated or withdrawn? I guess what I am asking is, what is the signalling mechanism?

Many, including myself, do indeed recommend that the namespace URI be retrievable as a document or as the governing XSD itself. However, as shown above it is not required. Further, a conformant, validating XML processor need not even report when a namespace name is not a URI:

To conform to this specification, a processor MUST report violations of namespace well-formedness, with the exception that it is not REQUIRED to check that namespace names are URI references [RFC3986].

For this reason, you'll sometimes see non-URI used in namespace names, especially for quick, throw-away examples. (However, it's probably better to use http://www.example.org/topic in such cases to be proper.)

URIs are used because they are a convenient mechanism for expressing uniqueness of a resource with a built-in authority specification -- the owner of the domain is the one responsible for namespaces defined using the domain.

Namespaces as endpoints

From @jww follow-up in comments:

If the endpoint no longer exists - does it mean that we need to re-generate the stub proxy for the webservice again?

No, and you should not even refer to the namespace as an endpoint. The retrievability of the namespace name URI has no bearing at anytime on the specification or operation of your Web Service.

这篇关于XML 命名空间名称 URI 必须是可检索的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆