Reputation: 429
I'm trying to implement the new GetReservationRQ/RS API as the old TravelItineraryReadRQ is apparently being sunset in December 2018.
I am able to make the call and get a response, and all of the valid travel data is present in the XML payload, but I am unable to get Intellisense to show the items in the Item field of the proxy class. I maybe explaining that incorrectly so I have a few screenshots below.
I've tried digging through the reference.cs file created by the WSDL and I do see some differences in the way the object models are created between GetReservationRQ and TravelItinerarReadRQ, but I'm at a loss as to what to do about it.
Populated Object in debug mode showing all of the valid Reservation Items:
Intellisense showing item field without any other visible members:
EDIT 7/26/18
Thanks to Carlos' answer below, I got this working by implementing his changes. For future generations, here is my working code:
public class GetReservationReq
{
private GetReservationService service;
public GetReservationRS response;
public string xmlResponse;
public GetReservationReq()
{
//parameterless constructor for serializiation
}
public GetReservationReq(SessionToken token, string locator)
{
//MessageHeader
MessageHeader mHeader = new MessageHeader();
PartyId[] pId = { new PartyId() };
pId[0].Value = "SWS";
From from = new From();
from.PartyId = pId;
To to = new To();
to.PartyId = pId;
mHeader.Action = "getReservationRQ";
mHeader.Service = new Service()
{
Value = mHeader.Action
};
mHeader.ConversationId = token.conversationID;
mHeader.CPAId = token.ipcc;
mHeader.From = from;
mHeader.To = to;
mHeader.MessageData = new MessageData()
{
Timestamp = DateTime.UtcNow.ToString()
};
//Security
Security sec = new Security();
//Security1 sec = new Security1();
sec.BinarySecurityToken = token.securityToken;
//Service
service = new GetReservationService();
service.MessageHeaderValue = mHeader;
service.SoapVersion = System.Web.Services.Protocols.SoapProtocolVersion.Soap11;
service.SecurityValue = sec;
//create the request
GetReservationRQ req = new GetReservationRQ();
req.Version = "1.18.0";
req.RequestType = "Stateful"; //This indicates that we are looking to pull up an existing PNR
req.Locator = locator;
req.ReturnOptions = new ReturnOptions();
req.ReturnOptions.ViewName = "Full";
req.ReturnOptions.ResponseFormat = "STL";
try
{
//execute the response
response = service.GetReservationOperation(req);
//cast response items to usable Object
ReservationPNRB content = (ReservationPNRB)response.Item;
//testing - iterate through reservation elements and do stuff
foreach (var segment in content.OpenReservationElements.OpenReservationElement)
{
Console.WriteLine(segment.id + " - " + segment.type);
}
Console.Read();
//serialize the response for logging if necessary
xmlResponse = Serializer.toXML(response);
//serialize response for logging if necessary
using (StreamWriter myWriter = new StreamWriter(@"C:\SABRE_DATA\TMP\xmlItin.txt", true))
{
XmlSerializer mySerializer = new XmlSerializer(typeof(GetReservationRS));
mySerializer.Serialize(myWriter, response);
StringWriter myStringWriter = new StringWriter();
mySerializer.Serialize(myStringWriter, response);
xmlResponse = myStringWriter.ToString();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
throw;
}
}
}
Upvotes: 1
Views: 323
Reputation: 166
As you see in your last print screen the Item property is of type Object. That means that you need to cast it to the specific type you are expecting.
To find the valid types that can be returned in that property you need to go to reference.cs, in there you will see on the top of the property (as an attribute) the valid type of objects that the API can return in this property.
Upvotes: 1