Skip Navigation

Accessing Sabre Web Services

You need a working Red App project with an Activator class.

  1. Using Eclipse, add the following required dependencies:

    • com.sabre.edge.cf.core

    • com.sabre.edge.cf.model

    • com.sabre.edge.cf.sws

  2. Create a request object for Sabre Web Services.

    SWSRequest request = new SWSRequest();

    Set the following two fields for a request.

    The action field represents the action to perform. You can set the action with the SWSRequest.setAction(String action) method.

    The payload field is org.w3c.dom.Document.

    You can find both the action values and the corresponding XML formats for payloads in the Sabre Web Services developer documentation.

    Note
    The action values for consuming Sabre Web Services differ from the action values for using markup services.

    request.setAction(String action)

    request.setPayload(Document payload);

  3. Add the following Java code to consume this service.

    1. Obtain a reference to ISRWCommunication service:

      ISRWCommunication com = Activator.getDefault().getServiceReference(ISRWCommunication.class);
    2. Create an instance of SWSServiceClient class and call send() method with an instance of SWSRequest class.

      SWSServiceClient client = new SWSServiceClient(com);
      ClientResponse <SWSResponse> rsp = client.send(request);
    3. Retrieve a response to ClientResponse<SWSResponse> reference.This class provides simple methods isSuccess() to check for status,getErrors() retrieving errors (if occurred) and getPayload() to obtain a response.

      if (rsp.isSuccess())
      {
          SWSResponse response = rsp.getPayload();
          Document doc = response.getResponse();
      }
    4. Add an Authorization entry to redapp.xml. Your authorization entry must include the name/action element/attribute combination to pass the action code of the request for the specific Sabre Web Services that your Red App calls.

Accessing Rest2SG Services - REST

You need a working Red App project with an Activator class.

  1. Using Eclipse, add the following required dependencies:

    • com.sabre.edge.cf.core

    • com.sabre.edge.cf.model

    • com.sabre.edge.cf.rest2sg

  2. Create a request object for Rest2SgService

    Rest2SgRequest request = new Rest2SgRequest();

    Set the following two fields for a request.

    The url field represents the path to service to perform with optional query string. The url is path taken from Sabre Dev Studio for specific service and updated with mandatory and optional parameters. Path may contain parameters which are enclosed by brackets like in following example:
    /v1/historical/flights/{destination}/seasonality.
    Those parameters must be replaced with proper values. Additional parameters can be added as query strings like in following example:
    /v1/historical/flights/DFW/seasonality?pointofsalecountry=US.
    For more details please follow documentation at Sabre Dev Studio about specific service. Each url used by Red App must have corresponding Authorization entry in redapp.xml file. You can set the path with the Rest2SgRequest.setPath(String path) method.

    The httpMethod field represents the HTTPMethod of request to service to perform. You can set the HTTPMethod with the Rest2SgRequest.setHttpMethod(HTTPMethod httpMethod) method.

    The authTokenType field represents the authentication token type used by service to perform. You can set the auth token type with the Rest2SgRequest.setAuthTokenType(cwAuthTokenType authTokenType) method.

    The payload field represents the payload for service to perform. The payload field is optional except PUT and POST Http methods for which is required and TRACE for which is forbidded. You can set the payload with the Rest2SgRequest.setPayload(String payload) method.

    The contentType field represents the content type of request to service to perform. It must be set when the payload is provided. You can set the content type with the Rest2SgRequest.setContentType(String contentType) method.

    The headers field represents the headers that will be set in HTTP request. You can set them using Rest2SgRequest.setHeaders(String headers). String has to be in JSON-string format, ex. "{\"header1\":\"value\"}".

    You can find both the action values and the corresponding formats for payloads in the Sabre Web Services developer documentation.

    Note
    The action values for consuming Sabre Web Services differ from the action values for using markup services.
    request.setUrl("/v1/historical/flights/DFW/seasonality?pointofsalecountry=US");
    request.setHttpMethod(HTTPMethod.POST);
    request.setAuthTokenType(AuthTokenType.SESSIONLESS);
    request.setPayload(payload);
    request.setContentType("application/json");
  3. Add the following Java code to consume this service.

    1. Obtain a reference to ISRWCommunication service:

      ISRWCommunication com = Activator.getDefault().getServiceReference(ISRWCommunication.class);
    2. Create an instance of Rest2SgServiceClient class and call send() method with an instance of Rest2SgRequest class.

      Rest2SgServiceClient client = new Rest2SgServiceClient(com);
      ClientResponse <Rest2SgResponse> rsp = client.send(request);
    3. Retrieve a response to ClientResponse<Rest2SgResponse> reference.This class provides simple methods isSuccess() to check for status,getErrors() retrieving errors (if occurred) and getPayload() to obtain a response.

      if (rsp.isSuccess())
      {
          Rest2SgResponse response = rsp.getPayload();
          String json = response.getResponse();
      }
  4. Add an Authorization entry to redapp.xml. Your authorization entry must include the name/action element/attribute combination to pass the url of the request for the specific Sabre Web Services that your Red App calls. The name attribute of Action entry is exact path value presented in Sabre Dev Studio for specific service, like in following example:

    <Authorization name="com.sabre.edge.cf.rest2sg.Rest2Sg">
        <Action name="/v1/lists/utilities/aircraft/equipment" threshold="1" />
        <Action name="/v1/historical/flights/{destination}/seasonality" threshold="1" />
    </Authorization>