Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php中为SABRE创建soap?_Php_Xml_Web Services_Soap_Sabre - Fatal编程技术网

如何在php中为SABRE创建soap?

如何在php中为SABRE创建soap?,php,xml,web-services,soap,sabre,Php,Xml,Web Services,Soap,Sabre,我是SOAP的新手,我想知道如何向saber服务器发出请求,但我没有成功,我需要帮助来发出以下请求 <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://w

我是SOAP的新手,我想知道如何向saber服务器发出请求,但我没有成功,我需要帮助来发出以下请求

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


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

看起来SoapClient想要的是WSDL本身的URL,而不是服务端点。对于GetReservationRQ,您可以在上找到它。

他用这种方式解决了我的问题

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

我做了一个修改,非常适合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);
    }
}
函数leerreservas($pnr){
错误报告(0);
//ini设置(“显示错误”,真);
//ini设置(“显示启动错误”,true);
$oDate=新日期时间();
$timestamp=$oDate->format('Y-m-d\Th:i:sP');
$timetolive=$oDate->add(新的日期间隔('PT1H'))->格式('Y-m-d\Th:i:sP');
$Locator=$pnr;
$BinarySecurityToken=selectoken();$endpoint=selecendpoint();
$sabre=sabredatosusaurio();
$namespace=”http://webservices.sabre.com/pnrbuilder/v1_15";
$test='1
客户
SWS
“.$sabre['ipcc']”
真菌转化
服务
getReservationRQ
“.$timestamp。”
“.$timetolive。”
“.$BinarySecurityToken。”
“.$Locator。”
有状态
定价信息
';
$location\u URL=$endpoint;
$action\u URL=$namespace;
$client=new SoapClient(null,数组('location'=>$location\u URL,'uri'=>,
'跟踪'=>1,);
试一试{
$order\u return=$client->\u doRequest($test、$location\u URL、$action\u URL,1);
//从这里得到回应
if(空($order_return)){
呼应“真空”;
}否则{
$xml2=reemplazo($order\u return);
$xml=simplexml\u load\u字符串($xml2,'simplexmlement',LIBXML\u NOCDATA);
$datos=json_decode(json_encode($xml),TRUE);
回声打印(datos);
}
}catch(SoapFault$异常){
var_dump(get_类($exception));
var_dump($例外);
}
}

从错误消息中,我可以说,目前没有SOAP API。也许您需要使用测试xml中的服务url启动客户机?()谢谢,如果我添加了名称空间路径和指向页面的链接并给出了答案,那么它就不起作用了,使用wsdl,创建新函数,xml已经恢复欢迎使用堆栈溢出。请用英语写下你的答案,因为堆栈溢出是一个错误。进行了修改,非常适合了解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);
    }
}