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

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值