WSDL是干什么的?
Web服务的定义语言.通过WSDL你可以告诉别人您能够提供什么服务,或者你能干什么. 首先,我提供一个WSDL的例子,这个例子源于Netbeans5.5的BPEL的贷款教程。
Operation
操作. 说白了, 就是方法. 例如getAllUsers(). 可以接受参数和返回值, 当然参数和返回值在Web服务中叫消息.
PortType
端口类型. 由一些操作构成. 这个名字很容易让人摸不着头脑. 它其实就是我们说的Web Service: 你可以这样理解, 它相当于Java 中的类, 一个类中有很多方法, 这里就是操作. 更像工具类. 你给我参数告诉我调用那个方法, 然后我作完了将返回值给你. WSDL文件的根元素是<definitions>, 这个元素下面是一些portType元素. 其实WSDL就是一些端口类型的集合,或者说一些服务的集合.
如果更加直白的说:
Java: method --> class --> package 给其他Java程序使用
Web: operation --> port type --> wsdl 给其他任何Web Service的客户端使用.
类比一下把.</definitions>
Web服务的定义语言.通过WSDL你可以告诉别人您能够提供什么服务,或者你能干什么. 首先,我提供一个WSDL的例子,这个例子源于Netbeans5.5的BPEL的贷款教程。
WSDL例子
- <?xml version="1.0" encoding="UTF-8"?>
- <definitions targetNamespace="http://j2ee.netbeans.org/wsdl/LoanRequestor"
- xmlns="http://schemas.xmlsoap.org/wsdl/"
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="LoanRequestor" xmlns:plink="http://schemas.xmlsoap.org/ws/2004/03/partner-link/" xmlns:tns="http://j2ee.netbeans.org/wsdl/LoanRequestor" xmlns:ns="http://xml.netbeans.org/schema/LoanRequestor">
- <types>
- <xsd:schema targetNamespace="http://j2ee.netbeans.org/wsdl/LoanRequestor">
- <xsd:import namespace="http://xml.netbeans.org/schema/LoanRequestor" schemaLocation="LoanRequestor.xsd"/>
- </xsd:schema>
- </types>
- <message name="LoanRequestorOperationRequest">
- <part name="requestLoanMessage" element="ns:pa"/>
- </message>
- <message name="LoanRequestorOperationReply">
- <part name="responsePart" element="ns:par"/>
- </message>
- <portType name="LoanRequestorPortType">
- <operation name="LoanRequestorOperation">
- <input name="input1" message="tns:LoanRequestorOperationRequest"/>
- <output name="output1" message="tns:LoanRequestorOperationReply"/>
- </operation>
- </portType>
- <binding name="LoanRequestorBinding" type="tns:LoanRequestorPortType">
- <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
- <operation name="LoanRequestorOperation">
- <soap:operation/>
- <input name="input1">
- <soap:body use="literal"/>
- </input>
- <output name="output1">
- <soap:body use="literal"/>
- </output>
- </operation>
- </binding>
- <service name="LoanRequestorService">
- <port name="LoanRequestorPort" binding="tns:LoanRequestorBinding">
- <soap:address location="http://localhost:18181/LoanRequestorService/LoanRequestorPort"/>
- </port>
- </service>
- <plink:partnerLinkType name="LoanRequestorPartner">
- <!-- partnerLinkType are automatically generated when a new portType is added. partnerLinkType are used by BPEL processes.
- In a BPEL process, a partner link represents the interaction between the BPEL process and a partner service.Each partner link is associated with a partner link type.
- A partner link type characterizes the conversational relationship between two services.The partner link type can have one or two roles.-->
- <plink:role name="LoanRequestorPortTypeRole" portType="tns:LoanRequestorPortType"/>
- </plink:partnerLinkType>
- </definitions>
Operation
操作. 说白了, 就是方法. 例如getAllUsers(). 可以接受参数和返回值, 当然参数和返回值在Web服务中叫消息.
PortType
端口类型. 由一些操作构成. 这个名字很容易让人摸不着头脑. 它其实就是我们说的Web Service: 你可以这样理解, 它相当于Java 中的类, 一个类中有很多方法, 这里就是操作. 更像工具类. 你给我参数告诉我调用那个方法, 然后我作完了将返回值给你. WSDL文件的根元素是<definitions>, 这个元素下面是一些portType元素. 其实WSDL就是一些端口类型的集合,或者说一些服务的集合.
如果更加直白的说:
Java: method --> class --> package 给其他Java程序使用
Web: operation --> port type --> wsdl 给其他任何Web Service的客户端使用.
类比一下把.</definitions>