javax.xml.ws.WebServiceException:找不到端口 {http://tempuri.org/}WSHttpBinding_IDWService

发布于 2024-10-21 13:48:36 字数 990 浏览 2 评论 0原文

我正在尝试使用 java 中的 Web 服务,使用通过 wsdl2java 从 wsdl 文件生成的客户端。

我使用的是 Eclipse 版本 Helios 和 jdk 1.6.0_20,并且我使用 wsld2java 生成了 .class 文件,其选项为:

“-dc:\WebServices\Genelated -client -verbose -compile -autoNameResolution -p org.dwservice - sn DWService -wsdlLocation /WEB-INF/wsdl/DWService.wsdl c:\WebServices\DWService.wsdl"

我将生成的文件打包到 .jar 中并将其添加到我的项目中,编译正常。 但是当我尝试使用网络服务时,我得到了异常:

javax.xml.ws.WebServiceException: Port {http://tempuri.org/}WSHttpBinding_IDWService not found.
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:311)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:302)
at javax.xml.ws.Service.getPort(Service.java:92)
at org.dwservice.DWService.getWSHttpBindingIDWService(DWService.java:63)

这是我的代码:

import org.dwservice.*;
...

private DWService dwService = new DWService();
private IDWService iDWService = ***dwService.getWSHttpBindingIDWService()***;

任何想法都会非常感激。

I'm trying to consume a webservice in java, using a client generated from the wsdl file with wsdl2java.

I'm using Eclipse version Helios and jdk 1.6.0_20, and I've generated the .class files using wsld2java with the options:

"-d c:\WebServices\Generated -client -verbose -compile -autoNameResolution -p org.dwservice -sn DWService -wsdlLocation /WEB-INF/wsdl/DWService.wsdl c:\WebServices\DWService.wsdl"

I packed the resultant files into a .jar and added it to my project that compiles ok.
But when I try to use the webservice, I got the exception:

javax.xml.ws.WebServiceException: Port {http://tempuri.org/}WSHttpBinding_IDWService not found.
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:311)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:302)
at javax.xml.ws.Service.getPort(Service.java:92)
at org.dwservice.DWService.getWSHttpBindingIDWService(DWService.java:63)

And this is my code:

import org.dwservice.*;
...

private DWService dwService = new DWService();
private IDWService iDWService = ***dwService.getWSHttpBindingIDWService()***;

Any idea would be very much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘虞初梦 2024-10-28 13:48:36

我知道这篇文章已经有一年多了,但它是这个错误的排名很高的搜索结果。我为后代添加这个答案。

您的 wsdl2java 命令表明您的 WSDL 是本地的,并且您正在将其打包到 Web 应用程序中。我怀疑应用程序在运行时找不到打包的 WSDL。一种选择是将其作为 Java 资源加载并将其位置传递到服务的构造函数中:

QName qname = new QName("my.name.space", "myName");
URL wsdlLocation = MyServiceClient.class.getResource("/WEB-INF/wsdl/DWService.wsdl");

dwService = new DWService(wsdlLocation, qname);

如果使用此方法,请仔细检查 WSDL 的路径。 getResource() 很容易默默地失败,这将产生相同的错误。

I know this post is over a year old, but it's a highly ranked search result for this error. I'm adding this answer for posterity.

Your wsdl2java command suggests your WSDL is local and you're packaging it into a web app. I suspect the app isn't finding the packaged WSDL at runtime. One option is to load it as a Java resource and pass its location into your service's constructor:

QName qname = new QName("my.name.space", "myName");
URL wsdlLocation = MyServiceClient.class.getResource("/WEB-INF/wsdl/DWService.wsdl");

dwService = new DWService(wsdlLocation, qname);

If you use this approach, triple-check the path to your WSDL. It's easy for getResource() to silently fail, which will produce the same error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文