【问题标题】:Deploying web service on cloud在云上部署 Web 服务
【发布时间】:2012-09-10 00:14:00
【问题描述】:

开发了一个网络服务,步骤如下

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。创建一个 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. 创建端点发布者...

导入 javax.xml.ws.Endpoint; 导入 com.abc.ws.HelloWorldImpl;

//Endpoint publisher
public class HelloWorldPublisher{

    public static void main(String[] args) {
       Endpoint.publish("http://localhost:9999/ws/hello", new HelloWorldImpl());
    }

}

现在,我还通过 URL“http://localhost:9999/ws/hello?wsdl”访问生成的 WSDL(Web 服务定义语言)文档来测试部署的 Web 服务。

但是我的疑问是,当我刚接触云世界时,我想将我的网络服务部署到像亚马逊这样的云上,这样如果我向世界上的任何人提供 wsdl,他就可以通过他的浏览器访问我的 wsdl 作为我的网络服务部署在云端。

请告诉我如何实现这一目标..!!

【问题讨论】:

  • 我正在寻找这个...任何可以帮助我们吗?

标签: java web-services jax-ws amazon


【解决方案1】:

当您将应用程序部署到云上的真实服务器时,此方法将不起作用,因为您无法执行 main 方法来发布 Web 服务。

当您的应用程序在服务器上启动时,您需要配置一些东西来发布您的 Web 服务。

例如,使用 Spring,要在 Tomcat 上运行 SOAP Web 服务,您需要注入您的 WS bean 并使用 SimpleJaxWsServiceExporter bean 来发布它,这些配置在您的 application-context.xml 或等效项上实现。

就你而言,看看这个link,它是一个如何使用 JAX-WS RI 分发发布 WSDL Web 服务的示例。

对于测试,您可以将 WAR 应用程序部署到 Openshift

希望对你有帮助, 最好的问候。

【讨论】:

    猜你喜欢
    • 2016-12-11
    • 1970-01-01
    • 2013-07-19
    • 2012-07-15
    • 2014-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多