Hola, 
 
estoy tratando de consumir un webservice con curl, utilizando esta funcion:
 
function soap_operation($host='http://192.168.0.105', $port = 443, $url='/Inventario.asmx', $action='http://tempuri.org/GetTopSellersFromCategory', $body,$products_model,$numero,$catego,$usarSemilla  ) 
{ $request = "'POST'"; 
require_once('lib/xml2array.php');
$eol = "\r\n"; 
// extract namespace from soap action 
preg_match('/(http?:\/\/.*\/)(.*)/', $action, $matches) or die("Invalid SOAPAction: '$action'"); 
echo $soap_ns = $matches[1]; 
echo $soap_action = $matches[2]; 
 
// create soap envelope 
// convert to utf8 and get the content length 
$content ='<?xml version="1.0" encoding="utf-8"?>'.$eol;
$content .='<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/">'.$eol; 
$content .='<soap:Body>'.$eol;
$content .='<'.$soap_action.' xmlns="'.$soap_ns.'">'.$eol; 
$content .='<ASIN>'.$products_model.'</ASIN>'.$eol; 
$content .='<NroArticulos>'.$numero.'</NroArticulos>'.$eol; 
$content .='<CategoriaTraetelo>'.$catego.'</CategoriaTraetelo>'.$eol; 
$content .='<UsarSemilla>'.$usarSemilla.'</UsarSemilla>'.$eol;
$content .='</'.$soap_action.'>'.$eol;
$content .='</soap:Body>'.$eol;
$content .='</soap:Envelope>'; 
 
$content = utf8_encode($content); 
$content_length = strlen($content); 
 
$headers = array( 
"POST ".$url." HTTP/1.1", 
"Host: ".str_replace("http://","",$host)."", 
"Content-Length: ".$content_length." ", 
"Content-Type: text/xml; charset=utf-8", 
"Connection: close", 
"SOAPAction: \"".$soap_ns.$soap_action."\"".$eol, 
$content); 
print_r($headers);
$ch = curl_init ($host.$url);
curl_setopt($ch, CURLOPT_URL, "http://192.168.0.102:81/Inventario.asmx?wsdl" );
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request); 
curl_setopt ($ch, CURLOPT_POST, 1); 
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers); 
curl_setopt ($ch, CURLOPT_POSTFIELDS, $content); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$parser = new XMLParser($ch);
$parser->Parse();
return $parser;
} // End soap_operation() 
 
 
Arojándome como error lo siguiente:
Notice: XML Parsing Error at 1:1. Error 4: Not well-formed (invalid token) in D:\Aplicaciones\Shop\includes\functions\lib\xml2ar  ray.php on line 112
 
e imprimiendome por pantalla lo siguiente:
 
Array ( [0] => POST /Inventario.asmx HTTP/1.1 [1] => Host: 192.168.0.105:81 [2] => Content-Length: 477 [3] => Content-Type: text/xml; charset=utf-8 [4] => Connection: close [5] => SOAPAction: "http://tempuri.org/GetTopSellersFromCategory" [6] => AMB000E43GP8 5 53 false ) 
 
y cuando veo por codigo fuente muestra lo siguiente:
 
Array
(
    [0] => POST /Inventario.asmx HTTP/1.1
    [1] => Host: 192.168.0.102:81
    [2] => Content-Length: 477 
    [3] => Content-Type: text/xml; charset=utf-8
    [4] => Connection: close
    [5] => SOAPAction: "http://tempuri.org/GetTopSellersFromCategory"
 
    [6] => <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> 
<GetTopSellersFromCategory xmlns="http://tempuri.org/"> 
<ASIN>AMB000E43GP8</ASIN> 
<NroArticulos>5</NroArticulos> 
<CategoriaTraetelo>53</CategoriaTraetelo> 
<UsarSemilla>false</UsarSemilla> 
</GetTopSellersFromCategory> 
</soap:Body> 
</soap:Envelope> 
)
 
en la posicion [6] del array falta la siguiente linea:
 
<?xml version="1.0" encoding="utf-8"?>
 
supongo que por esa razon no se podra parsear.
 
Muchas gracias de antemano! 
   
 



