Web Service endpoints in Mustang
Mustang has a very good support for Web Services. One can create, publish a Web Service very easily. First write the Web Service endpoint implementation, and then use javax.xml.ws.Endpoint API to create and publish the Web Service.
package myws;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
@WebService
@SOAPBinding(style=SOAPBinding.Style.RPC)
public class Implementor {
public int add(int a, int b) {
return a+b;
}
}
package myws;
import javax.xml.ws.Endpoint;
public class WSWrapper {
public static void main(String[] args) {
Implementor impl = new Implementor();
// Create and publish the endpoint at the given address
Endpoint endpoint = Endpoint.publish("http://localhost:8080/add", impl);
}
}
Compile both the java files and run the java class myws.WSWrapper (Typically one needs to run wsgen before running the program but in this case it is not required). JAXWS runtime created and published a Web Service in publish() method. The WSDL of the Web Service is published at http://localhost:8080/add?wsdl and can be accessed from the browser. Now write a client to access this Web Service !!
- Login or register to post comments
- Printer-friendly version
- jitu's blog
- 3082 reads





