Archive for the ‘jax-ws’ tag
WebService Client in JAX-WS (Java 6 and above)
Given a WSDL URL, you may generate the Java client classes using the JDK provided tool wsimport. The basic usage:
$ wsimport <wsdl_url>
The common command-line parameters supported by this tool:
| -p | specifies the target package |
| -d | folder where generated class files are placed |
Quick WebService in Java 6
To write a quick JAX-WS webservice in Java 6:
package test;
import javax.xml.ws.Endpoint;
@javax.jws.WebService
public class MyWebService{
@javax.jws.WebMethod
public String getQuote(String name){
return "1234.56";
}
public static void main(String[] arg){
Endpoint end = Endpoint.create(new MyWebService());
end.publish("http://localhost:1000/MyWebService");
}
}
To compile and run:
$ apt -d bin/ MyWebService.java $ java -cp bin test.MyWebService