Publishing a web service without an application server

This recipe explains the method of exposing a web service to clients without deploying it to the application server.

How to do it…

In Java code, we create the web service publisher class and name it as PublisherCCGateway.

Tip

Do not forget to check the Main Method option in the Create Java Class wizard in JDeveloper.

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.

How it works…

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:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset