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>
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>
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($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $soapUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
var_dump($response);
curl_close($ch);
?>