第五十二章 生成的 WSDL 的详细信息 - 命名空间声明
命名空间声明
在详细检查 WSDL
的其余部分之前,查看 WSDL
其余部分使用的命名空间声明很有用。 <definitions>
元素包含WSDL
中使用的每个命名空间的一个命名空间声明。对于本主题前面显示的示例 Web
服务,这些声明如下:
<definitions xmlns="https://schemas.xmlsoap.org/wsdl/"
xmlns:SOAP-ENC="https://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="https://schemas.xmlsoap.org/wsdl/mime/"
xmlns:s="https://www.w3.org/2001/XMLSchema"
xmlns:s0="https://www.mynamespace.org"
xmlns:soap="https://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="https://schemas.xmlsoap.org/wsdl/"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
targetNamespace="https://www.mynamespace.org">
以下参数影响命名空间声明:
-
Web
服务中的NAMESPACE
参数。
此参数用于targetNamespace
属性,指示Web服务的目标命名空间。
如果未指定 NAMESPACE
参数,则 targetNamespace
为“https://tempuri.org
”
-
We
服务中的SOAPVERSION
参数。
这会影响自动包含的 SOAP
命名空间。
默认情况下,SOAPVERSION
为1.1
。
对于 SOAPVERSION
等于 1.2
的情况,WSDL
将包含以下内容:
<definitions ...
xmlns:soap12="https://schemas.xmlsoap.org/wsdl/soap12/"
...
对于等于“”的 SOAPVERSION
,WSDL
将包含以下内容:
<definitions
xmlns:soap="https://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap12="https://schemas.xmlsoap.org/wsdl/soap12/"
...
-
Web
服务中以及Web
服务所使用的任何支持XML
的类中的其他命名空间关键字和参数。
这些项目将在以下章节中讨论。
这些命名空间是根据需要声明的,以与 WSDL
的其余部分保持一致。
此外,其他命名空间(例如 https://schemas.xmlsoap.org/wsdl/soap/
)也会根据需要自动包含在内。
命名空间前缀都是自动选择的,无法自定义。