Estoy tratando de enviar un XML por POST a través de CURL a un WebServices Autenticado, pero el servidor por alguna razón me esta rechazando el archivo dandome un error 500, sin embargo a otro WebServices que es vía GET no tengo ningún problema, a continuación muestro el código con el cual estoy intentando:
Código PHP:
<?php
$request_xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
<FiltroLicitaciones xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">
<CantidadRegistro>10</CantidadRegistro>
<Texto>memo</Texto>
<CodigoRegion xsi:nil=\"true\" />
<CodigoEstado>1</CodigoEstado>
<TipoFecha>FechaPublicacion</TipoFecha>
<FechaDesde>2011-06-01T00:00:00</FechaDesde>
<FechaHasta>2011-08-01T00:00:00</FechaHasta>
</FiltroLicitaciones>";
//Initialize handle and set options
$username = 'user';
$password = 'pass';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.mercadopublico.cl/movil/licitaciones/porFecha');
//curl_setopt($ch, CURLOPT_URL, "http://localhost/server.php");
curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request_xml);
$result = curl_exec($ch);
curl_close($ch);
print_r($result);
?>
Código:
Hice una prueba en el servidor local, para ver como estan llegando los datos, a continuación el resultado de esto:HTTP/1.1 500 The server encountered an error processing the request. Please see the server logs for more details. Cache-Control: private Content-Length: 1047 Content-Type: text/html Server: Microsoft-IIS/7.5 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Mon, 30 Jul 2012 23:53:05 GMT
Código PHP:
HTTP/1.1 200 OK
Date: Mon, 30 Jul 2012 23:41:50 GMT
Server: Apache/2.2.22 (Fedora)
X-Powered-By: PHP/5.3.14
Content-Length: 2450
Connection: close
Content-Type: text/html; charset=UTF-8
Array
(
[GLOBALS] => Array
*RECURSION*
[_POST] => Array
(
[<?xml version] => "1.0" encoding="utf-8" ?>
<FiltroLicitaciones xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CantidadRegistro>10</CantidadRegistro>
<Texto>memo</Texto>
<CodigoRegion xsi:nil="true" />
<CodigoEstado>1</CodigoEstado>
<TipoFecha>FechaPublicacion</TipoFecha>
<FechaDesde>2011-06-01T00:00:00</FechaDesde>
<FechaHasta>2011-08-01T00:00:00</FechaHasta>
</FiltroLicitaciones>
)
[_GET] => Array
(
)
[_COOKIE] => Array
(
)
[_FILES] => Array
(
)
[_ENV] => Array
(
)
[_REQUEST] => Array
(
[<?xml version] => "1.0" encoding="utf-8" ?>
<FiltroLicitaciones xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CantidadRegistro>10</CantidadRegistro>
<Texto>memo</Texto>
<CodigoRegion xsi:nil="true" />
<CodigoEstado>1</CodigoEstado>
<TipoFecha>FechaPublicacion</TipoFecha>
<FechaDesde>2011-06-01T00:00:00</FechaDesde>
<FechaHasta>2011-08-01T00:00:00</FechaHasta>
</FiltroLicitaciones>
)
[_SERVER] => Array
(
[HTTP_HOST] => localhost
[HTTP_ACCEPT] => */*
[CONTENT_LENGTH] => 469
[CONTENT_TYPE] => application/x-www-form-urlencoded
[PATH] => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[SERVER_SIGNATURE] => <address>Apache/2.2.22 (Fedora) Server at localhost Port 80</address>
[SERVER_SOFTWARE] => Apache/2.2.22 (Fedora)
[SERVER_NAME] => localhost
[SERVER_ADDR] => ::1
[SERVER_PORT] => 80
[REMOTE_ADDR] => ::1
[DOCUMENT_ROOT] => /var/www/html
[SERVER_ADMIN] => root@localhost
[SCRIPT_FILENAME] => /var/www/html/server.php
[REMOTE_PORT] => 37712
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => POST
[QUERY_STRING] =>
[REQUEST_URI] => /server.php
[SCRIPT_NAME] => /server.php
[PHP_SELF] => /server.php
[PHP_AUTH_USER] => user
[PHP_AUTH_PW] => pass
[REQUEST_TIME] => 1343691710
)
)
Gracias.