首先看看一段简单的JAVA代码,我们用它作为WSDL的服务实现代码:
public class Test
{
public String echo(String u){
return "Hello " + u;
}
}
然后看看用它导出的WSDL:
1<wsdl:definitions targetnamespace=" http://businessEngine.hongsoft.com " xmlns=" http://schemas.xmlsoap.org/wsdl/ " xmlns:apachesoap=" http://xml.apache.org/xml-soap " xmlns:impl=" http://businessEngine.hongsoft.com-impl " xmlns:intf=" http://businessEngine.hongsoft.com " xmlns:soapenc=" http://schemas.xmlsoap.org/soap/encoding/ " xmlns:wsdl=" http://schemas.xmlsoap.org/wsdl/ " xmlns:wsdlsoap=" http://schemas.xmlsoap.org/wsdl/soap/ " xmlns:xsd=" http://www.w3.org/2001/XMLSchema ">
2<wsdl:types></wsdl:types>//我们没有自定义的类型
3
4<wsdl:message name="echoResponse">//返回的消息
5
6<wsdl:part name="echoReturn" type="xsd:string"></wsdl:part>
7</wsdl:message>
8<wsdl:message name="echoRequest">//请求的消息
9
10<wsdl:part name="u" type="xsd:string"></wsdl:part>
11</wsdl:message>
12<wsdl:porttype name="Test">//一个portType可以看着一个类
13
14<wsdl:operation name="echo" parameterorder="u">//一个operation就是一个方法
15
16<wsdl:input message="intf:echoRequest" name="echoRequest"></wsdl:input>
17<wsdl:output message="intf:echoResponse" name="echoResponse"></wsdl:output>
18</wsdl:operation>
19</wsdl:porttype>
20<wsdl:binding name="TestSoapBinding" type="intf:Test">
21//下面指定消息封装方式
22
23<wsdlsoap:binding style="rpc" transport=" http://schemas.xmlsoap.org/soap/http">
24//下面将WSDL描述与具体实现进行绑定,这里采用SOAP方式
25
26<wsdl:operation name="echo">
27<wsdlsoap:operation soapaction=""></wsdlsoap:operation>
28<wsdl:input name="echoRequest">
29<wsdlsoap:body encodingstyle=" http://schemas.xmlsoap.org/soap/encoding/ " namespace=" http://businessEngine.hongsoft.com " use="encoded"></wsdlsoap:body>
30</wsdl:input>
31<wsdl:output name="echoResponse">
32<wsdlsoap:body encodingstyle=" http://schemas.xmlsoap.org/soap/encoding/ " namespace=" http://businessEngine.hongsoft.com " use="encoded"></wsdlsoap:body>
33</wsdl:output>
34</wsdl:operation>
35</wsdlsoap:binding></wsdl:binding>
36//下面将发布的服务与前面的SOAP绑定进行关联
37
38<wsdl:service name="TestService">
39<wsdl:port binding="intf:TestSoapBinding" name="Test">
40<wsdlsoap:address location=" http://localhost:8080/hongsoft/services/Test">
41</wsdlsoap:address></wsdl:port>
42</wsdl:service>
43</wsdl:definitions>