php将soap返回的xml转成数组,php - 如何将SOAP响应转换为PHP Array? - 堆栈内存溢出...

可以使用前面的方法的组合轻松地将以下SOAP响应结构转换为数组。 在某些情况下,仅使用函数“ simplexml_load_string”除去冒号“:”即可返回null。

SOAP响应

xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">

xmlns:ns2="http://ws.iatai.com/">

94567

3958

3

Declinada

202

93815.0

86815.0

0.0

COP

24-07-2015 12:18:40 PM

REJECT

1

VISA

411111

1111

3

PHP转换:

$response = preg_replace("/(]*>)/", "$1$2$3", $response);

$xml = new SimpleXMLElement($response);

$body = $xml->xpath('//SBody')[0];

$array = json_decode(json_encode((array)$body), TRUE);

print_r($array);

结果:

Array

(

[ns2transaccionResponse] => Array

(

[respuestaTransaccion] => Array

(

[idTransaccion] => 94567

[referencia] => 3958

[idEstado] => 3

[nombreEstado] => Declinada

[codigoRespuesta] => 202

[valor] => 93815.0

[iva] => 86815.0

[baseDevolucion] => 0.0

[isoMoneda] => COP

[fechaProcesamiento] => 24-07-2015 12:18:40 PM

[mensaje] => REJECT

[tarjetaRespuesta] => Array

(

[idFranquicia] => 1

[nombreFranquicia] => VISA

[numeroBin] => 411111

[numeroProducto] => 1111

)

[procesadorRespuesta] => Array

(

[idProcesador] => 3

)

)

)

)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值