1:安装好java6,eclipse
2:创建jvava project
创建一个java类:如下。
package com.myfirst.wsServer;
import javax.jws.WebService;
@WebService
public class SayHello {
private static final String SALUTATION = "Hello";
public String getGreeting( String name ) {
return SALUTATION + " " + name;
}
}
创建一个build.xml文件。如下:
<project default="wsgen">
<target name="wsgen">
<exec executable="wsgen">
<arg line="-cp ./bin -keep -s ./src -d ./bin com.myfirst.wsServer.SayHello" />
</exec>
</target>
</project>
生成2个文件 GetGreeting.java , GetGreetingResponse.java
3:运行webservice
package com.myfirst.wsServer;
import javax.xml.ws.Endpoint;
public class RunService {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("SayHello Web Service started.");
Endpoint.publish("http://localhost:8080/wsTest", new SayHello());
}
}
4:测试
wsdl地址
http://localhost:8080/wsTest
可以使用eclipse 中的 luanch the web services Explorer 进行测试。