WebService顾名思义就是web服务,web服务主要有两种,一种是基于soap类型的服务,一种是基于rest类型的服务,
其中soap类型的服务有两种版本,一种是soap1.1版本,一种是soap1.2版本,soap服务类型的数据是xml数据格式的,
rest服务的数据类型是json格式的
wsdl查看是从下往上的
根据wsdl写客户端
HelloWorldService hws = new HelloWorldService; //service的name
HelloWorld hw = hws.getHelloWorld()//service下port的name
String s1 = hw.sayHelloWorldFrom("lhw");
1.wsdl:service
<wsdl:service name="HelloWorldService"> <wsdl:port binding="impl:HelloWorldSoapBinding" name="HelloWorld"> <wsdlsoap:address location="http://localhost:8080//services/example/HelloWorld"/> </wsdl:port> </wsdl:service>
wsdl:service 是表明这个服务的名称:HelloWorldService 服务的地址:http://localhost:8080//services/example/HelloWorld
service的binding绑定了 2.wsdl:binding 的name
2.wsdl:binding
简单代码说明:
<wsdl:binding name="HelloWorldSoapBinding" type="impl:HelloWorld"> </wsdl:binding>
详细代码:
<wsdl:binding name="HelloWorldSoapBinding" type="impl:HelloWorld">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sayHelloToYou">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="sayHelloToYouRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="sayHelloToYouResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="sayHelloWorldFrom">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="sayHelloWorldFromRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="sayHelloWorldFromResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>