为了更好地理解WSDL的语句含义,这里把一个WSDL文件内容帖出来做一个详细分析以能够让人更加清晰地认识和理解WSDL。
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="
http://www.w3.org/2001/XMLSchema" xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/" xmlns:tns="
http://ws.aspire.com/" xmlns:soap="
http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="
http://schemas.xmlsoap.org/soap/http" name="HelloWSImplService" targetNamespace="
http://ws.aspire.com/">
<wsdl:types>
<xs:schema xmlns:xs="
http://www.w3.org/2001/XMLSchema" xmlns:tns="
http://ws.aspire.com/" elementFormDefault="unqualified" targetNamespace="
http://ws.aspire.com/" version="1.0">
<!--
下边这个第一部分说明webservice的请求和响应定义,即之前文中提过的SOAP请求和响应消息定义,对应颜色一致的即为对应结构。
//用于请求
<sayHello>
<arg0></arg0>
</sayHello>
//用于响应
<sayHelloResponse>
<return></return>
</sayHelloResponse>
-->
<xs:element name="
sayHello" type="tns:sayHello"/>
<xs:element name="
sayHelloResponse" type="tns:sayHelloResponse"/>
<xs:complexType name="sayHello">
<xs:sequence>
<xs:element minOccurs="0" name="
arg0" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sayHelloResponse">
<xs:sequence>
<xs:element minOccurs="0" name="
return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<!--
message:用来定义消息的结构
part:指定types中定义的标签片段
-->
<
wsdl:message name="sayHelloResponse">
<
wsdl:part element="tns:sayHelloResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="sayHello">
<wsdl:part element="tns:sayHello" name="parameters">
</wsdl:part>
</wsdl:message>
<!--
portType:用来定义服务器端的SEI(就是webservice服务器端用来处理请求的接口)
operation:用来指定SEI中的方法
input:指定客户端传过来的数据,会引用上面指定的message
output:指定服务器返回给客户端的数据,会引用上面定义的message
-->
<
wsdl:portType name="HelloWS">
<
wsdl:operation name="sayHello">
<
wsdl:input message="tns:sayHello" name="sayHello">
</
wsdl:input>
<
wsdl:output message="tns:sayHelloResponse" name="sayHelloResponse">
</
wsdl:output>
</
wsdl:operation>
</
wsdl:portType>
<!--
binding:用于定义SEI实现类
type:引用上边定义的type标签
<soap:binding style="document" /> :绑定数据是一个xml
operation:用来定义方法的实现
<soap:operation style="document"/> :传输的document(xml)
input:指定客户端传过来的数据,会引用上面指定的message
<soap:body use="literal"/> :传输的是文本数据
output:指定服务器返回给客户端的数据,会引用上面定义的message
<soap:body use="literal"/> :传输的是文本数据
-->
<
wsdl:binding name="HelloWSImplServiceSoapBinding"
type="tns:HelloWS">
<
soap:binding style="document" transport="
http://schemas.xmlsoap.org/soap/http"/>
<
wsdl:operation name="sayHello">
<
soap:operation soapAction="" style="document"/>
<
wsdl:input name="sayHello">
<
soap:body use="literal"/>
</
wsdl:input>
<
wsdl:output name="sayHelloResponse">
<
soap:body use="literal"/>
</
wsdl:output>
</
wsdl:operation>
</
wsdl:binding>
<!--
service:一个webservice的容器
name属性:用来指定客户端的容器类
Port:指定一个服务端处理请求的一个入口(SEI的实现)
binding:指定上边定义的binding标签
address:当前webservice的请求地址
-->
<
wsdl:service
name="HelloWSImplService">
<
wsdl:port
binding="tns:HelloWSImplServiceSoapBinding" name="HelloWSImplPort">
<
soap:address location="
http://localhost:8088/day01_ws/hellows"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>