WebService学习笔记-WSDL文档分析
发布时间:2020-12-17 00:55:32 所属栏目:安全 来源:网络整理
导读:?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.day01_ws.atguigu.com/"xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"?xm
<?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.day01_ws.atguigu.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"? xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="HelloWSImplService"? targetNamespace="http://ws.day01_ws.atguigu.com/"> <!--? types? schema?:?定义了一些标签结构 ?--> <wsdl:types> <xs:schema?xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://ws.day01_ws.atguigu.com/"?elementFormDefault="unqualified" targetNamespace="http://ws.day01_ws.atguigu.com/"?version="1.0"> <!--? //用于请求 <sayHello> <arg0>string</arg0> </sayHello> <q0:sayHello> <arg0>BB</arg0>? </q0:sayHello> //用于响应 <sayHelloResponse> <return>string</return> </sayHelloResponse> <ns2:sayHelloResponse"> <return>Hello?BB</return>? </ns2: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:?用来定义消息的结构???soap消息 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 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属性:?引用上面的<portType> <soap:binding?style="document">?:?绑定的数据是一个document(xml) operation?:?用来定义实现的方法 <soap:operation?style="document"?/>?传输的是document(xml) input:?指定客户端应用传过来的数据 <soap:body?use="literal"?/>?:?文本数据 output?: 指定服务器端返回给客户端的数据 <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://192.168.10.165:8888/day01_ws/hellows"?/> </wsdl:port> </wsdl:service> </wsdl:definitions> 1.Webservice相当于http+XML+schema 2.wsdl:webservice定义语言,对应.wsdl文档。一个webservice服务会对应一个唯一的wsdl文档。定义了客户端和服务端发送请求的响应的数据格式和过程。 3.soap:simple object access protocal? 4.发布webservice: ①定义SEI @webservice @webmethod ②定义SEI的实现 ③发布 Endpoint .publish(address,new XXXImpl()) 5.请求webservice ①根据wsdl文档生成客户端代码。使用JDK(wsimport -keep)或CXF(wsdl2java)生成。 ②根据生成的代码调用webservice (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |