Llevo varios días sin lograr recibir de forma adecuada la respuesta que me entrega un Web Service; mi código es el siguiente:
<?php
$params = array('NitProveedor' => '860000896',
'baseDatos' => '1',
'FechaInicial' => '01/04/2016',
'FechaFinal' => '01/05/2016',
'numeroFacutura' => 'BO-00019421');
$wsdl = 'http://10.1.1.26:82/SincoConinsaRH_PRBINT/ERPNET/Financiero/Comunicaciones/CuentasPorPagar/ExtratoProveedor/ExtractoProveedorService.svc?wsdl';
$options = array(
'uri'=>'http://schemas.xmlsoap.org/soap/envelope/',
'style'=>SOAP_RPC,
'use'=>SOAP_ENCODED,
'soap_version'=>SOAP_1_1,
'cache_wsdl'=>WSDL_CACHE_NONE,
'connection_timeout'=>6000,
'trace'=>true,
'encoding'=>'UTF-8',
'exceptions'=>true,
);
try {
$soap = new SoapClient($wsdl, $options);
$data = $soap->ExtratoProveedor($params);
$xmlstring = $soap->__getLastResponse();
}
catch(Exception $e) {
die($e->getMessage());
}
die;
La respuesta que me devuelve el __getLastResponse()
si hago un:
echo $xmlstring = $soap->__getLastResponse();
Me muestra:
200132625BO-0001942101/04/2016860000896Otros (Ch. Ger. - Carta)24575000.003932000.000.000.000.000.000.000.0028507000.000.0028507000.000.000.00CENTRO COMERCIAL DIVERPLAZA -BOG
Es como la respuesta en un string no lo entraga como array. Si doy clic derecho ver codigo fuente muestra una especie de XML que se ve así:
<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>
<s:Body><ExtratoProveedorResponse xmlns='ERPNet/Financiero/Comunicaciones/CuentasPorPagar/ExtratoProveedor'><ExtratoProveedorResult><Facturas xmlns=''>
<Factura>
<NumeroCE>200132625</NumeroCE>
<FacturaProv>BO-00019421</FacturaProv>
<FechaPago>01/04/2016</FechaPago>
<Nit>860000896</Nit>
<FormaGiro>Otros (Ch. Ger. - Carta)</FormaGiro>
<ChequeNo></ChequeNo>
<Banco></Banco>
<TipoCuentaBancaria></TipoCuentaBancaria>
<CuentaBancariaNo></CuentaBancariaNo
><SubTotal>24575000.00</SubTotal>
<Iva>3932000.00</Iva>
<ReteIca>0.00</ReteIca>
<ReteIva>0.00</ReteIva>
<ReteFuente>0.00</ReteFuente>
<ReteGarantia>0.00</ReteGarantia>
<Amortizacion>0.00</Amortizacion>
<ReteCree>0.00</ReteCree>
<Neto>28507000.00</Neto>
<DescuentosF>0.00</DescuentosF>
<Pagado>28507000.00</Pagado>
<Saldo>0.00</Saldo>
<NotasCredito>0.00</NotasCredito>
<Proyecto>CENTRO COMERCIAL DIVERPLAZA -BOG</Proyecto>
</Factura></Facturas>
</ExtratoProveedorResult></ExtratoProveedorResponse
></s:Body>
</s:Envelope>
El problema es que cuando intento parsear este response con simpleXML:
$xmlString = $ws->__getLastResponse();
$xml = simplexml_load_string($xmlString);
Intento mostrar o acceder a $xml no muestra nada; como si el load del $xmlString no lograra reconocer el formato que recibe en el response; incluso he intentado con esto:
$xml = new SimpleXMLElement($xmlString);
print_r($xml);
y la respuesta que me da es esta: String could not be parsed as XML
He llegado a la conclusión que el XML obtenido en el response no es compatible por su estructura con la funcionalidad de simpleXML entonces quisiera saber si alguien h atenido un inconveniente similar y como lo ha solventado.NOTA: la respuesta del WS es tipo any.