JAX-WS实现包含在Java中? [英] JAX-WS Implementation included with Java?

查看:112
本文介绍了JAX-WS实现包含在Java中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JAX-WS Web服务应用程序,它作为Tomcat 7的WAR文件进行部署。它使用最新版本的Metro库,我将其包含在WAR文件中,并且工作正常。

I have a JAX-WS web service application which deploys as a WAR file for Tomcat 7. It uses a recent version of the Metro libraries, which I include inside the WAR file, and it works fine.

我正在尝试简化部署包。据我所知,Sun JDK包含Metro副本(参见这个问题这一个例如)但由于某种原因,显然必须用从glassfish网站下载的地铁版本替换这份地铁副本。我试图了解是否有可能只使用Tomcat和JDK附带的metro实现,或者如果不是为什么不这样做。

I'm trying to simplify the deployment package. I understand that the Sun JDK includes a copy of Metro (see this question and this one for example), yet for some reason, it's apparently mandatory to replace this copy of metro with one downloaded from the glassfish site. I'm trying to understand if it's possible to get by with just Tomcat and the metro implementation that comes with the JDK, or if not why not.

WAR内容是如下(删除了类文件):

The WAR contents are as follows (class files removed):

META-INF/MANIFEST.MF
WEB-INF/classes/
WEB-INF/classes/com/[et cetera]
WEB-INF/ibm-web-ext.xml
WEB-INF/lib/
WEB-INF/lib/stax-api.jar
WEB-INF/lib/webservices-api.jar
WEB-INF/lib/webservices-extra-api.jar
WEB-INF/lib/webservices-extra.jar
WEB-INF/lib/webservices-rt.jar
WEB-INF/lib/webservices-tools.jar
WEB-INF/sun-jaxws.xml
WEB-INF/web.xml
wsdl/
wsdl/MyService.wsdl

web.xml 部分包含:

<servlet>
    <servlet-name>MyService</servlet-name>
    <servlet-class>
        com.sun.xml.ws.transport.http.servlet.WSServlet
    </servlet-class>              
</servlet>

当我从WAR,网络中移除webservices- * jars - Metro jars时服务失败,错误Wrapper找不到servlet类com.sun.xml.ws.transport.http.servlet.WSServlet或它依赖的类。这并不奇怪,因为我无法在Java 7 SE附带的罐子里找到该类。

When I remove the webservices-* jars--the Metro jars--from the WAR, the web service fails with the error " Wrapper cannot find servlet class com.sun.xml.ws.transport.http.servlet.WSServlet or a class it depends on". This isn't surprising because I can't find that class anywhere in the jars that come with Java 7 SE.

那么,说Java 7是什么意思如果你必须下载另一份地铁副本来做这样的工作吗?是否可以仅使用Java附带的jar在Tomcat中运行JAX-WS Web服务?

So, what does it mean to say that Java 7 comes with Metro, if you have to download another copy of Metro to make something like this work? Is it possible to run a JAX-WS web service within Tomcat using just the jars that come with Java?

推荐答案

捆绑的JAX- WS缺乏与servlet容器的集成,因为它仅用于 在独立Java应用程序中提供JAX-WS服务(WTF!?!?!?)。

Bundled JAX-WS lacks integration with servlet containers, as it is intended to be used only to offer JAX-WS services inside standalone Java applications (WTF!?!?!?).

当然,可以考虑实现一个执行该集成的servlet,因此您不必在WAR中包含另一个Metro副本。但是只包含一个外部的完整副本更容易,它会使WAR膨胀,但不应该有很大的性能损失。此外,通过这种方式,您可以控制使用的版本,避免陷入JRE中包含的版本。

Of course, one could think of implementing a servlet that does that integration, so you would not have to include another copy of Metro in your WAR. But it is easier to just include an external "full" copy, it bloats the WAR but should not have a great performance penalty. Furthermore, in this way you can control which version you use, avoiding to get stuck with the version that was included in your JRE.

无论如何,Sun通常会更改软件包名称。捆绑的库,所以它们不会与外部库冲突,因此,如果servlet存在(它没有),它可能会被调用:

Anyway, Sun usually changed package names in bundled libraries so they would not collide with external ones, Therefore, if the servlet would exist (it does not), it would probably be called:

com.sun.xml 。 内部。 ws.transport.http.servlet.WSServlet

com.sun.xml. internal. ws.transport.http.servlet.WSServlet

这非常烦人,因为它们也以相同的方式更改了一些配置属性(例如:超时相关的),所以如果你使用捆绑的JAX-WS,你必须使用

This is very annoying as they also changed some configuration properties in the same way (e.g.: timeout related ones), so if you use the bundled JAX-WS you have to use

com.sun.xml。 内部。 ...样式配置属性,

但如果您使用某些外部JAX-WS,则必须使用

com.sun.xml. internal.... style configuration properties,

but if you use some external JAX-WS you have to use

com.sun .xml ....样式配置属性。

com.sun.xml.... style configuration properties.

谢谢Sun !!

这篇关于JAX-WS实现包含在Java中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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