WSDL WebServiceDescriptionLanguage,web service描述语言.
它的作用是使用XML描述webservice,包括访问和使用WebService所必需的信息,定义该WebService的位置,功能,以及如何等描述信息.
一般来说,只要调用者可以获取WebService对应的WSDL,就可以了解他所提供的服务如何调用WebService.因为一份WSDL清晰的定义了3方面的内容:
1,what部分
用于定义WebService提供的操作或方法.也就是webservice能做些什么.在WSDL中由<types.../>,<message.../>,<portType.../>元素定义.
2.HOW部分
用于定义如何访问WebService,包括数据格式详情和访问webservice操作的必要协议.也就是定义了如何访问webservice.这个是<binding.../>.
3.where部分
用于定义webservice位于何处,如何使用特定协议决定的网络地址,如URL.该部分使用<service.../>元素定义.可以在WSDL文件的最后部分看到<service.../>元素.
<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2-hudson-411-. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2-hudson-411-. -->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://calculator.me.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://calculator.me.org/" name="CalculatorWSService">
<types>
<xsd:schema>
<xsd:import namespace="http://calculator.me.org/" schemaLocation="http://localhost:8080/CalculatorApp/CalculatorWSService?xsd=1" />
</xsd:schema>
</types>
<message name="add">
<part name="parameters" element="tns:add" />
</message>
<message name="addResponse">
<part name="parameters" element="tns:addResponse" />
</message>
<portType name="CalculatorWS">
<operation name="add">
<input wsam:Action="http://calculator.me.org/CalculatorWS/addRequest" message="tns:add" />
<output wsam:Action="http://calculator.me.org/CalculatorWS/addResponse" message="tns:addResponse" />
</operation>
</portType>
<binding name="CalculatorWSPortBinding" type="tns:CalculatorWS">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<operation name="add">
<soap:operation soapAction="" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="CalculatorWSService">
<port name="CalculatorWSPort" binding="tns:CalculatorWSPortBinding">
<soap:address location="http://localhost:8080/CalculatorApp/CalculatorWSService" />
</port>
</service>
</definitions>
因此可以看得出,WSDL文档分为两个部分:
第一部分:
定义了服务接口,他在WSDL中由<message../>元素和<portType.../>两个元素组成,
其中<message.../>元素定义了操作的交互方式.
而<portType.../>元素里则可以包含N个<operation.../>元素,每个<operation.../>元素代表一个允许远程调用的操作(就是方法).
第二部分:
定义了服务实现.由binding和service元素组成
binding定义了特定的通信协议,数据编码模型和底层通信协议.将WebService服务接口定义映射到具体实现.
而service元素就包含一系列的port元素,每个元素将把绑定机制,服务访问协议,端点地址结合在一起.
下图是实际用的一个WSDL文件.
源码:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s1="http://tempuri.org/AbstractTypes" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<s:element name="SendMMS">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="title" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="userNumbers" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="MMSContent" type="s:base64Binary"/>
<s:element minOccurs="1" maxOccurs="1" name="sendType" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="SendMMSResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="SendMMSResult" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="SendMMSEx">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="title" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="userNumbers" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="MMSContent" type="s:base64Binary"/>
<s:element minOccurs="0" maxOccurs="1" name="sendtime" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="sendType" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="SendMMSExResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="SendMMSExResult" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetMMSCount">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="sendType" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetMMSCountResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="GetMMSCountResult" type="s:long"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetStatusReport">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetStatusReportResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetStatusReportResult" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="string" nillable="true" type="s:string"/>
<s:element name="long" type="s:long"/>
</s:schema>
<s:schema targetNamespace="http://tempuri.org/AbstractTypes">
<s:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<s:complexType name="StringArray">
<s:complexContent mixed="false">
<s:restriction base="soapenc:Array">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="String" type="s:string"/>
</s:sequence>
</s:restriction>
</s:complexContent>
</s:complexType>
</s:schema>
</wsdl:types>
<wsdl:message name="SendMMSSoapIn">
<wsdl:part name="parameters" element="tns:SendMMS"/>
</wsdl:message>
<wsdl:message name="SendMMSSoapOut">
<wsdl:part name="parameters" element="tns:SendMMSResponse"/>
</wsdl:message>
<wsdl:message name="SendMMSExSoapIn">
<wsdl:part name="parameters" element="tns:SendMMSEx"/>
</wsdl:message>
<wsdl:message name="SendMMSExSoapOut">
<wsdl:part name="parameters" element="tns:SendMMSExResponse"/>
</wsdl:message>
<wsdl:message name="GetMMSCountSoapIn">
<wsdl:part name="parameters" element="tns:GetMMSCount"/>
</wsdl:message>
<wsdl:message name="GetMMSCountSoapOut">
<wsdl:part name="parameters" element="tns:GetMMSCountResponse"/>
</wsdl:message>
<wsdl:message name="GetStatusReportSoapIn">
<wsdl:part name="parameters" element="tns:GetStatusReport"/>
</wsdl:message>
<wsdl:message name="GetStatusReportSoapOut">
<wsdl:part name="parameters" element="tns:GetStatusReportResponse"/>
</wsdl:message>
<wsdl:message name="SendMMSHttpPostIn">
<wsdl:part name="userName" type="s:string"/>
<wsdl:part name="password" type="s:string"/>
<wsdl:part name="title" type="s:string"/>
<wsdl:part name="userNumbers" type="s:string"/>
<wsdl:part name="MMSContent" type="s1:StringArray"/>
<wsdl:part name="sendType" type="s:string"/>
</wsdl:message>
<wsdl:message name="SendMMSHttpPostOut">
<wsdl:part name="Body" element="tns:string"/>
</wsdl:message>
<wsdl:message name="SendMMSExHttpPostIn">
<wsdl:part name="userName" type="s:string"/>
<wsdl:part name="password" type="s:string"/>
<wsdl:part name="title" type="s:string"/>
<wsdl:part name="userNumbers" type="s:string"/>
<wsdl:part name="MMSContent" type="s1:StringArray"/>
<wsdl:part name="sendtime" type="s:string"/>
<wsdl:part name="sendType" type="s:string"/>
</wsdl:message>
<wsdl:message name="SendMMSExHttpPostOut">
<wsdl:part name="Body" element="tns:string"/>
</wsdl:message>
<wsdl:message name="GetMMSCountHttpPostIn">
<wsdl:part name="userName" type="s:string"/>
<wsdl:part name="password" type="s:string"/>
<wsdl:part name="sendType" type="s:string"/>
</wsdl:message>
<wsdl:message name="GetMMSCountHttpPostOut">
<wsdl:part name="Body" element="tns:long"/>
</wsdl:message>
<wsdl:message name="GetStatusReportHttpPostIn">
<wsdl:part name="userName" type="s:string"/>
<wsdl:part name="password" type="s:string"/>
</wsdl:message>
<wsdl:message name="GetStatusReportHttpPostOut">
<wsdl:part name="Body" element="tns:string"/>
</wsdl:message>
<wsdl:portType name="MMSSoap">
<wsdl:operation name="SendMMS">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">发送彩信,参数(用户名,密码,彩信标题,手机号码,彩信内容,彩信发送类型(1是网关发,2是卡发))</wsdl:documentation>
<wsdl:input message="tns:SendMMSSoapIn"/>
<wsdl:output message="tns:SendMMSSoapOut"/>
</wsdl:operation>
<wsdl:operation name="SendMMSEx">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">发送彩信,参数(用户名,密码,彩信标题,手机号码,彩信内容,定时时间(yyyyMMddHHmm)(年年年年月月日日时时分分)),彩信发送类型(1是网关发,2是卡发)</wsdl:documentation>
<wsdl:input message="tns:SendMMSExSoapIn"/>
<wsdl:output message="tns:SendMMSExSoapOut"/>
</wsdl:operation>
<wsdl:operation name="GetMMSCount">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">查询彩信剩余条数,参数(用户名,密码,彩信发送类型(1是网关发,2是卡发))</wsdl:documentation>
<wsdl:input message="tns:GetMMSCountSoapIn"/>
<wsdl:output message="tns:GetMMSCountSoapOut"/>
</wsdl:operation>
<wsdl:operation name="GetStatusReport">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">查询状态报告,参数(用户名,密码)</wsdl:documentation>
<wsdl:input message="tns:GetStatusReportSoapIn"/>
<wsdl:output message="tns:GetStatusReportSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="MMSHttpPost">
<wsdl:operation name="SendMMS">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">发送彩信,参数(用户名,密码,彩信标题,手机号码,彩信内容,彩信发送类型(1是网关发,2是卡发))</wsdl:documentation>
<wsdl:input message="tns:SendMMSHttpPostIn"/>
<wsdl:output message="tns:SendMMSHttpPostOut"/>
</wsdl:operation>
<wsdl:operation name="SendMMSEx">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">发送彩信,参数(用户名,密码,彩信标题,手机号码,彩信内容,定时时间(yyyyMMddHHmm)(年年年年月月日日时时分分)),彩信发送类型(1是网关发,2是卡发)</wsdl:documentation>
<wsdl:input message="tns:SendMMSExHttpPostIn"/>
<wsdl:output message="tns:SendMMSExHttpPostOut"/>
</wsdl:operation>
<wsdl:operation name="GetMMSCount">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">查询彩信剩余条数,参数(用户名,密码,彩信发送类型(1是网关发,2是卡发))</wsdl:documentation>
<wsdl:input message="tns:GetMMSCountHttpPostIn"/>
<wsdl:output message="tns:GetMMSCountHttpPostOut"/>
</wsdl:operation>
<wsdl:operation name="GetStatusReport">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">查询状态报告,参数(用户名,密码)</wsdl:documentation>
<wsdl:input message="tns:GetStatusReportHttpPostIn"/>
<wsdl:output message="tns:GetStatusReportHttpPostOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MMSSoap" type="tns:MMSSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SendMMS">
<soap:operation soapAction="http://tempuri.org/SendMMS" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="SendMMSEx">
<soap:operation soapAction="http://tempuri.org/SendMMSEx" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetMMSCount">
<soap:operation soapAction="http://tempuri.org/GetMMSCount" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetStatusReport">
<soap:operation soapAction="http://tempuri.org/GetStatusReport" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="MMSSoap12" type="tns:MMSSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SendMMS">
<soap12:operation soapAction="http://tempuri.org/SendMMS" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="SendMMSEx">
<soap12:operation soapAction="http://tempuri.org/SendMMSEx" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetMMSCount">
<soap12:operation soapAction="http://tempuri.org/GetMMSCount" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetStatusReport">
<soap12:operation soapAction="http://tempuri.org/GetStatusReport" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="MMSHttpPost" type="tns:MMSHttpPost">
<http:binding verb="POST"/>
<wsdl:operation name="SendMMS">
<http:operation location="/SendMMS"/>
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded"/>
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="SendMMSEx">
<http:operation location="/SendMMSEx"/>
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded"/>
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetMMSCount">
<http:operation location="/GetMMSCount"/>
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded"/>
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetStatusReport">
<http:operation location="/GetStatusReport"/>
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded"/>
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MMS">
<wsdl:port name="MMSSoap" binding="tns:MMSSoap">
<soap:address location="http://mmsplat.eucp.b2m.cn/MMSCenterInterface/MMS.asmx"/>
</wsdl:port>
<wsdl:port name="MMSSoap12" binding="tns:MMSSoap12">
<soap12:address location="http://mmsplat.eucp.b2m.cn/MMSCenterInterface/MMS.asmx"/>
</wsdl:port>
<wsdl:port name="MMSHttpPost" binding="tns:MMSHttpPost">
<http:address location="http://mmsplat.eucp.b2m.cn/MMSCenterInterface/MMS.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>