packageteam.soi.service;publicinterfaceHelloService{/**
* to do sth.
* @param to
* @return
*/ObjecttoDoSth(Stringto);}
编写接口的实现类
1
2
3
4
5
6
7
8
9
10
11
12
13
packageteam.soi.service.impl;importteam.soi.service.HelloService;importjavax.jws.WebService;@WebServicepublicclassHelloServiceImplimplementsHelloService{publicObjecttoDoSth(Stringto){return"Hello,"+to+"! Welcome to my webservice world!";}}
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<!--
Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e.
--><!--
Generated by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e.
--><definitionsxmlns: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://impl.service.soi.team/"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns="http://schemas.xmlsoap.org/wsdl/"targetNamespace="http://impl.service.soi.team/"name="HelloServiceImplService"><types><xsd:schema><xsd:importnamespace="http://impl.service.soi.team/"schemaLocation="http://localhost:8899/ws/demo?xsd=1"/></xsd:schema></types><messagename="toDoSth"><partname="parameters"element="tns:toDoSth"/></message><messagename="toDoSthResponse"><partname="parameters"element="tns:toDoSthResponse"/></message><portTypename="HelloServiceImpl"><operationname="toDoSth"><inputwsam:Action="http://impl.service.soi.team/HelloServiceImpl/toDoSthRequest"message="tns:toDoSth"/><outputwsam:Action="http://impl.service.soi.team/HelloServiceImpl/toDoSthResponse"message="tns:toDoSthResponse"/></operation></portType><bindingname="HelloServiceImplPortBinding"type="tns:HelloServiceImpl"><soap:bindingtransport="http://schemas.xmlsoap.org/soap/http"style="document"/><operationname="toDoSth"><soap:operationsoapAction=""/><input><soap:bodyuse="literal"/></input><output><soap:bodyuse="literal"/></output></operation></binding><servicename="HelloServiceImplService"><portname="HelloServiceImplPort"binding="tns:HelloServiceImplPortBinding"><soap:addresslocation="http://localhost:8899/ws/demo"/></port></service></definitions>
soi@soi:~/workspace/wsc$ wsimport -extension -keep -p team.soi.ws.client -s ./src -d ./bin http://localhost:8899/ws/demo?wsdl
正在解析 WSDL...
正在生成代码...
正在编译代码...
soi@soi:~/workspace/wsc$ cd bin
soi@soi:~/workspace/wsc/bin$ jar cvf hello-ws-demo.jar team
soi@soi:~/workspace/wsc/bin$ ls
hello-ws-demo.jar team
packageteam.soi;importjunit.framework.TestCase;importteam.soi.ws.client.HelloServiceImpl;importteam.soi.ws.client.HelloServiceImplService;publicclassAppTestextendsTestCase{/**
* test ws
*/publicvoidtestWs(){HelloServiceImplservice=newHelloServiceImplService().getHelloServiceImplPort();Strings=(String)service.toDoSth("Soi");System.out.println(s);}}