Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/04/2016, 04:32
pwron
 
Fecha de Ingreso: mayo-2007
Mensajes: 18
Antigüedad: 17 años, 9 meses
Puntos: 0
Pregunta Problemas con SOAP

Buenas gente no he trabajado nunca con este tipo de Webservices (SOAP) y no consigo una respuesta correcta.

Estoy trabajando en PHP y haciendo peticiones de prueba en CURL y también con la clase SoapClient() de PHP , la request y la response son estas :

REQUEST :
Código HTML:
POST /ServiciosWeb.asmx HTTP/1.1
Host: privadacz.adexia.es
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://privadacz.adexia.es/ObtenerArchivoTarifaCz"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <ObtenerArchivoTarifaCz xmlns="http://privadacz.adexia.es/">
      <Ticket>string</Ticket>
      <DatosSolicitud>
        <xsd:schema>schema</xsd:schema>xml</DatosSolicitud>
    </ObtenerArchivoTarifaCz>
  </soap:Body>
</soap:Envelope> 
RESPONSE:
Código HTML:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <ObtenerArchivoTarifaCzResponse xmlns="http://privadacz.adexia.es/">
      <ObtenerArchivoTarifaCzResult>
        <xsd:schema>schema</xsd:schema>xml</ObtenerArchivoTarifaCzResult>
    </ObtenerArchivoTarifaCzResponse>
  </soap:Body>
</soap:Envelope> 
El ticket se saca de otra request que si que me responde y me devuelve el ticket , hasta ahi todo correcto .

La duda la tengo aquí en la Request "<xsd:schema>schema</xsd:schema>xml</DatosSolicitud>" , el proveedor me da unos xsd que son esquemas que debe cumplir el xml (o eso imagino) para cada request .

Y aquí es donde la matan , yo lo que entiendo es que donde pone "schema" tendría que poner el xsd que me da el proveedor de esta request y en donde pone "xml" , el xml que coincide con ese xsd ¿Estoy en lo cierto o estoy completamente equivocado?

Os dejo el código de pruebas muchísimas gracias!.

Código PHP:
<?php 
        $soapUrl 
"https://privadacz.adexia.es/ServiciosWeb.asmx?WSDL"

        
$client = new SoapClient($soapUrl);
        
$result $client->SolicitarTicket(array('Usuario' => 'xxxx' 'Contraseña' => 'xxxx'));
        
$ticket $result->SolicitarTicketResult;


        
$xml_post_string '<?xml version="1.0" encoding="utf-8"?>
                            <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                              <soap:Body>
                                <ObtenerArchivoTarifaCz xmlns="http://privadacz.adexia.es/">
                                  <Ticket>'
.$ticket.'</Ticket>
                                    <DatosSolicitud>
                                    <xsd:schema>schema</xsd:schema>xml</DatosSolicitud>
                                </ObtenerArchivoTarifaCz>
                              </soap:Body>
                            </soap:Envelope>'
;

           
$headers = array(
                        
"POST /ServiciosWeb.asmx HTTP/1.1",
                        
"Host: privadacz.adexia.es",
                        
"Content-Type: text/xml; charset=utf-8",
                        
"Content-length: ".strlen($xml_post_string),
                        
"SOAPAction: http://privadacz.adexia.es/ObtenerArchivoTarifaCz"
                    
); 

            
$ch curl_init();
            
curl_setopt($chCURLOPT_SSL_VERIFYPEER0);
            
curl_setopt($chCURLOPT_URL$soapUrl);
            
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
            
curl_setopt($chCURLOPT_HTTPAUTHCURLAUTH_ANY);
            
curl_setopt($chCURLOPT_TIMEOUT10);
            
curl_setopt($chCURLOPT_POSTtrue);
            
curl_setopt($chCURLOPT_POSTFIELDS$xml_post_string);
            
curl_setopt($chCURLOPT_HTTPHEADER$headers);

            
$response curl_exec($ch);

            
var_dump($response);

            
curl_close($ch);


    
?>

Última edición por pwron; 09/04/2016 a las 06:05