Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying web service on cloud

I have developed a web service with the below steps:

  1. Create a Web Service Endpoint Interface..
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
 
//Service Endpoint Interface
@WebService
@SOAPBinding(style = Style.RPC)
public interface HelloWorld {

    @WebMethod String getHelloWorldAsString(String name); 
}
  1. Create a Web Service Endpoint Implementation ..
import javax.jws.WebService;
 
//Service Implementation
@WebService(endpointInterface = "com.abc.ws.HelloWorld")
public class HelloWorldImpl implements HelloWorld {
 
    @Override
    public String getHelloWorldAsString(String name) {
        return "Hello World JAX-WS " + name;
    }
}
  1. Create a Endpoint Publisher...
import javax.xml.ws.Endpoint;
import com.abc.ws.HelloWorldImpl;
     
    //Endpoint publisher
    public class HelloWorldPublisher {
     
        public static void main(String[] args) {
           Endpoint.publish("http://localhost:9999/ws/hello", new HelloWorldImpl());
        }
    }

Now I have also tested the deployed web service by accessing the generated WSDL (Web Service Definition Language) document via this URL http://localhost:9999/ws/hello?wsdl.

I am new to the world of cloud, I want to deploy my webservice to the cloud like Amazon, so that If I provide the wsdl to anyone in the world they can access my wsdl through his browser.

How can I achieve this?

like image 837
Rocky Sinha Avatar asked Mar 23 '26 04:03

Rocky Sinha


1 Answers

This aproach will not work when you deploy your application to a real server on the cloud because you cannot execute your main method to publish the web service.

You need to configure something to publish your web service when your application starts on server.

For example, using Spring, to run an SOAP Web Service on Tomcat you need to inject your WS beans and use the SimpleJaxWsServiceExporter bean to publish it, these configurations are realized on your application-context.xml or equivalent.

In your case, take a look on this link, it is an example of how to publish an WSDL Web Service using JAX-WS RI distribution.

For tests, you can deploy your WAR application to Openshift.

like image 91
nortontgueno Avatar answered Mar 25 '26 18:03

nortontgueno



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!