WebService—wsdl的简单介绍(未完)
发布时间:2020-12-17 00:02:22 所属栏目:安全 来源:网络整理
导读:WSDL简介 WSDL,Web Services Description Language,Web Service的描述语言,是一种接口定义语言,用于描述Web Service的接口信息等。(描述Web服务和说明如何与Web服务通信的XML语言。为用户提供详细的接口说明书。) WSDL元素 WSDL有五大元素,分别是type
WSDL简介 WSDL,Web Services Description Language,Web Service的描述语言,是一种接口定义语言,用于描述Web Service的接口信息等。(描述Web服务和说明如何与Web服务通信的XML语言。为用户提供详细的接口说明书。) WSDL元素 WSDL有五大元素,分别是types,message,portType,binding和service。 ? types:用来定义访问的类型 下方为 代码优先 生成的wsdl文件: <?xml version="1.0" encoding="UTF-8"?> <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://service.zttc.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://service.zttc.org/" name="MyServiceImplService"> <!-- types:用来定义访问的类型 --> <types> <xsd:schema> <xsd:import namespace="http://service.zttc.org/" schemaLocation="http://localhost:8887/ns?xsd=1"></xsd:import> </xsd:schema> </types> <!-- message:SOAP Message,消息体 --> <message name="minus"> <part name="parameters" element="tns:minus"></part> </message> <message name="minusResponse"> <part name="parameters" element="tns:minusResponse"></part> </message> <message name="login"> <part name="parameters" element="tns:login"></part> </message> <message name="loginResponse"> <part name="parameters" element="tns:loginResponse"></part> </message> <message name="add"> <part name="parameters" element="tns:add"></part> </message> <message name="addResponse"> <part name="parameters" element="tns:addResponse"></part> </message> <!-- portType:端口类型,指明服务器的接口 --> <portType name="IMyService"> <!-- 并且通过operation绑定相应的in和out消息(in:参数,out:返回值)--> <!-- operation,操作,对服务所支持的操作进行抽象描述 --> <operation name="minus"> <input wsam:Action="http://service.zttc.org/IMyService/minusRequest" message="tns:minus"></input> <output wsam:Action="http://service.zttc.org/IMyService/minusResponse" message="tns:minusResponse"></output> </operation> <operation name="login"> <input wsam:Action="http://service.zttc.org/IMyService/loginRequest" message="tns:login"></input> <output wsam:Action="http://service.zttc.org/IMyService/loginResponse" message="tns:loginResponse"></output> </operation> <operation name="add"> <input wsam:Action="http://service.zttc.org/IMyService/addRequest" message="tns:add"></input> <output wsam:Action="http://service.zttc.org/IMyService/addResponse" message="tns:addResponse"></output> </operation> </portType> <!-- binding:使用的通信协议,指定传递消息所使用的格式 --> <binding name="MyServiceImplPortBinding" type="tns:IMyService"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding> <operation name="minus"> <soap:operation soapAction=""></soap:operation> <input> <soap:body use="literal"></soap:body> </input> <output> <soap:body use="literal"></soap:body> </output> </operation> <operation name="login"> <soap:operation soapAction=""></soap:operation> <input> <soap:body use="literal"></soap:body> </input> <output> <soap:body use="literal"></soap:body> </output> </operation> <operation name="add"> <soap:operation soapAction=""></soap:operation> <input> <soap:body use="literal"></soap:body> </input> <output> <soap:body use="literal"></soap:body> </output> </operation> </binding> <!-- service:指定服务所发布的名称 --> <service name="MyServiceImplService"> <!-- 定义为绑定和网络地址组合的单个端点 --> <port name="MyServiceImplPort" binding="tns:MyServiceImplPortBinding"> <soap:address location="http://localhost:8887/ns"></soap:address> </port> </service> </definitions>
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/mywsdl/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="MyServiceImplService" targetNamespace="http://www.example.org/mywsdl/"> <!-- types:用来定义访问的类型 --> <wsdl:types> <xsd:schema targetNamespace="http://www.example.org/mywsdl/"> <xsd:element name="plus" type="tns:plus" /> <xsd:element name="plusResponse" type="tns:plusResponse" /> <xsd:element name="minus" type="tns:minus" /> <xsd:element name="minusResponse" type="tns:minusResponse" /> <xsd:element name="licenseInfo" type="xsd:string" /> <xsd:complexType name="plus"> <xsd:sequence> <xsd:element name="a" type="xsd:int" /> <xsd:element name="b" type="xsd:int" /> </xsd:sequence> </xsd:complexType> <xsd:complexType name="plusResponse"> <xsd:sequence> <xsd:element name="plusResult" type="xsd:int" /> </xsd:sequence> </xsd:complexType> <xsd:complexType name="minus"> <xsd:sequence> <xsd:element name="num1" type="xsd:int" /> <xsd:element name="num2" type="xsd:int" /> </xsd:sequence> </xsd:complexType> <xsd:complexType name="minusResponse"> <xsd:sequence> <xsd:element name="minusResult" type="xsd:int" /> </xsd:sequence> </xsd:complexType> </xsd:schema> </wsdl:types> <!-- message:SOAP Message,消息体 --> <wsdl:message name="plus"> <wsdl:part name="plus" element="tns:plus" /> </wsdl:message> <wsdl:message name="plusResponse"> <wsdl:part name="plusResponse" element="tns:plusResponse" /> </wsdl:message> <wsdl:message name="minus"> <wsdl:part name="minus" element="tns:minus" /> </wsdl:message> <wsdl:message name="minusResponse"> <wsdl:part name="minusResponse" element="tns:minusResponse" /> </wsdl:message> <wsdl:message name="licenseInfo"> <wsdl:part name="licenseInfo" element="tns:licenseInfo" /> </wsdl:message> <!-- portType:端口类型,指明服务器的接口 --> <wsdl:portType name="IMyService"> <!-- 并且通过operation绑定相应的in和out消息(in:参数,out:返回值)--> <wsdl:operation name="plus"> <wsdl:input message="tns:plus" /> <wsdl:output message="tns:plusResponse" /> </wsdl:operation> <wsdl:operation name="minus"> <wsdl:input message="tns:minus" /> <wsdl:output message="tns:minusResponse" /> </wsdl:operation> </wsdl:portType> <!-- binding:使用的通信协议,指定传递消息所使用的格式 --> <wsdl:binding name="myServiceSOAP" type="tns:IMyService"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="plus"> <wsdl:input> <soap:body use="literal"/> <soap:header use="literal" part="licenseInfo" message="tns:licenseInfo" /> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="minus"> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <!-- service:指定服务所发布的名称 --> <wsdl:service name="MyServiceImplService"> <wsdl:port binding="tns:myServiceSOAP" name="MyServiceImplPort"> <soap:address location="http://localhost:8989/ms"/> </wsdl:port> </wsdl:service> </wsdl:definitions> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |