Search code examples
web-serviceswsdlsabre

Authentication Error (Authentication Failed) Using Sabre Soap Message


I am using soap service to authenticate request by sabre as in the document https://developer.sabre.com/docs/read/soap_basics/Authentication. I generate the proxy classes using wsdl. i put authentication credential in the code. This is my Code for test purpose:

using ConsoleApplication1.SessionReference1;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            try
            {

                // Set user information, including security credentials and the IPCC.
                string username = "my-username";
                string password = "my-password";
                string ipcc = "not-understand";
                string domain = "EXT";

                string temp = Environment.GetEnvironmentVariable("tmp");    // Get temp directory
                string PropsFileName = temp + "/session.properties";        // Define dir and file name
                DateTime dt = DateTime.UtcNow;
                string tstamp = dt.ToString("s") + "Z";

                //Create the message header and provide the conversation ID.
                MessageHeader msgHeader = new MessageHeader();
                msgHeader.ConversationId = "TestSession";       // Set the ConversationId

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

                To to = new To();
                PartyId toPartyId = new PartyId();
                PartyId[] toPartyIdArr = new 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";
                Service service = new Service();
                service.Value = "SessionCreate";
                msgHeader.Service = service;

                MessageData msgData = new MessageData();
                msgData.MessageId = "mid:[email protected]";
                msgData.Timestamp = tstamp;
                msgHeader.MessageData = msgData;

                Security security = new Security();
                SecurityUsernameToken securityUserToken = new SecurityUsernameToken();
                securityUserToken.Username = username;
                securityUserToken.Password = password;
                securityUserToken.Organization = ipcc;
                securityUserToken.Domain = domain;
                security.UsernameToken = securityUserToken;


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

                SessionCreatePortTypeClient s = new SessionCreatePortTypeClient();
                SessionCreateRS resp = s.SessionCreateRQ(ref msgHeader, ref security, req);

                //SessionCreateRQService serviceObj = new SessionCreateRQService();
                //serviceObj.MessageHeaderValue = msgHeader;
                //serviceObj.SecurityValue = security;
                //SessionCreateRS rs = new SessionCreateRS();

                //SessionCreateRS  = serviceObj.SessionCreateRQ(req);   // Send the request

                if (resp.Errors != null && resp.Errors.Error != null)
                {
                    Console.WriteLine("Error : " + resp.Errors.Error.ErrorInfo.Message);
                }

                else
                {
                  //  msgHeader = serviceObj.MessageHeaderValue;
                  //  security = serviceObj.SecurityValue;

                    Console.WriteLine("**********************************************");
                    Console.WriteLine("Response of SessionCreateRQ service");
                    Console.WriteLine("BinarySecurityToken returned : " + security.BinarySecurityToken);
                    Console.WriteLine("**********************************************");
                    string ConvIdLine = "convid=" + msgHeader.ConversationId;   // ConversationId to a string
                    string TokenLine = "securitytoken=" + security.BinarySecurityToken; // BinarySecurityToken to a string
                    string ipccLine = "ipcc=" + ipcc;   // IPCC to a string

                 //   File.Delete(PropsFileName);       // Clean up
                  //  TextWriter tw = new StreamWriter(PropsFileName);  // Create & open the file
                   // tw.WriteLine(DateTime.Now);       // Write the date for reference
                  //  tw.WriteLine(TokenLine);      // Write the BinarySecurityToken
                  //  tw.WriteLine(ConvIdLine);     // Write the ConversationId
                  //  tw.WriteLine(ipccLine);       // Write the IPCC
                  //  tw.Close();

                    //Console.Read();
                }

            }
            catch (Exception e)
            {
                Console.WriteLine("Exception Message : " + e.Message);
                Console.WriteLine("Exception Stack Trace : " + e.StackTrace);
                Console.Read();
            }


        }
    }
}

Please Help me


Solution

  • I didn't check the sequence of the code in detail, but checking the values you set for organization and domain:

    string ipcc = "not-understand";
    string domain = "EXT";
    

    Unless you did it intentionally to mask the values, you should have received your ipcc value from Sabre after getting a SOAP webservices account. The value for SOAP APIs domain is normally "DEFAULT".

    Registering on dev studio only gives you REST test credentials (not SOAP), so you can use this form to request SOAP test credentials: https://developer.sabre.com/contact

    Finally, I don't quite see the environment/target url you're using to test the SessionCreate service...CERT one is: https://sws3-crt.cert.sabre.com/