似乎jdk 6.0已经带有jax-ws实现,并且可以嵌入一个小的服务器。我还没有弄清楚所有的东西,但是这是一个开始:
mkdir -p helloservice/endpoint/
helloservice / endpoint / Hello.java:
package helloservice.endpoint;import javax.jws.WebService;@WebService()public class Hello { private String message = new String("Hello, "); public void Hello() {} public String sayHello(String name) { return message + name + "."; }}helloservice / endpoint / Server.java:
package helloservice.endpoint;import javax.xml.ws.Endpoint;public class Server { protected Server() throws Exception { System.out.println("Starting Server"); Object implementor = new Hello(); String address = "http://localhost:9000/SoapContext/SoapPort"; Endpoint.publish(address, implementor); } public static void main(String args[]) throws Exception { new Server(); System.out.println("Server ready..."); Thread.sleep(5 * 60 * 1000); System.out.println("Server exiting"); System.exit(0); }}建立东西:
mkdir buildjavac -d build helloservice/endpoint/*java$JAVA_HOME/wsgen -d build -s build -classpath . helloservice.endpoint.Hello
运行东西:
java -cp build helloservice.endpoint.Server
现在,某些东西正在http:// localhost:9000 / SoapContext /
SoapPort上运行。您可以在http://
localhost:9000 / SoapContext /
SoapPort?WSDL上获得wsdl。
还没有找到客户的机会。



