简体   繁体   English

在云上部署Web服务

[英]Deploying web service on cloud

Developed an web service , below are the steps 开发了一个Web服务,以下是步骤

1) Create a Web Service Endpoint Interface.. 1)创建一个Web服务端点接口。

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);

}

2. Create a Web Service Endpoint Implementation .. 2.创建一个Web服务端点实现。

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; 导入javax.xml.ws.Endpoint; import com.abc.ws.HelloWorldImpl; 导入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” . 现在,我还通过通过此URL“ http:// localhost:9999 / ws / hello?wsdl”访问生成的WSDL(Web服务定义语言)文档来测试已部署的Web服务。

But My query is that as I new to the world of cloud , I want to deploy my webservice to cloud like amazon so that If I provide the wsdl to anyone in the world he can access my wsdl through his browser as my web service is deployed on cloud. 但是我的查询是,当我刚接触云世界时,我想将我的Web服务像亚马逊一样部署到云中,这样,如果我将wsdl提供给世界上的任何人,他都可以在部署Web服务时通过浏览器访问我的wsdl。在云上。

Please advise me how to 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. 当您将应用程序部署到云上的真实服务器时,此方法将不起作用,因为您无法执行发布Web服务的main方法。

You need to configure something to publish your web service when your application starts on server. 当您的应用程序在服务器上启动时,您需要配置一些内容以发布Web服务。

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. 例如,使用Spring在Tomcat上运行SOAP Web服务时,您需要注入WS bean并使用SimpleJaxWsServiceExporter bean进行发布,这些配置在application-context.xml或等效文件上实现。

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. 在您的情况下,请查看此链接 ,它是如何使用JAX-WS RI发行版发布WSDL Web服务的示例。

For tests, you can deploy your WAR application to Openshift . 对于测试,您可以将WAR应用程序部署到Openshift

Hope it helps, Best Regards. 希望对您有帮助,最好的问候。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM