This recipe explains the method of exposing a web service to clients without deploying it to the application server.
In Java code, we create the web service publisher class and name it as PublisherCCGateway
.
We enter the following Java code into the newly created class:
public class PublisherCCGateway { public static void main(String[] args) { Endpoint.publish("http://localhost:9999/cc/gateway", new CreditCardGateway()); } }
We can now run the web service publisher as a normal Java application.
The javax.xml.ws.Endpoint
class is part of Java SE 6. With the help of this class, we are able to publish the web service without the use of an application server. The web service is packed and published in the JVM HTTP server built in Java SE 6. With the help of the publish()
method, we define the web service endpoint along with the port and provide the web service implementation class. More information about the Endpoint class can be accessed at the following URLs:
http://localhost:9999/cc/gateway
http://localhost:9999/cc/gateway?wsdl