Travelport / travelport-uapi-tutorial

The travelport-uapi-tutorial is a Java project for Universal API that will help you connect and code a standard workflow including Air and Hotel.
45 stars 34 forks source link

Getting Error Error 500: java.lang.StringIndexOutOfBoundsException #739

Open AbhinavSharma96 opened 4 years ago

AbhinavSharma96 commented 4 years ago

I am sending XML Request thought asp.net but i am getting error message (Error 500: java.lang.StringIndexOutOfBoundsException) in web response. Blow is my Request Response Log. Please help me what is missing in this.

string xmlMessage = "< soapenv:Header ></ soapenv:Header >< soapenv:Body >< air:LowFareSearchReq xmlns:air = 'http://www.travelport.com/schema/air_v49_0' xmlns: com = 'http://www.travelport.com/schema/common_v49_0' AuthorizedBy = 'user' SolutionResult = 'true' TargetBranch = 'P7128836' TraceId = 'trace' >< com:BillingPointOfSaleInfo OriginApplication = 'UAPI' />< air:SearchAirLeg >< air:SearchOrigin >< com:Airport Code = 'LKO' /></ air:SearchOrigin >< air:SearchDestination >< com:Airport Code = 'BLR' /></ air:SearchDestination >< air:SearchDepTime PreferredTime = '2020-02-17' /></ air:SearchAirLeg >< air:AirSearchModifiers >< air:PreferredProviders >< com:Provider Code = '1G' /></ air:PreferredProviders ></ air:AirSearchModifiers >< com:SearchPassenger BookingTravelerRef = '1tretetetretert' Code = 'ADT' />< com:SearchPassenger BookingTravelerRef = '1tretetetfsdretert' Code = 'CHD' />< com:SearchPassenger BookingTravelerRef = '1tretetetfsdretert' Code = 'INF' /></ air:LowFareSearchReq ></ soapenv:Body ></ soapenv:Envelope > "; string url = "https://apac.universal-api.pp.travelport.com/B2BGateway/connect/uAPI/AirService";

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    string svcCredentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes("Universal API/uAPI1108823219-47922f7f" + ":" + "XXXXXXXX"));
    request.Headers.Add("Authorization", "Basic " + svcCredentials);
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
    byte[] requestInFormOfBytes = System.Text.Encoding.ASCII.GetBytes(xmlMessage);

    request.Method = "POST";
    request.ContentType = "application/XML";
    request.Timeout = 90000;
    request.ContentLength = requestInFormOfBytes.Length;
    Stream requestStream = request.GetRequestStream();
    requestStream.Write(requestInFormOfBytes, 0, requestInFormOfBytes.Length);
    requestStream.Close(); 
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    StreamReader respStream = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);
    string receivedResponse = respStream.ReadToEnd();
    Console.WriteLine(receivedResponse);
    respStream.Close();
    response.Close();

in web Response(receivedResponse) it gives Error 500: java.lang.StringIndexOutOfBoundsException

vivekjyotipramanik commented 4 years ago

Hi AbhinavSharma96,

Could you please try with the below request. Thanks.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ses="http://www.travelport.com/soa/common/security/SessionContext_v1" xmlns:air="http://www.travelport.com/schema/air_v49_0" xmlns:com="http://www.travelport.com/schema/common_v49_0">
  <soapenv:Header>
  </soapenv:Header>
  <soapenv:Body>
    <air:LowFareSearchReq xmlns:air = "http://www.travelport.com/schema/air_v49_0" xmlns:com = "http://www.travelport.com/schema/common_v49_0" AuthorizedBy = "user" SolutionResult = "true" TargetBranch = "P7128836" TraceId = "trace">
      <com:BillingPointOfSaleInfo OriginApplication = "API"/>
      <air:SearchAirLeg>
        <air:SearchOrigin>
          <com:Airport Code="LKO"/>
        </air:SearchOrigin>
        <air:SearchDestination>
          <com:Airport Code="BLR"/>
        </air:SearchDestination>
        <air:SearchDepTime PreferredTime = "2020-02-17"/>
      </air:SearchAirLeg>
      <air:AirSearchModifiers>
        <air:PreferredProviders>
          <com:Provider Code="1G"/>
        </air:PreferredProviders>
      </air:AirSearchModifiers>
      <com:SearchPassenger BookingTravelerRef="1tretetetretert" Code="ADT"/>
      <com:SearchPassenger BookingTravelerRef="1tretetetfsdretert" Code="CHD"/>
      <com:SearchPassenger BookingTravelerRef="1tretetetfsdretert" Code="INF"/>
    </air:LowFareSearchReq>
  </soapenv:Body>
</soapenv:Envelope>