http://blog.csdn.net/jxz_st_love123/article/details/45116333
本篇文章还以HelloService为例。
完整的HelloService.Java文件如下
- package cn.itcast.ws;
-
- import javax.jws.WebService;
- import javax.xml.ws.Endpoint;
-
-
-
-
-
-
- @WebService
- public class HelloService {
-
-
-
-
-
- public static void main(String[] args) {
-
-
-
-
- Endpoint.publish("http://192.168.1.100:6789/hello", new HelloService());
-
-
-
- System.out.println("server start ...");
- }
-
- public String sayHello(String name){
- return "hello:"+ name;
- }
- }
点击run as -> Java application ,发布该web 服务。
1.选择launch the web Services Explore
![](https://img-blog.csdn.net/20150418205200024)
2.选择WSDL page,画面跳转至wsdl main。
![](https://img-blog.csdn.net/20150418205703217)
3.输入wsdl url ,点击Go。
![](https://img-blog.csdn.net/20150418205805711)
4.找到你访问的方法,如“sayHello”,点击进入。
![](https://img-blog.csdn.net/20150418205838418)
5.点击“add”。
![](https://img-blog.csdn.net/20150418210116468)
6.输入values,点击go。
![](https://img-blog.csdn.net/20150418210216825)
7.在status中,点击source。
![](https://img-blog.csdn.net/20150418210302604)
8.通过上述操作,就可以在“SOAP Request Envelope:”中看到我们要的soap请求了。当然你也可以通过自己的方法找soap。
内容如下:
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://ws.itcast.cn/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <q0:sayHello>
- <arg0>我是来测试的</arg0>
- </q0:sayHello>
- </soapenv:Body>
- </soapenv:Envelope>