如何将jax-ws服务部署到eclipse或tomcat? [英] how to deploy a jax-ws service to eclipse or tomcat?

查看:240
本文介绍了如何将jax-ws服务部署到eclipse或tomcat?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为一个Web服务初学者,我已经尝试了2个星期来获得一个与Maven,eclipse和tomcat一起使用的世界级Web服务。

As a web services beginner, I have tried for 2 weeks to get a hello world webservice working with maven, eclipse and tomcat.

我放弃了尝试任何代码/ wsdl生成器都可以工作,我遵循了本教程 http ://myarch.com/create-jax-ws-service-in-5-minutes 编写一个很好的例子。

I gave up trying to get any of the code/wsdl generators to work, and I followed this tutorial http://myarch.com/create-jax-ws-service-in-5-minutes to hand code an example, which is brilliant.

此会产生4个类文件和一个WSDL文件。

This results in 4 class files and a WSDL file.

所以我的愚蠢问题是如何在Eclipse和/或tomcat中运行服务?

So my stupid question is how to "run" the service in eclipse and/or on tomcat?

我尝试只是将它们部署为Web应用程序,但是没有乐趣-web.xml中没有任何内容可以告诉Servlet引擎该Web服务存在,因此我想它永远无法工作。

I tried just deploying them as a webapp, but no joy - there is nothing in the web.xml to tell the servlet engine that the web service exists, so I guess it could never work.

我是否必须在tomcat内安装一个特殊的Web服务容器(例如axis2,Metro或CXF)并进行部署?还是可以只使用一些jax-ws jar和神秘配置来运行它?

Do I have to have a special web service container (e.g. axis2, metro or CXF) inside tomcat, and deploy to that? Or can it just run with some jax-ws jars + mystery configuration?

我不想安装到tomcat Metro(它使用了蚂蚁,并且被设计用于玻璃鱼) )或axis2(使用ant,大多数人似乎不建议使用)。

I dont want to have to install into tomcat metro (which uses ant, and is desiged for glassfish), or axis2 (which uses ant, and most people seem to not recommend).

我看过CXF,但是在他们的站点上找不到如何在没有弹簧的情况下在tomcat(或Eclipse)上安装/配置它的地方。我将CFX jars放入了maven依赖项中,并安装了eclipse插件,但是这样做可以使您更接近实际运行Web服务,而无需了解神秘的配置方法。 CXF似乎与spring绑定在一起,这对我们来说是一个很大的缺点,因为我们不使用spring(或需要它的任何功能)。

I looked at CXF, but cant find anywhere on their site on how to install/configure it on tomcat (or eclipse) without spring. I put the CFX jars in maven dependencies, and installed the eclipse plugin, but this deoesnt get you any closer to actually running a webservice with out the mystery configuration glue. CXF seems tied to spring, which is a big minus for us as we dont use spring (or need any of its features).

我注意到helios wtp具有某种Web服务项目,称为JSR-109。是仅此Java RPC,还是支持完整的SOAP websiervice系统,是否值得尝试?

I noticed helios wtp has some kind of web service project called JSR-109. Is this java RPC only, or does it support the full SOAP websiervice system, and is it worth trying to figrue out?

任何建议都非常欢迎。我必须在Google上搜索1000个页面才能找到网络上的圣杯-即如何创建一个页面并将其部署到tomcat的端到端。

Any advice very welcome. I must have googled 1000 pages in search of the web serive holy grail - i.e. how to create and deploy one to tomcat end to end. Is it supposed to be this hard?

推荐答案

将此片段添加到您的 web.xml 文件中

Add this fragment to your web.xml file

<servlet>
    <servlet-name>wshello</servlet-name>
    <servlet-class>
        com.sun.xml.ws.transport.http.servlet.WSServlet
    </servlet-class>              
</servlet>      
<servlet-mapping>
    <servlet-name>wshello</servlet-name>
        <url-pattern>/webservice</url-pattern>
</servlet-mapping>

然后仅创建一个名称为 sun-jaxws.xml 的文件。

And then just create a file whose name is sun-jaxws.xml.

<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"  version="2.0">
  <endpoint  name="WebServiceTest"
             implementation="your.webservice.impl.ClassName"
             url-pattern="/webservice"/>
</endpoints>

然后照常创建战争文件。您不需要CXF或Axis即可将基本的Web服务部署到Tomcat中。
顺便说一下,jax-ws库jars(jaxws-api.jar,jaxb-impl.jar等)应该位于您的类路径中。您可以从此处

Then create a war file as usual. You don't need CXF or Axis to deploy a basic WebService into Tomcat. By the way jax-ws library jars( jaxws-api.jar, jaxb-impl.jar etc..) should be in your classpath. You can download jax-ws libraries from here

这篇关于如何将jax-ws服务部署到eclipse或tomcat?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