2

I am trying to create session using SessionCreateRQ soap service. which is first step of using sabre soap services where I have created object of HttpWebRequest with end point https://sws3-crt.cert.sabre.com and passing the request xml copied from sabre documentation to create a session

 public HttpWebRequest CreateWebRequest()
        {
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(@"https://sws3-crt.cert.sabre.com");
            webRequest.Headers.Add(@"SOAP:Action");
            webRequest.ContentType = "text/xml;charset=\"utf-8\"";
            webRequest.Accept = "text/xml";
            webRequest.Method = "POST";
            return webRequest;
        }

public void Execute()
        {
            HttpWebRequest request = CreateWebRequest();
            XmlDocument soapEnvelopeXml = new XmlDocument();
            soapEnvelopeXml.LoadXml(@"<?xml version=""1.0"" encoding=""UTF-8""?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:eb=""http://www.ebxml.org/namespaces/messageHeader"" xmlns:xlink=""http://www.w3.org/1999/xlink"" xmlns:xsd=""http://www.w3.org/1999/XMLSchema"">
    <SOAP-ENV:Header>
        <eb:MessageHeader SOAP-ENV:mustUnderstand=""1"" eb:version=""1.0"">
            <eb:ConversationId/>
            <eb:From>
                <eb:PartyId type=""urn:x12.org:IO5:01"">999999</eb:PartyId>
            </eb:From>
            <eb:To>
                <eb:PartyId type=""urn:x12.org:IO5:01"">123123</eb:PartyId>
            </eb:To>
            <eb:CPAId>IPCC</eb:CPAId>
            <eb:Service eb:type=""OTA"">SessionCreateRQ</eb:Service>
            <eb:Action>SessionCreateRQ</eb:Action>
            <eb:MessageData>
                <eb:MessageId>1000</eb:MessageId>
                <eb:Timestamp>2016-03-09T11:15:12Z</eb:Timestamp>
                <eb:TimeToLive>2016-03-10T11:15:12Z</eb:TimeToLive>
            </eb:MessageData>
        </eb:MessageHeader>
        <wsse:Security xmlns:wsse=""http://schemas.xmlsoap.org/ws/2002/12/secext"" xmlns:wsu=""http://schemas.xmlsoap.org/ws/2002/12/utility"">
            <wsse:UsernameToken> 
                <wsse:Username>myUserName</wsse:Username>
                <wsse:Password>myPasswordenter code here</wsse:Password>
                <Organization>IPCC</Organization>
                <Domain>DEFAULT</Domain> 
            </wsse:UsernameToken>
        </wsse:Security>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <eb:Manifest SOAP-ENV:mustUnderstand=""1"" eb:version=""1.0"">
            <eb:Reference xmlns:xlink=""http://www.w3.org/1999/xlink"" xlink:href=""cid:rootelement"" xlink:type=""simple""/>
        </eb:Manifest>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>");

            using (Stream stream = request.GetRequestStream())
            {
                soapEnvelopeXml.Save(stream);
            }

            using (WebResponse response = request.GetResponse())
            {
                using (StreamReader rd = new StreamReader(response.GetResponseStream()))
                {
                    string soapResult = rd.ReadToEnd();
                    Console.WriteLine(soapResult);
                }
            }
        }

but getting 500 error code on request.GetResponse(). Is there any problem with code or end point is wrong if its wrong please provide correct one.

2 Answers2

1

On the assumption your using visual studio use web reference rather than service reference. Service references seem create a bad proxy representation of the classes.

You can do this by right clicking on service reference.

Go t to advanced options in the bottom right and then clicking on add Web Reference. Then input the WSDL URL and consume the webservice from there.

Then something like this on the assumption you name your proxy class namespace SabreSesh should work.

Also might be worth noting that when generating proxy classes from sabre WSDL's sometimes you have to do a search and replace of the Reference.cs of and replace [][] with [] as it has a habit of translating the list and array schemas to double arrays when it shouldn't.

     public SabreSessionInfo sabreCreateSession(string user, string pass, string pseudo, string iPseudo, bool doGetAirVendors)
                {
                    SabreSessionInfo inf = new SabreSessionInfo();

                    try
                    {
                        userName = user;
                        password = pass;

                        iPCC = iPseudo;
                        PCC = pseudo;

                        string domain = "DEFAULT";

                        DateTime dt = DateTime.UtcNow;
                        string tstamp = dt.ToString("s") + "Z";

                        SabreSesh.MessageHeader msgHeader = new SabreSesh.MessageHeader();

                        msgHeader.ConversationId = "TestSession";       // Set the ConversationId

                        SabreSesh.From from = new SabreSesh.From();
                        SabreSesh.PartyId fromPartyId = new SabreSesh.PartyId();
                        SabreSesh.PartyId[] fromPartyIdArr = new SabreSesh.PartyId[1];
                        fromPartyId.Value = "WebServiceClient";
                        fromPartyIdArr[0] = fromPartyId;
                        from.PartyId = fromPartyIdArr;
                        msgHeader.From = from;

                        SabreSesh.To to = new SabreSesh.To();
                        SabreSesh.PartyId toPartyId = new SabreSesh.PartyId();
                        SabreSesh.PartyId[] toPartyIdArr = new SabreSesh.PartyId[1];
                        toPartyId.Value = "WebServiceSupplier";
                        toPartyIdArr[0] = toPartyId;
                        to.PartyId = toPartyIdArr;
                        msgHeader.To = to;

                        //Add the value for eb:CPAId, which is the IPCC. 
                        //Add the value for the action code of this Web service, SessionCreateRQ.

                        msgHeader.CPAId = iPCC;
                        msgHeader.Action = "SessionCreateRQ";
                        SabreSesh.Service service = new SabreSesh.Service();
                        service.Value = "SessionCreate";
                        msgHeader.Service = service;

                        SabreSesh.MessageData msgData = new SabreSesh.MessageData();
                        msgData.MessageId = "mid:20001209-133003-2333@clientofsabre.com1";
                        msgData.Timestamp = tstamp;
                        msgHeader.MessageData = msgData;

                        SabreSesh.Security security = new SabreSesh.Security();
                        SabreSesh.SecurityUsernameToken securityUserToken = new SabreSesh.SecurityUsernameToken();
                        securityUserToken.Username = userName;
                        securityUserToken.Password = password;
                        securityUserToken.Organization = iPCC;
                        securityUserToken.Domain = domain;
                        security.UsernameToken = securityUserToken;

                        SabreSesh.SessionCreateRQ req = new SabreSesh.SessionCreateRQ();
                        SabreSesh.SessionCreateRQPOS pos = new SabreSesh.SessionCreateRQPOS();
                        SabreSesh.SessionCreateRQPOSSource source = new SabreSesh.SessionCreateRQPOSSource();
                        source.PseudoCityCode = iPCC;
                        pos.Source = source;
                        req.POS = pos;

                        SabreSesh.SessionCreateRQService serviceObj = new SabreSesh.SessionCreateRQService();
                        serviceObj.MessageHeaderValue = msgHeader;
                        serviceObj.SecurityValue = security;


                        lock (lockObject)
                        {

                            SabreSesh.SessionCreateRS resp = new SabreSesh.SessionCreateRS();
                            try
                            {
                                resp = serviceObj.SessionCreateRQ(req); // Send the request
                            }
                            catch (Exception ex)
                            {
                                System.Diagnostics.Debug.WriteLine(ex.ToString());
                            }


                        }





                        inf.conversationID = msgHeader.ConversationId;
                        inf.sabreToken = security.BinarySecurityToken;


                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.ToString());
                    }

            return inf;
            }

 public class SabreSessionInfo
    {
        public string conversationID { get; set;}
        public string sabreToken { get; set; }

        public SabreSessionInfo()
        {
            conversationID = "";
            sabreToken = "";
        }
    }
