1.实例截图
2.wsdl文件分析 :
<?xml version='1.0' encoding='UTF-8'?>
<!--
wsdl的作用:定义了web service的服务器端与客户端应用交互传递请求和响应数据的格式和方式
请求的url
-->
<wsdl:definitions
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://ws.java.atguigu.net/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
name="HelloWSImplService"
targetNamespace="http://ws.java.atguigu.net/">
<!--
定义当前wsdl文档中所使用的标签,很重要的一部分为soap消息中xml片断所包含的一些标签
<sayHello>
<arg0>文本</arg0>
</sayHello>
===>soap请求的请求体的一部分
<sayHelloResponse>
<return></return>
</sayHelloResponse>
===>soap响应的请求体的一部分
-->
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://ws.java.atguigu.net/"
elementFormDefault="unqualified"
targetNamespace="http://ws.java.atguigu.net/" version="1.0">
<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>
<!--
定义请求消息,它的个数为SEI方法个数的2倍
message name 指定消息的名称
part element 指定消息的组成,依赖<types>中定义的某个element
-->
<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>
<!--
定义SEI接口
portType name 指定SEI接口名
operation 接口的操作,也就是其方法
input message 服务器端接收的消息,依赖指定的<message>,也就是将哪个消息作为请求消息对应方法的参数
output message 指定服务器返回的消息,依赖指定的<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>
<!--
定义服务器端处理请求的SEI实现类对象
binding type :参照<portType>所定义的SEI
soap:binding : 绑定的方式,也就数据传递的方式 为文档(即xml)
input : 指定请求消息(与<portType>中的input对应)
output:指定响应消息(与<portType>中的output对应)
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>
<!-- 定义客户端调用web service的入口
service name :生产客户端的SEI接口实现的工厂类
port binding :处理请求的服务器端的SEI接口实现类对象
address location :web service的请求url
-->
<wsdl:service name="HelloWSImplService">
<wsdl:port binding="tns:HelloWSImplServiceSoapBinding" name="HelloWSImplPort">
<soap:address location="http://192.168.1.104/ws_server/helloWS" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
3.文档结构
<definitions>
<type>
<message>
<portType>
<binding>
<service>
<definitions> <types> <schema> <element> </types> <message> <part> </message> <portType> <operation> <input> <output> </portType> <binding> <operation> <input> <output> </binding> <service> <port> <address> </service> </definitions> |
3.1 文档结构图
4. 重要标签的说明
· types - 数据类型(标签)定义的容器,里面使用schema定义了一些标签结构供message引用
· message - 通信消息的数据结构的抽象类型化定义。引用types中定义的标签
· operation - 对服务中所支持的操作的抽象描述,一个operation描述了一个访问入口的请求消息与响应消息对。
· portType - 对于某个访问入口点类型所支持的操作的抽象集合,这些操作可以由一个或多个服务访问点来支持。
· binding - 特定端口类型的具体协议和数据格式规范的绑定。
· service- 相关服务访问点的集合
· port - 定义为协议/数据格式绑定与具体Web访问地址组合的单个服务访问点。