javax.xml.ws.WebServiceException:未找到端口{http://tempuri.org/}WSHttpBinding_IDWService [英] javax.xml.ws.WebServiceException: Port {http://tempuri.org/}WSHttpBinding_IDWService not found

查看:178
本文介绍了javax.xml.ws.WebServiceException:未找到端口{http://tempuri.org/}WSHttpBinding_IDWService的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我正在使用Eclipse版本Helios和jdk 1.6.0_20,并且已经使用wsld2java并通过以下选项生成了.class文件:

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

我将生成的文件打包到一个.jar文件中,并将其添加到可以正常编译的项目中. 但是,当我尝试使用Web服务时,却出现了异常:

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()***;

任何想法都会非常感激.

解决方案

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

您的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'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.

解决方案

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.

这篇关于javax.xml.ws.WebServiceException:未找到端口{http://tempuri.org/}WSHttpBinding_IDWService的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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