java 如何在 Tomcat 7 上部署 SOAP Web 服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30846441/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 17:44:50  来源:igfitidea点击:

How to deploy SOAP Web Service on Tomcat 7

javaweb-servicessoaptomcat7

提问by Khan

How do I deploy a SOAP Web Service on Tomcat 7?

如何在 Tomcat 7 上部署 SOAP Web 服务?

I have successfully published my Web Service using Eclipse:

我已经使用 Eclipse 成功发布了我的 Web 服务:

"Endpoint.publish("http://localhost:786/AddWebservice", new Operation())"

From here I have no idea how to publish the same Web Service on a Tomcat Server.

从这里我不知道如何在 Tomcat 服务器上发布相同的 Web 服务。

回答by Anilkumar Bathula

Deploy JAX-WS web services on Tomcat servlet container. See following summary steps of a web service deployment.

在 Tomcat servlet 容器上部署 JAX-WS Web 服务。请参阅以下 Web 服务部署的摘要步骤。

  1. Create a web service (of course).
  2. Create a sun-jaxws.xml, defines web service implementation class.
  3. Create a standard web.xml, defines WSServletContextListener, WSServlet and structure of a web project.
  4. Build tool to generate WAR file.
  5. Copy JAX-WS dependencies to “${Tomcat}/lib” folder.
  6. Copy WAR to “${Tomcat}/webapp” folder.
  7. Start It.
  1. 创建一个 Web 服务(当然)。
  2. 创建一个 sun-jaxws.xml,定义 web 服务实现类。
  3. 创建标准的 web.xml,定义 WSServletContextListener、WSServlet 和 web 项目的结构。
  4. 生成 WAR 文件的构建工具。
  5. 将 JAX-WS 依赖项复制到“${Tomcat}/lib”文件夹。
  6. 将 WAR 复制到“${Tomcat}/webapp”文件夹。
  7. 启动它。

See the below example SOAP in Tomcat

请参阅以下Tomcat 中的 SOAP示例

回答by Michail Alexakis

If building as a Maven project, a simple and consistent way to gather runtime dependencies is to add the following dependency (adjust version):

如果构建为 Maven 项目,收集运行时依赖项的一种简单且一致的方法是添加以下依赖项(调整版本):

<!-- runtime for JAX-WS (servlet implementation) -->
<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-rt</artifactId>
    <version>2.2.10</version>
</dependency>

回答by Khan

The one way can be used to publish the endpoint is to create a servlet and within doGet() method, publish your endpoint as "Endpoint.publish("your_URL", new Operation())" then use "your_URL", to hit the service.

可用于发布端点的一种方法是创建一个 servlet 并在 doGet() 方法中,将您的端点发布为“Endpoint.publish("your_URL", new Operation())”,然后使用“your_URL”,点击服务。