首先上一下 sayHello.wsdl的源码
<?xml version="1.0" encoding="UTF-8"?><!-- Published by JAX-WS RI (http://jax-ws.java.net).
RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. --><!-- Generated by JAX-WS RI (http://jax-ws.java.net).
RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. -->
<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://ws/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://ws/"
name="HelloWSImplService">
<types>
<xsd:schema>
<xsd:import namespace="http://ws/"
schemaLocation="http://192.168.199.215:8989/ws_test/zq?xsd=1"></xsd:import>
</xsd:schema>
</types>
<message name="sayHello">
<part name="parameters" element="tns:sayHello"></part>
</message>
<message name="sayHelloResponse">
<part name="parameters" element="tns:sayHelloResponse"></part>
</message>
<portType name="HelloWSImpl">
<operation name="sayHello">
<input wsam:Action="http://ws/HelloWSImpl/sayHelloRequest"
message="tns:sayHello"></input>
<output wsam:Action="http://ws/HelloWSImpl/sayHelloResponse"
message="tns:sayHelloResponse"></output>
</operation>
</portType>
<binding name="HelloWSImplPortBinding" type="tns:HelloWSImpl">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"></soap:binding>
<operation name="sayHello">
<soap:operation soapAction=""></soap:operation>
<input>
<soap:body use="literal"></soap:body>
</input>
<output>
<soap:body use="literal"></soap:body>
</output>
</operation>
</binding>
<service name="HelloWSImplService">
<port name="HelloWSImplPort" binding="tns:HelloWSImplPortBinding">
<soap:address location="http://192.168.199.215:8989/ws_test/zq"></soap:address>
</port>
</service>
</definitions>
(1) types
<types>
<xsd:schema>
<xsd:import namespace="http://ws/"
schemaLocation="http://192.168.199.215:8989/ws_test/zq?xsd=1"></xsd:import>
</xsd:schema>
</types>
在浏览器中输入:http://192.168.199.215:8989/ws_test/zq?xsd=1
可以看到其文件约束
<?xml version="1.0" encoding="UTF-8"?><!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e. --><xs:schema xmlns:tns="http://ws/" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://ws/"> | |
<xs:element name="sayHello" type="tns:sayHello"></xs:element> | |
<xs:element name="sayHelloResponse" type="tns:sayHelloResponse"></xs:element> | |
<xs:complexType name="sayHello"> | |
<xs:sequence> | |
<xs:element name="arg0" type="xs:string" minOccurs="0"></xs:element> | |
</xs:sequence> | |
</xs:complexType> | |
<xs:complexType name="sayHelloResponse"> | |
<xs:sequence> | |
<xs:element name="return" type="xs:string" minOccurs="0"></xs:element> | |
</xs:sequence> | |
</xs:complexType> | |
</xs:schema> |
这个主要是约束了请求和响应的xml格式:
这个用于约束请求
<sayHello>
<arg0>string</arg0>
</sayHello>
这个用于约束响应
<sayHelloResponse>
<arg0>string</arg0>
</sayHelloResponse>
(2)message
<message name="sayHello">
<part name="parameters" element="tns:sayHello"></part>
</message>
<message name="sayHelloResponse">
<part name="parameters" element="tns:sayHelloResponse"></part>
</message>
message:用来定义消息的结构:一共就两个消息,一个请求消息,一个响应消息;
part:用来定义指定引用types中定义的标签片段;
(3)portType
<portType name="HelloWSImpl">
<operation name="sayHello">
<input wsam:Action="http://ws/HelloWSImpl/sayHelloRequest"
message="tns:sayHello"></input>
<output wsam:Action="http://ws/HelloWSImpl/sayHelloResponse"
message="tns:sayHelloResponse"></output>
</operation>
</portType>
portType 用来定义服务器的SEI;
operation :用来定义SEI中处理请求的方法;
input:指定客户端应用传过来的数据,会引用上面的message;
output:是指服务器端返回给客户端的数据,会引用上面的message;
(4)binding
<binding name="HelloWSImplPortBinding" type="tns:HelloWSImpl">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"></soap:binding>
<operation name="sayHello">
<soap:operation soapAction=""></soap:operation>
<input>
<soap:body use="literal"></soap:body>
</input>
<output>
<soap:body use="literal"></soap:body>
</output>
</operation>
</binding>
binding :用于定义SEI的实现类;
type:医用上面定义的portType标签;
operation :方法的具体实现;
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"></soap:binding>:用来指定使用xml文档传输
<soap:body use="literal"></soap:body>:是指客户端传过来的数据是文本数据
(5)service
<service name="HelloWSImplService">
<port name="HelloWSImplPort" binding="tns:HelloWSImplPortBinding">
<soap:address location="http://192.168.199.215:8989/ws_test/zq"></soap:address>
</port>
</service>
service :是服务器端的一个webservice容器
name属性:用来指定客户端容器类;
port:用来指定一个服务器端处理请求的入口,其实就是对应一个service服务的入口。
binding属性:引用上面的binding标签;
address:当前webservice的请求地址。
整体结构提如下所示: