Java 7 包含 JAX-WS 实现还是仅包含 API?
有人告诉我 Java 7 应该包含 JAX-WS,这样我就不需要像 Apache CXF 中那样的库。然而,官方文档说:
此版本包含用于 XML 处理的 Java API (JAXP) 1.4.5、 支持 Java XML 绑定架构 (JAXB) 2.2.3,并支持 用于 XML Web 服务的 Java API (JAX-WS) 2.2.4。
此外,JAX-WS 上的 Eclipse 页面谈到使用 Apache CXF、Sun Metro 或 Apache Axis 等实现。我在 JAX-WS 上找到的每个示例/教程都使用 CXF 或 Metro 等库集。
我在 Eclipse 中有一个项目,它在带有 javax.jws.WebService 注释的类上调用“Endpoint.publish(...)”。下面引用的 WSDL 文件位于 Eclipse 外部。该项目(作为“Java 应用程序”)与 Apache CXF 库一起运行良好。一旦我删除它们(以及 Eclipse 对 Apache CXF 的引用),它就会崩溃并出现以下异常:
com.sun.xml.internal.ws.server.ServerRtException: [failed to localize] cannot.load.wsdl(http://localhost:8081/wsdl/csw.wsdl)
at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.getPrimaryWsdl(EndpointImpl.java:313)
因此,要么我做错了什么,要么 Apache 提供了 JDK 本身只有 API 的实现。请指出是哪种情况,以及相关内容的常用链接。
I am told that Java 7 is supposed to include JAX-WS such that I don't need libraries like those in Apache CXF. However, the official docs say:
This release contains Java API for XML Processing (JAXP) 1.4.5,
supports Java Architecture for XML Binding (JAXB) 2.2.3, and supports
Java API for XML Web Services (JAX-WS) 2.2.4.
Further, the Eclipse page on JAX-WS speaks of using implementations such as Apache CXF, Sun Metro, or Apache Axis. And every example/tutorial I can find on JAX-WS uses a library set like CXF or Metro.
I have a project in Eclipse that calls "Endpoint.publish(...)" on a class with a javax.jws.WebService annotation. The WSDL file referenced below resides outside Eclipse. This project runs (as a "Java Application") fine with the Apache CXF libraries includes. As soon as I remove them (and Eclipse references to Apache CXF), it crashes with the following exception:
com.sun.xml.internal.ws.server.ServerRtException: [failed to localize] cannot.load.wsdl(http://localhost:8081/wsdl/csw.wsdl)
at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.getPrimaryWsdl(EndpointImpl.java:313)
So either I'm doing something wrong or Apache is supplying implementations of things to which the JDK itself only has APIs. Please point out which is the case, along with the usual link to something relevant.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Jdk 7(如 6)包含基于 Metro 的实现。
正如您从异常中看到的,内部实现正在运行“com.sun.xml.internal.ws.transport.http.server.EndpointImpl”。问题似乎是它不喜欢你的 WsdlLocation (我相信 jaxws 期望本地资源,但你给了它一个 http 资源)。
Jdk 7 (like 6) includes a metro based implementation.
As you can see from your exception, the internal implementation is running "com.sun.xml.internal.ws.transport.http.server.EndpointImpl". The problem seems to be that it doesn't like your WsdlLocation (i believe jaxws is expecting a local resource, but you have given it a http resource).