javax.xml.ws.WebServiceException when invoking WSDL service

Jad Chahine picture Jad Chahine · Mar 12, 2016 · Viewed 21.9k times · Source

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:

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.

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:

  • Universal API User ID
  • Universal API Password
  • Branch Code (TargetBranch) for ProviderName (ProviderCode)
  • A URL
  • 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 :

  • I have linked the Apache CXF with Tomcat
  • I have imported the project from GitHub using this link:
  • Travelport/travelport-uapi-tutorial

  • I have edited the ENDPOINT_PREFIX in WSDLService class with the url received from the 30-Day Trial Credentials for Travelport Universal API email response
  • I generated the client classes using WSDL, and i tried to invoke the service,
  • 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?

    Answer

    gavenkoa picture gavenkoa · Mar 18, 2020

    You need to alter connection endpoint after generation of java classes. At runtime this can be done with:

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