如何使用Zend_Soap_Client将原始xml发送到SOAP服务器?

时间:2011-05-24 14:40:08

标签: zend-framework zend-soap

我正在努力将原始请求发送到SOAP服务器。我发现这样做的唯一方法是创建一个冗余的Zend_Soap_Client_Common以调用_dorequest。真的有必要吗?有没有其他方法将原始xml发送到服务器?

以下是代码:

    $client = new Zend_Soap_Client('http://212.170.239.71/appservices/ws/FrontendService?wsdl', 
                        array( 
                                'soap_version'=>SOAP_1_1 
                                ,'encoding' => 'UTF-8' 
                                ,'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_DEFLATE 
                                ,'location'=>'http://212.170.239.71/appservices/ws/FrontendService'

                        ) 
                ); 

    $location = 'http://212.170.239.71/appservices/ws/FrontendService';

    $request = '<?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  
        <soapenv:Body>  
                <hb:getHotelValuedAvail xmlns:hb="http://axis.frontend.hydra.hotelbeds.com" xsi:type="xsd:anyType">  
<HotelValuedAvailRQ echoToken="DummyEchoToken" sessionId="DummySessionId" xmlns="http://www.hotelbeds.com/schemas/2005/06/messages" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.hotelbeds.com/schemas/2005/06/messages HotelValuedAvailRQ.xsd">
    <Language>CAS</Language>
    <Credentials>
    <User>XXXXX</User>
    <Password>XXXXX</Password>
        </Credentials>
        <PaginationData pageNumber="1"/>
<ExtraParamList>
       <ExtendedData type="EXT_ORDER">
            <Name>ORDER_CONTRACT_PRICE</Name>
             <Value>ASC</Value>
        </ExtendedData>
</ExtraParamList>
        <CheckInDate date="20110809"/>
        <CheckOutDate date="20110811"/>
        <Destination code="LPA" type="SIMPLE">
            <ZoneList>
                 <Zone code="20" type="SIMPLE"/>
            </ZoneList>
    </Destination>
        <OccupancyList>
                <HotelOccupancy>
                        <RoomCount>1</RoomCount>
                        <Occupancy>
                                <AdultCount>2</AdultCount>
                                <ChildCount>0</ChildCount>
                        </Occupancy>
                </HotelOccupancy>
        </OccupancyList>
</HotelValuedAvailRQ>
                </hb:getHotelValuedAvail>  
        </soapenv:Body>  
</soapenv:Envelope>'; 

        $clientCommon = new Zend_Soap_Client_Common($client, 'http://212.170.239.71/appservices/ws/FrontendService?wsdl', 
                        array( 
                                'soap_version'=>SOAP_1_1 
                                ,'encoding' => 'UTF-8' 
                                ,'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_DEFLATE 
                                ,'location'=>'http://212.170.239.71/appservices/ws/FrontendService'

                        )); 
    $response =  $client->_doRequest($clientCommon, $request, $location, 'getHotelValuedAvail', SOAP_1_1); 

         // With these two lines I've managed the call using "native" SoapClient 
         //$client = new SoapClient("http://212.170.239.71/appservices/ws/FrontendService?wsdl", array('trace'=>1)); 
        //$response =  $client->__doRequest($request, $location, 'getHotelValuedAvail', SOAP_1_1); 

提前致谢。 乔治

1 个答案:

答案 0 :(得分:1)

为什么不使用cURL来调用服务器?

How can I send SOAP XML via Curl and PHP?

相关问题