Jerson Olaya
Jerson Olaya

Reputation: 7

how can i create a soap in php for SABRE?

I am new to the world of SOAP, I want to know how I can make a request to the saber servers, but I have not succeeded, I need help to make the following request.

<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:From>
                <eb:PartyId>Client</eb:PartyId>
            </eb:From>
            <eb:To>
                <eb:PartyId>SWS</eb:PartyId>
            </eb:To>
            <eb:CPAId>3DBJ</eb:CPAId>
            <eb:ConversationId>MyConversationID</eb:ConversationId>
            <eb:Service>Service</eb:Service>
            <eb:Action>getReservationRQ</eb:Action>
            <eb:MessageData>
                <eb:MessageId></eb:MessageId>
                <eb:Timestamp></eb:Timestamp>
            </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:BinarySecurityToken>Shared/IDL:IceSess\/SessMgr:1\.0.IDL/Common/!ICESMS\/RESE!ICESMSLB\/RES.LB!1</wsse:BinarySecurityToken>
        </wsse:Security>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns7:GetReservationRQ xmlns:ns7="http://webservices.sabre.com/pnrbuilder/v1_15" Version="1.15.0">
            <ns7:Locator>JXJ</ns7:Locator>
            <ns7:RequestType>Stateful</ns7:RequestType>
            <ns7:ReturnOptions UnmaskCreditCard="true">
                <ns7:SubjectAreas>
                    <ns7:SubjectArea>PRICING_INFORMATION</ns7:SubjectArea>
                </ns7:SubjectAreas>
            </ns7:ReturnOptions>
        </ns7:GetReservationRQ>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

This is my XML that I sent in postman and it generates a result but when I do it in PHP it generates an error.

SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://webservices.havail.sabre.com' : Document is empty





$client  = new SoapClient("https://webservices.havail.sabre.com");

$checkVatParameters =array( 
'BinarySecurityToken' => 'Shared/IDL:IceSess\/SessMgr:1\.0.IDL/Common/!ICESMS\/RESE!ICESMSLB\/RES.LB!',
'Locator' => 'JXJ',
'RequestType'=>'Stateful',
'SubjectArea'=>'PRICING_INFORMATION'

);//variables

$result=$client->__getFunctions();
$result = $client->GetReservationRQ($checkVatParameters);
echo "REQUEST:\n" . $client->__getLastRequest() . "\n";

}

they only gave me a URL but it asks me WDSL

Upvotes: 0

Views: 481

Answers (3)

Jerson Olaya
Jerson Olaya

Reputation: 7

I made a modification and works perfectly for PHP SOAP.

function leerreservas($pnr) {
    error_reporting(0);
    //ini_set('display_errors', true);
    //ini_set('display_startup_errors', true);
    $oDate = new DateTime();
    $timestamp = $oDate->format('Y-m-d\Th:i:sP');
    $timetolive = $oDate->add(new DateInterval('PT1H'))->format('Y-m-d\Th:i:sP');
    $Locator=$pnr;
    $BinarySecurityToken=selectokken(); $endpoint=selecendpoint();
    $sabre=sabredatosusuario();
    $namespaces="http://webservices.sabre.com/pnrbuilder/v1_15";

    $test = '<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:From>
                    <eb:PartyId>Client</eb:PartyId>
                </eb:From>
                <eb:To>
                    <eb:PartyId>SWS</eb:PartyId>
                </eb:To>
                <eb:CPAId>'.$sabre['ipcc'].'</eb:CPAId>
                <eb:ConversationId>MyConversationID</eb:ConversationId>
                <eb:Service>Service</eb:Service>
                <eb:Action>getReservationRQ</eb:Action>
                <eb:MessageData>
                    <eb:MessageId>'.$timestamp.'</eb:MessageId>
                    <eb:Timestamp>'.$timetolive.'</eb:Timestamp>
                </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:BinarySecurityToken>'.$BinarySecurityToken.'</wsse:BinarySecurityToken>
            </wsse:Security>
        </SOAP-ENV:Header>
        <SOAP-ENV:Body>
            <ns7:GetReservationRQ xmlns:ns7="'.$namespaces.'" Version="1.15.0">
                <ns7:Locator>'.$Locator.'</ns7:Locator>
                <ns7:RequestType>Stateful</ns7:RequestType>
                <ns7:ReturnOptions UnmaskCreditCard="true">
                    <ns7:SubjectAreas>
                        <ns7:SubjectArea>PRICING_INFORMATION</ns7:SubjectArea>
                    </ns7:SubjectAreas>
                </ns7:ReturnOptions>
            </ns7:GetReservationRQ>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>';

    $location_URL = $endpoint;
    $action_URL = $namespaces;
    $client = new SoapClient(null, array( 'location' => $location_URL, 'uri' => "",
    'trace' => 1, ));

    try {
        $order_return = $client->__doRequest($test,$location_URL,$action_URL,1); 
        //Get response from here
        if (empty($order_return)) {
            echo "vacio";
        } else {
            $xml2 = reemplazo($order_return);
            $xml = simplexml_load_string($xml2, 'SimpleXMLElement', LIBXML_NOCDATA);
            $datos = json_decode(json_encode($xml), TRUE);
            echo print_r($datos);
        }
    } catch (SoapFault $exception) {
        var_dump(get_class($exception));
        var_dump($exception);
    }
}

Upvotes: -1

Jerson Olaya
Jerson Olaya

Reputation: 7

he solved my problem in this way

    $location_URL = "https://sws-crt.cert.havail.sabre.com";
    $action_URL = "http://webservices.sabre.com/pnrbuilder/v1_15";

    $client = new SoapClient(null, array(
    'location' => $location_URL,
    'uri'      => "",
    'trace'    => 1,
    ));

    $order_return = $client->__doRequest($xml,$location_URL,$action_URL,1);

Upvotes: 1

AGabriel
AGabriel

Reputation: 31

It looks like the SoapClient is wanting the URL for the WSDL itself, not the service endpoint. For GetReservationRQ, you can find this at http://files.developer.sabre.com/wsdl/sabreXML1.0.00/pnrservices/GetReservation_1.19.0.wsdl.

Upvotes: 1

Related Questions