Foros del Web » Programando para Internet » PHP »

Problema con webservice!!

Estas en el tema de Problema con webservice!! en el foro de PHP en Foros del Web. Hola a todos, necesito consumir un webservice, este el codigo que tengo. Cdigo PHP: <?php //header("Content-Type: text/xml; charset=utf-8"); $xml  =  '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">     <soap:Body>         <OTA_HotelAvailService xmlns="http://www.opentravel.org/OTA/2003/05">             <OTA_HotelAvailRQ PrimaryLangID="%LANGUAGE%">                 <POS>                     <Source AgentDutyCode="*****"> ...
  #1 (permalink)  
Antiguo 28/09/2011, 09:36
 
Fecha de Ingreso: noviembre-2010
Mensajes: 5
Antigedad: 13 aos, 5 meses
Puntos: 0
Problema con webservice!!

Hola a todos, necesito consumir un webservice, este el codigo que tengo.

Cdigo PHP:
<?php
//header("Content-Type: text/xml; charset=utf-8");
$xml '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <OTA_HotelAvailService xmlns="http://www.opentravel.org/OTA/2003/05">
            <OTA_HotelAvailRQ PrimaryLangID="%LANGUAGE%">
                <POS>
                    <Source AgentDutyCode="*****">
                        <RequestorID MessagePassword="*****"/>
                    </Source>
                </POS>
                <AvailRequestSegments>
                    <AvailRequestSegment>
                        <StayDateRange Start="2011-11-12" End="2011-11-19"/>
                        <RoomStayCandidates>
                            <RoomStayCandidate Quantity="1">
                                <GuestCounts>
                                    <GuestCount Age="40" Count="1"/>
                                    <GuestCount Age="5" Count="1"/>
                                </GuestCounts>
                            </RoomStayCandidate>
                            <RoomStayCandidate Quantity="1">
                                <GuestCounts>
                                    <GuestCount Age="40" Count="2"/>
                                </GuestCounts>
                            </RoomStayCandidate>
                        </RoomStayCandidates>
                        <HotelSearchCriteria>
                            <Criterion>
                                <HotelRef HotelCityCode="%CITY_CODE%" HotelCode="%HOTEL_CODE%"/>
                                <TPA_Extensions>
                                    <ShowBasicInfo xmlns="">1</ShowBasicInfo>
                                    <ShowPromotions xmlns="">1</ShowPromotions>
                                </TPA_Extensions>
                            </Criterion>
                        </HotelSearchCriteria>
                    </AvailRequestSegment>
                </AvailRequestSegments>
            </OTA_HotelAvailRQ>
        </OTA_HotelAvailService>
    </soap:Body>
</soap:Envelope>'
;

$url 'http://xml.bookingengine.es/webservice/OTA_HotelAvail.asmx?wsdl';
$header = array();
$header[] = 'Content-Type: text/xml;charset=UTF-8';
$header[] = 'SOAPAction: "http://www.opentravel.org/OTA/2003/05/OTA_HotelAvailService"';
$header[] = 'Accept-Encoding: gzip,deflate';
 
$ch curl_init();
curl_setopt($chCURLOPT_URL$url); // set url to post to
curl_setopt($chCURLOPT_FOLLOWLOCATION1); // allow redirects
curl_setopt($chCURLOPT_RETURNTRANSFER1); // return into a variable
curl_setopt($chCURLOPT_SSL_VERIFYHOST0);
curl_setopt($chCURLOPT_SSL_VERIFYPEER0);
curl_setopt($chCURLOPT_HTTPHEADER$header);
curl_setopt($chCURLOPT_POST1);
curl_setopt($chCURLOPT_POSTFIELDS$xml);
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_USERAGENT$_SERVER['HTTP_USER_AGENT']);
$data curl_exec($ch);
curl_close($ch);

echo 
$data;

y esto es lo que imprime :

`I%&/m{JJt`$ؐ@iG#)*eVe]f@흼{{;N'?\fdlJɞ!?~|?" ezMQ-?hwQ/լX^|Ѻ=>8zT2/U+>yۮݽL"k>W]r7ח~k 7ٽ{5.M-{kv[)O/߮ڼ<̊u^_Uެec@˶]M; .{:}S,m n<;xѽGwǻ{?{Cs:T[n(8o^FC^7Y=YQzlOYG}9}qp/.*><*nk)GW>^}W u&~Q",sIˬ,fI:]eMsUճRO??{ӏһGr}g ^>L}͛n7N :



Ayuda!!, no se que hacer!!
  #2 (permalink)  
Antiguo 29/09/2011, 06:12
 
Fecha de Ingreso: noviembre-2010
Mensajes: 5
Antigedad: 13 aos, 5 meses
Puntos: 0
Respuesta: Problema con webservice!!

ya encontre la solucion, solo deben reemplazar esta lina:

$header[] = 'Accept-Encoding: gzip,deflate';

por:

$header[] = 'Accept-Encoding: deflate';

Etiquetas: variables
Atencin: Ests leyendo un tema que no tiene actividad desde hace ms de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:01.