下面给出了一个WSDL文件,用于演示一个简单的WSDL程序.
让我们假设该服务提供了一个公共可用的函数,名为 sayHello .此函数需要单个字符串参数并返回单个字符串问候语.例如,如果您传递参数 world ,那么服务函数 sayHello 将返回问候语"Hello,world!".
HelloService.wsdl文件的内容 :
<definitions name = "HelloService" targetNamespace = "http://www.examples.com/wsdl/HelloService.wsdl" xmlns = "https://img01.yuandaxia.cn/Content/img/tutorials/wsdl/" xmlns:soap = "https://img01.yuandaxia.cn/Content/img/tutorials/wsdl/" xmlns:tns = "http://www.examples.com/wsdl/HelloService.wsdl" xmlns:xsd = "http://www.w3.org/2001/XMLSchema"> <message name = "SayHelloRequest"> <part name = "firstName" type = "xsd:string"/> </message> <message name = "SayHelloResponse"> <part name = "greeting" type = "xsd:string"/> </message> <portType name = "Hello_PortType"> <operation name = "sayHello"> <input message = "tns:SayHelloRequest"/> <output message = "tns:SayHelloResponse"/> </operation> </portType> <binding name = "Hello_Binding" type = "tns:Hello_PortType"> <soap:binding style = "rpc" transport = "https://img01.yuandaxia.cn/Content/img/tutorials/wsdl/error.aspx <operation name = "sayHello"> <soap:operation soapAction = "sayHello"/> <input> <soap:body encodingStyle = "https://img01.yuandaxia.cn/Content/img/tutorials/wsdl/" namespace = "urn:examples:helloservice" use = "encoded"/> </input> <output> <soap:body encodingStyle = "https://img01.yuandaxia.cn/Content/img/tutorials/wsdl/" namespace = "urn:examples:helloservice" use = "encoded"/> </output> </operation> </binding> <service name = "Hello_Service"> <documentation>WSDL File for HelloService</documentation> <port binding = "tns:Hello_Binding" name = "Hello_Port"> <soap:address location = "http://www.examples.com/SayHello/" /> </port> </service> </definitions>
定义 : HelloService
输入 : 使用内置数据类型,它们在XMLSchema中定义.
消息 :
sayHelloRequest : firstName参数
sayHelloresponse : 问候回报价值
港口类型 : sayHello操作,包括请求和响应服务.
绑定 : 使用SOAP HTTP传输协议的方向.
服务 : 服务可在http://www.examples.com/SayHello/
港口 : 将绑定与URI http://www.examples.com/SayHello/相关联,可以访问正在运行的服务.