Mr Harno
  • 308
  • 1
  • 7
  • PS you don't need the Lock {} around the service call. – Mr Harno Mar 10 '16 at 13:29
  • Generating proxy class by adding Web Reference really worked and thanks for your code sample :) Can you please help finding wsdl url for test environment I have searched every where but unable to get wsdl for test environment currently i am getting authentication failed because wsdl used is of production and i have test account if this is not case please correct me – Imran Ahmed Soomro Mar 10 '16 at 16:42
  • It's been about 8 years since I played around in the Cert environment so over to Sabre for this one as I can't see a cert create session WSDL in existence. I would try editing the URL in the reference.cs for the proxy class and prefixing with https://sws-crt.cert.sabre.com rather than http://webservices.sabre.com or something like that. – Mr Harno Mar 11 '16 at 09:59
  • What I would try is in the reference.CS change the binding target URL below to point to the cert URL :- [System.Web.Services.WebServiceBindingAttribute(Name="SessionCreateSoapBinding", Namespace="https://webservices.sabre.com/websvc")] – Mr Harno Mar 11 '16 at 10:28
  • It *is* possible to add individual service references in Visual Studio 2015 at least. The problem is that Sabre uses non-standard BPEL constructs that predate the WS-Interoperability standards. Adding a Web Reference is a bad idea, because that stack is ancient and *not* actively developed. – Panagiotis Kanavos Dec 13 '16 at 14:03
0

There's an existing .NET sample in Dev studio, using proxy code/classes:

https://developer.sabre.com/docs/read/soap_basics/getting_started

Hope that helps.

fcarreno
  • 701
  • 4
  • 8
  • 1
    I have tried this code also using proxy class but seems like proxy class is not properly generated because followoing object is not created due to missing class and i think this class should also be created by adding service reference **SessionCreateRQService serviceObj = new SessionCreateRQService();** – Imran Ahmed Soomro Mar 10 '16 at 04:38
  • @fcarreno what this document says, in essence, is that Sabre doesn't follow the standards and good luck. The sample uses the ancient ASMX proxy. It *is* possible to generate WCF proxies by adding service references to individual WSDL URLs in VS 2015 – Panagiotis Kanavos Dec 13 '16 at 14:06