I have developed a web service with the below steps:
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);
}
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;
}
}
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With