XML模式:WSD

网站建设 2023-01-28 20:49www.1681989.com免费网站

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:defitions defes set of related services --> <wsdl:defitions name="EndorsementSearch" targetNamespace="http://namespaces.snowboard-fo." xmlns:es="http://.snowboard-fo./EndorsementSearch.wsdl" xmlns:esxsd="http://schemas.snowboard-fo./EndorsementSearch.xsd" xmlns:soap="http://schemas.xmlsoap./wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap./wsdl/"> <!-- wsdl:types encapsulates schema defitions of munication types; here usg xsd --> <wsdl:types> <!-- all type declarations are a chunk of xsd --> <xsd:schema targetNamespace="http://namespaces.snowboard-fo." xmlns:xsd="http://.w3./1999/XMLSchema"> <!-- xsd defition: GetEndorsgBoarder [manufacturer strg, model strg] --> <xsd:element name="GetEndorsgBoarder"> <xsd:plexType> <xsd:sequence> <xsd:element name="manufacturer" type="strg"/> <xsd:element name="model" type="strg"/> </xsd:sequence> </xsd:plexType> </xsd:element> <!-- xsd defition: GetEndorsgBoarderResponse [... endorsgBoarder strg ...] --> <xsd:element name="GetEndorsgBoarderResponse"> <xsd:plexType> <xsd:all> <xsd:element name="endorsgBoarder" type="strg"/> </xsd:all> </xsd:plexType> </xsd:element> <!-- xsd defition: GetEndorsgBoarderFault [... errorMessage strg ...] --> <xsd:element name="GetEndorsgBoarderFault"> <xsd:plexType> <xsd:all> <xsd:element name="errorMessage" type="strg"/> </xsd:all> </xsd:plexType> </xsd:element> </xsd:schema> </wsdl:types> <!-- wsdl:message elements describe potential transactions --> <!-- request GetEndorsgBoarderRequest is of type GetEndorsgBoarder --> <wsdl:message name="GetEndorsgBoarderRequest"> <wsdl:part name="body" element="esxsd:GetEndorsgBoarder"/> </wsdl:message> <!-- response GetEndorsgBoarderResponse is of type GetEndorsgBoarderResponse --> <wsdl:message name="GetEndorsgBoarderResponse"> <wsdl:part name="body" element="esxsd:GetEndorsgBoarderResponse"/> </wsdl:message> <!-- wsdl:portType describes messages an operation --> <wsdl:portType name="GetEndorsgBoarderPortType"> <!-- the value of wsdl:operation eludes me --> <wsdl:operation name="GetEndorsgBoarder"> <wsdl:put message="es:GetEndorsgBoarderRequest"/> <wsdl:output message="es:GetEndorsgBoarderResponse"/> <wsdl:fault message="es:GetEndorsgBoarderFault"/> </wsdl:operation> </wsdl:portType> <!-- wsdl:bdg states a serialization protocol for this service --> <wsdl:bdg name="EndorsementSearchSoapBdg" type="es:GetEndorsgBoarderPortType"> <!-- leverage off soap:bdg document style ...(no wsdl:foo potg at the soap bdg) --> <soap:bdg style="document" transport="http://schemas.xmlsoap./soap/http"/> <!-- semi-opaque contaer of work transport details classed by soap:bdg above ... --> <wsdl:operation name="GetEndorsgBoarder"> <!-- aga bd to SOAP? ... --> <soap:operation soapAction="http://.snowboard-fo./ EndorsementSearch"/> <!-- further specify that the messages the wsdl:operation "GetEndorsgBoarder" use SOAP? ... --> <wsdl:put> <soap:body use="literal" namespace="http://schemas.snowboard-fo./EndorsementSearch.xsd"/> </wsdl:put> <wsdl:output> <soap:body use="literal" namespace="http://schemas.snowboard-fo./EndorsementSearch.xsd"/> </wsdl:output> <wsdl:fault> <soap:body use="literal" namespace="http://schemas.snowboard-fo./EndorsementSearch.xsd"/> </wsdl:fault> </wsdl:operation> </wsdl:bdg> <!-- wsdl:service names a new service "EndorsementSearchService" --> <wsdl:service name="EndorsementSearchService"> <wsdl:documentation>snowboardg-fo. Endorsement Service</ wsdl:documentation> <!-- connect it to the bdg "EndorsementSearchSoapBdg" above --> <wsdl:port name="GetEndorsgBoarderPort" bdg="es:EndorsementSearchSoapBdg"> <!-- give the bdg an work address --> <soap:address location="http://.snowboard-fo./EndorsementSearch"/> </wsdl:port> </wsdl:service> </wsdl:defitions>

WSDL 声明了消息类型、默认数据类型和内容以及交换的数据结构。
访问服务器上 SOAP 结构需要使用的一切信息都可以在这个 WSDL 中找到。大多数语言和环境都提供一种阅读和解析 WSDL 的机制,以确定可用的函数和数据交换。
WSDL 不仅定义了用于交换信息的 SOAP 接口,通过适当的 WSDL 生成程序,还可用于创建发送请求、生成并格式化响应所需要的代码。
WSDL 和 SOAP 组成了一个强大的远程过程调用系统。
上一篇:XML模式:RDF 下一篇:什么是XML?

Copyright © 2016-2025 www.1681989.com 推火网 版权所有 Power by