I'm trying to call the web service here: http://publicbetawebservices.hotel.de/V2_8/FreeHotelSearchWebService.svc?WSDL
I've generated proxy classes using wsimport with JDK1.6.0_29. My wsimport command line is:
wsimport.exe" -keep -B-XautoNameResolution -d E:\mapov\mapov-dev\shared\hotel_info\ http://publicbetawebservices.hotel.de/V2_8/FreeHotelSearchWebService.svc?WSDL
I'm using the following code to attempt to call the service:
QName qName = new QName("http://webservices.hotel.de/V2_8", "FreeHotelSearchWebService");
FreeHotelSearchWebService service = new FreeHotelSearchWebService(new URL("http://publicbetawebservices.hotel.de/V2_8/FreeHotelSearchWebService.svc"), qName);
IFreeHotelSearchWebService sws = service.getBasicHttpBindingIFreeHotelSearchWebService();
String version = sws.getWebservicesVersion();
System.out.println("Hotel.info web service version: " + version);
However I get the following exception:
Exception in thread "main" javax.xml.ws.WebServiceException: Unsupported endpoint address: at com.sun.xml.ws.api.pipe.TransportTubeFactory.create(TransportTubeFactory.java:148) at com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:134) at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:641) at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:600) at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:585) at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:482) at com.sun.xml.ws.client.Stub.process(Stub.java:323) at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:161) at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:113) at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:93) at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:144) at $Proxy42.getWebservicesVersion(Unknown Source)
In most examples I've seen the generated code includes a getPort() method but that hasn't been generated for this class. Is my code wrong or do I need to run wsimport differently? I've also tried calling the FreeHotelWebService constructor without the parameters which yields the same exception.
1条答案
按热度按时间rsaldnfx1#
根据Justin的问题和Tug's Blog重新生成一个没有答案的问题:
JAX-WS:如何在运行时配置服务端点?
在部署Web服务客户端时,您经常需要更改在代码生成过程中设置的服务的端点。这篇简短的文章解释了如何在运行时在客户端代码中设置和更改端点。
有两种方法可以实现这一点:
使用绑定提供程序设置端点URL
第一种方法是使用以下代码更改BindingProvider.(端口)的ENDPOINT_ADDRESS_PROPERTY属性值:
使用WSDL获取端点URL
另一部分是在创建服务时设置WSDL。服务将使用位于WSDL端口-SOAP端点-中的值。只需使用以下代码即可完成此操作:
请注意,在Glassfish中,与许多Web服务环境一样,WSDL可以基于用于获取WSDL的URL动态生成端点URL。使用此方法,您还可以动态更改Soap端点(如果与生产环境的网络配置兼容)。