XML模式:WSD
所属分类:
网页制作 / XML/XSLT
阅读数:
618
收藏 0赞 0分享
Web 服务描述语言(Web Services Description Language,WSDL)提供了一种描述 Web 服务(大多使用 SOAP)的简单方法。WSDL 允许您描述利用 SOAP 标准所提供的服务和接口。
比方说,可以创建描述某台服务器上提供的服务的 WSDL 文件,然后把该文件分发给需要这些服务的 Web 服务消费者。通过阅读和解析 WSDL 文件,消费者能够了解到使用这些 Web 服务需要知道的所有信息,包括可以交换的数据类型、参数以及返回的各种错误和其他信息。
再次使用来自 W3C 的例子,可以看到不同远程函数的声明和交换的数据都是通过结构的 XML 定义处理的,如清单 3 所示。
清单 3. 不同远程函数和交换数据的 XML 定义
<?xml version="1.0"?>
<!-- root element wsdl:definitions defines set of related services -->
<wsdl:definitions name="EndorsementSearch"
targetNamespace="http://namespaces.snowboard-info.com"
xmlns:es="http://www.snowboard-info.com/EndorsementSearch.wsdl"
xmlns:esxsd="http://schemas.snowboard-info.com/EndorsementSearch.xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<!-- wsdl:types encapsulates schema definitions of communication types;
here using xsd -->
<wsdl:types>
<!-- all type declarations are in a chunk of xsd -->
<xsd:schema targetNamespace="http://namespaces.snowboard-info.com"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<!-- xsd definition: GetEndorsingBoarder [manufacturer string,
model string] -->
<xsd:element name="GetEndorsingBoarder">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="manufacturer" type="string"/>
<xsd:element name="model" type="string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<!-- xsd definition: GetEndorsingBoarderResponse
[... endorsingBoarder string ...] -->
<xsd:element name="GetEndorsingBoarderResponse">
<xsd:complexType>
<xsd:all>
<xsd:element name="endorsingBoarder" type="string"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
<!-- xsd definition: GetEndorsingBoarderFault
[... errorMessage string ...] -->
<xsd:element name="GetEndorsingBoarderFault">
<xsd:complexType>
<xsd:all>
<xsd:element name="errorMessage" type="string"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<!-- wsdl:message elements describe potential transactions -->
<!-- request GetEndorsingBoarderRequest is of type GetEndorsingBoarder -->
<wsdl:message name="GetEndorsingBoarderRequest">
<wsdl:part name="body" element="esxsd:GetEndorsingBoarder"/>
</wsdl:message>
<!-- response GetEndorsingBoarderResponse is of type
GetEndorsingBoarderResponse -->
<wsdl:message name="GetEndorsingBoarderResponse">
<wsdl:part name="body" element="esxsd:GetEndorsingBoarderResponse"/>
</wsdl:message>
<!-- wsdl:portType describes messages in an operation -->
<wsdl:portType name="GetEndorsingBoarderPortType">
<!-- the value of wsdl:operation eludes me -->
<wsdl:operation name="GetEndorsingBoarder">
<wsdl:input message="es:GetEndorsingBoarderRequest"/>
<wsdl:output message="es:GetEndorsingBoarderResponse"/>
<wsdl:fault message="es:GetEndorsingBoarderFault"/>
</wsdl:operation>
</wsdl:portType>
<!-- wsdl:binding states a serialization protocol for this service -->
<wsdl:binding name="EndorsementSearchSoapBinding"
type="es:GetEndorsingBoarderPortType">
<!-- leverage off soap:binding document style ...(no wsdl:foo pointing at
the soap binding) -->
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<!-- semi-opaque container of network transport details classed by
soap:binding above ... -->
<wsdl:operation name="GetEndorsingBoarder">
<!-- again bind to SOAP? ... -->
<soap:operation soapAction="http://www.snowboard-info.com/
EndorsementSearch"/>
<!-- further specify that the messages in the wsdl:operation
"GetEndorsingBoarder" use SOAP? ... -->
<wsdl:input>
<soap:body use="literal"
namespace="http://schemas.snowboard-info.com/EndorsementSearch.xsd"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"
namespace="http://schemas.snowboard-info.com/EndorsementSearch.xsd"/>
</wsdl:output>
<wsdl:fault>
<soap:body use="literal"
namespace="http://schemas.snowboard-info.com/EndorsementSearch.xsd"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<!-- wsdl:service names a new service "EndorsementSearchService" -->
<wsdl:service name="EndorsementSearchService">
<wsdl:documentation>snowboarding-info.com Endorsement Service</
wsdl:documentation>
<!-- connect it to the binding "EndorsementSearchSoapBinding" above -->
<wsdl:port name="GetEndorsingBoarderPort"
binding="es:EndorsementSearchSoapBinding">
<!-- give the binding an network address -->
<soap:address location="http://www.snowboard-info.com/EndorsementSearch"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
WSDL 声明了消息类型、默认数据类型和内容以及交换的数据结构。
访问服务器上 SOAP 结构需要使用的一切信息都可以在这个 WSDL 中找到。大多数语言和环境都提供一种阅读和解析 WSDL 的机制,以确定可用的函数和数据交换。
WSDL 不仅定义了用于交换信息的 SOAP 接口,通过适当的 WSDL 生成程序,还可用于创建发送请求、生成并格式化响应所需要的代码。
WSDL 和 SOAP 组成了一个强大的远程过程调用系统。
在XML模式中扩展枚举列表
在列表中添加新值是一种常见而且必要的需求。模式设计者通常希望在系统架构中构建一种添加附加值的方法,并且该附加值在设计阶段是未知的。模式设计者如何创建一个可扩展、易于实现的枚举值列表?本文将介绍几种实现这一目标的方法。
模式设计者和实现人员需要一种扩
收藏 0赞 0分享
XML入门教程:XML名称空间-XML/XSLT
XML名称空间表示XML名称的使用范围,因为XML可自定义元素标签,所以有不同XML应用间XML名称重名的机会是很大的。如果没有一种方法来区分不应用的名称,就会造成混乱。XML名称空间就是为了解决这个问题而设计的。通过XML名称空间,我们可以区分
收藏 0赞 0分享
XML入门教程:属性声明-XML/XSLT
一个有效的XML文档,必须对元素的属性进行声明。使用ATTLIST声明来完成,一个ATTLIST可以为一个元素类型声明多个属性。
一个有效的XML文档,必须对元素的属性进行声明。使用ATTLIST声明来完成,一个ATTLIST可以为一个元素类型
收藏 0赞 0分享
XML入门教程:实体-XML/XSLT
由于数据不是XML格式,所以使用NDATA声明指定数据类型。avi是在NOTATION中定义的MIME媒体类型。在XML中嵌入未析实体很复杂且不规范,尽量不要使用。
实体
用ENTITY声明定义实体。如:
收藏 0赞 0分享
XML入门教程:元素声明-XML/XSLT
有效文档中使用的每个元素都必须在文档的DTD中用元素声明进行声明。element_name可是任何合法的XML名称,content_model(内容模型)指定元素可以或必须包含的子元素以及子元素的顺序。下面具体介绍内容模型的内容。
上节文档类型
收藏 0赞 0分享
XML入门教程:文档类型声明-XML/XSLT
要使用DTD进行有效性检验,就要使用文档类型定义声明指定DTD。文档类型声明位于XML声明之后,根元素之前。如果dtd文档位于本机,可用路径名直接指出dtd文档的位置。
由于XML可自定义标签,所以每个人定义的标签集都会不同,如
收藏 0赞 0分享
XML入门教程:XML语法-XML/XSLT
接着在浏览器中打开index.xml文档,则可显示“Hello World”。上面两个文档都是合法的XML文件,具体的语法规则下面会详细介绍,上例可先给大家一个感性的认识。合法的XML文档可有种意思,一个是良构文档(well-format),即符合XML规则书写的文档
收藏 0赞 0分享
xml入门教程:XML是什么-XML/XSLT
XML(eXtensible Markup Language,可扩展标记语言)是SGML的一个子集,但比SGML简单,用以创建可相互转换的结构化文本文档和数据文档。下面说明一下与XML相关的一些概念。
XML(eXtensible Markup L
收藏 0赞 0分享
WAP教程(11):WAP论坛和开放移动联盟与论坛-XML/XSLT
WAP 论坛,WAP开放移动联盟,WAP论坛.
WAP 论坛 (WAP Forum)
无线应用协议 (WAP) 论坛为数字移动电话和其他无线终端开发了事实上的全球标准。 WAP 论坛发布了开放的全球无线协议规范,此规范基于已有的因特网标准
收藏 0赞 0分享
查看更多