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

发布于 2024-11-09 13:59:26 字数 3704 浏览 4 评论 0原文

我正在尝试向 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); 

提前致谢。 豪尔赫

I'm traying to send a raw request to a SOAP server. The only way I found to do this is creating a redundant Zend_Soap_Client_Common in order to invoke _dorequest. Is really that necessary? Is there any other way to send raw xml to the server?

Here's the code:

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

Thanks in advance.
Jorge

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文