【问题标题】:how can i create a soap in php for SABRE?我如何在 php 中为 SABRE 创建一个肥皂?
【发布时间】:2019-07-24 14:38:08
【问题描述】:

我是 SOAP 世界的新手,我想知道如何向 sabre 服务器发出请求,但我没有成功,我需要帮助才能发出以下请求。

<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>

这是我在邮递员中发送的 XML,它会生成一个结果,但是当我在 PHP 中执行此操作时会生成一个错误。

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";

}

他们只给了我一个 URL,但它问我 WDSL

【问题讨论】:

标签: php xml web-services soap sabre


【解决方案1】:

看起来 SoapClient 想要 WSDL 本身的 URL,而不是服务端点。对于 GetReservationRQ,您可以在 http://files.developer.sabre.com/wsdl/sabreXML1.0.00/pnrservices/GetReservation_1.19.0.wsdl 找到它。

【讨论】:

  • 它不起作用,使用那个 wsdl,创建新函数并且 xml 已经恢复
【解决方案2】:

他就这样解决了我的问题

    $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);

【讨论】:

    【解决方案3】:

    我做了一个修改,完美适用于 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);
        }
    }
    

    【讨论】:

    • 欢迎来到 Stack Overflow。请用英文写下你的答案,因为 Stack Overflow 是English only site
    • 进行了修改,完美适用于 KNOW PHP SOAP。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多