java 调用 WSDL 服务时出现 javax.xml.ws.WebServiceException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35961224/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
javax.xml.ws.WebServiceException when invoking WSDL service
提问by Jad Chahine
I was looking to use the Travelport Universal API
to develop a Flight Booking System, so i have used this Travelport Developers official link as reference:
我想使用Travelport Universal API
来开发航班预订系统,所以我使用了这个 Travelport Developers 官方链接作为参考:
Getting Started for Travelport Developers
As the documentation referred:
正如文档中提到的:
Travelport Universal API offers an array of travel content for air, hotel, car, and rail, including ancillaries (optional services). It also provides functionality to build complete traveler, agency, branch, and account profiles.
Travelport 通用 API 为航空、酒店、汽车和铁路提供了一系列旅行内容,包括辅助设备(可选服务)。它还提供了构建完整的旅行者、代理机构、分支机构和帐户资料的功能。
For be able to send requests and receive responses, we should ask for a 30-Day Trial Credentials for Travelport Universal API
, so i have asked for this and i have received my credentials, the credentials is composed about many things:
为了能够发送请求和接收响应,我们应该要求一个30-Day Trial Credentials for Travelport Universal API
,所以我已经要求了这个并且我已经收到了我的凭据,凭据由许多内容组成:
I test this credentials, and i am sure they are working using a php file from the link below:
TravelPort Universal API - Ping Request with PHP
I am trying to run the Travelport API in JAVA using eclipse, and i follow the steps mentioned in the below url:
Setting up to work with Universal API
The configurations steps that i followed are :
我测试了这个凭据,我确定他们正在使用以下链接中的 php 文件工作:
TravelPort 通用 API - 使用 PHP 进行 Ping 请求
我正在尝试使用 Eclipse 在 JAVA 中运行 Travelport API,并且我按照以下 url 中提到的步骤操作:
我遵循的配置步骤是:
But a error appears:
Exception in thread "main" javax.xml.ws.WebServiceException: Could not send Message.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:150)
at $Proxy48.service(Unknown Source)
at com.travelport.service.system_v9_0.SystemPingPortType_SystemPingPort_Client.main(SystemPingPortType_SystemPingPort_Client.java:55)
Caused by: org.apache.cxf.transport.http.HTTPException: HTTP response '404: Not Found' when communicating with http://localhost:8080/kestrel/SystemService
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.doProcessResponseCode(HTTPConduit.java:1600)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1607)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1551)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1348)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:651)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:324)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:277)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:139)
... 2 more
Can anyone support me with the required steps that i should do for be able to test the Travelport API, so i can send requests and receive responses from the real data of Travelport?
但是出现一个错误:
Exception in thread "main" javax.xml.ws.WebServiceException: Could not send Message.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:150)
at $Proxy48.service(Unknown Source)
at com.travelport.service.system_v9_0.SystemPingPortType_SystemPingPort_Client.main(SystemPingPortType_SystemPingPort_Client.java:55)
Caused by: org.apache.cxf.transport.http.HTTPException: HTTP response '404: Not Found' when communicating with http://localhost:8080/kestrel/SystemService
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.doProcessResponseCode(HTTPConduit.java:1600)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1607)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1551)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1348)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:651)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:324)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:277)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:139)
... 2 more
任何人都可以为我提供测试 Travelport API 所需的步骤,以便我可以发送请求并接收来自 Travelport 真实数据的响应吗?
回答by gavenkoa
You need to alter connection endpoint after generation of java classes. At runtime this can be done with:
您需要在生成 java 类后更改连接端点。在运行时,这可以通过以下方式完成:
String endpoint = "https://emea.universal-api.travelport.com/B2BGateway/connect/uAPI";
BindingProvider provider = (BindingProvider) port;
Map<String, Object> reqCtx = provider.getRequestContext();
String connUrl = endpoint.endsWith("/")
? endpoint + connUrlSuffix
: endpoint + "/" + connUrlSuffix;
reqCtx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, connUrl);
回答by aventurin
It seems that you try to connect to localhost on port 8080, but there's no service running.
您似乎尝试在端口 8080 上连接到 localhost,但没有运行任何服务。