gpt4 book ai didi

调用 WSDL 服务时出现 javax.xml.ws.WebServiceException

转载 作者:行者123 更新时间:2023-12-01 06:10:34 27 4
gpt4 key购买 nike

我希望使用 Travelport Universal API 来开发航类预订系统,因此我使用了此 Travelport 开发人员官方链接作为引用:

Getting Started for Travelport Developers

正如文档所提到的:

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 Universal API 的 30 天试用凭证,所以我已经要求了这个,并且我已经收到了我的凭证,凭证由很多事情组成:

  • 通用API用户ID

  • 通用API密码

  • ProviderName 的分支代码 (TargetBranch) (ProviderCode)

  • 网址

    我测试了此凭据,并且我确信它们正在使用以下链接中的 php 文件进行工作:

    TravelPort Universal API - Ping Request with PHP

    我正在尝试使用 eclipse 在 JAVA 中运行 Travelport API,并且按照以下 url 中提到的步骤操作:

    Setting up to work with Universal API

    我遵循的配置步骤是:

  • 我已将 Apache CXF 与 Tomcat 链接

  • 我已使用此链接从 GitHub 导入项目:

    Travelport/travelport-uapi-tutorial

  • 我已使用从 Travelport 通用 API 电子邮件回复的 30 天试用凭证收到的 URL 编辑了 WSDLService 类中的 ENDPOINT_PREFIX

  • 我使用 WSDL 生成了客户端类,并尝试调用服务,

    但是出现错误:

    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 真实数据的响应吗?

  • 最佳答案

    生成 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);

    关于调用 WSDL 服务时出现 javax.xml.ws.WebServiceException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35961224/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com