WSDL编写的五个步骤

WSDL编写的五个步骤

我们以 http://blog.csdn.net/hongbo781202/archive/2004/07/21/47135.aspx 中的案例来说明.

1)声明名称空间
必须在

 1<definitions> 元素中提供各种名称空间的声明.   
 2<definitions targetnamespace=" http://loans.org/wsdl/loan-approval " xmlns=" http://schemas.xmlsoap.org/wsdl/ " xmlns:lns=" http://loans.org/wsdl/loan-approval " xmlns:plnk=" http://schemas.xmlsoap.org/ws/2003/05/partner-link/ " xmlns:xsd=" http://www.w3.org/2001/XMLSchema ">   
 3三个必须做的外部名称空间声明是 WSDL、SOAP 和 XSD(XML 模式定义)   
 4xmlns=" http://schemas.xmlsoap.org/wsdl/ "是WSDL名称空间   
 5xmlns:soap=" http://schemas.xmlsoap.org/wsdl/soap/ " 是SOAP名称空间,这里因为是用做BPEL4WS,所以 
 6
 7不需要该名称空间   
 8xmlns:xsd=" http://www.w3.org/2001/XMLSchema "是XSD名称空间 
 9
102)编写服务   
11<definitions> 元素包含一个或多个 <porttype> 元素,实际上,每个元素都是您希望表示的一系列 
12
13operation。或者,您也可以将单个 portType 元素看作是将各种方法组成类的一个逻辑分组。我们称 
14
15portType为服务---这就是"WEB服务"这个名称的由来.   
16<porttype name="loanServicePT">
17<operation name="request">
18<input message="lns:creditInformationMessage"/>
19<output message="lns:approvalMessage"></output>
20<fault message="lns:errorMessage" name="unableToHandleRequest"></fault>
21</operation>
22</porttype>   
23可以看出,portType是operation的集合.一个operation是一个方法,那一个portType不就是一个类吗?一个 
24
25类,我们可以看作一个服务. 
26
27  
283)指定参数   
29operation指定了输入的参数和输出的参数,在 WSDL 术语中,所有参数称为“消息”。   
30<message name="creditInformationMessage">
31<part name="firstName" type="xsd:string"></part>
32<part name="name" type="xsd:string"></part>
33<part name="amount" type="xsd:integer"></part>
34</message>   
35一个消息可以有多个part元素,part元素指定名称和类型. 
36
374)与SOAP绑定   
38WSDL以一种抽象方式定义了操作和消息,而不考虑实现的细节。实际上,WSDL 的任务是定义或描述 Web 
39
40服务,然后提供一个对外部框架的引用来定义 WSDL 用户将如何实现这些服务。可以将这个框架当作 
41
42WSDL 抽象定义和它们的实现之间的“绑定(binding)”。一般是与SOAP绑定,当然,也不是必须的. 
43
445)指定实现   
45当您在 UDDI 注册中心发布 Web 服务时,会使用它.   
46最后两个步骤把WSDL与SOAP/UDDI结合起来了.</porttype></definitions></definitions></definitions>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus