K
K
Konstantin Zhikhor2020-03-10 17:21:32
PHP
Konstantin Zhikhor, 2020-03-10 17:21:32

How to parse Soap response?

Please help me get data from this Soap response

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <SOAP-ENV:Body>
    <cred:receiveCreditDecision
      xmlns=""
      xmlns:cred="http://b2b.instantloan.com/CreditDecision">
      <decision>
        <amount>0</amount>
        <creditTerm>15</creditTerm>
        <decision>1</decision>
        <downPayment></downPayment>
        <environmentCode>KREDBRKMNG_TEST</environmentCode>
        <product>PKP285_М6_36</product>
        <reference>2-1BVB7NYF</reference>
        <referenceKB></referenceKB>
        <source>OTPBank</source>
        <monthlypaymentamount>0</monthlypaymentamount>
        <CreditAmount>0</CreditAmount>
        <FullAgentServicesAmount>0</FullAgentServicesAmount>
        <AgentServicesAmount>0</AgentServicesAmount>
        <limitCartOfGoods>100000</limitCartOfGoods>
      </decision>
    </cred:receiveCreditDecision>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

My attempts
$xml = simplexml_load_string($soap_response);
                    $xml->registerXPathNamespace('SOAP-ENV', 'http://schemas.xmlsoap.org/soap/envelope/');
                    $xml->registerXPathNamespace('cred', 'http://b2b.instantloan.com/CreditDecision');
                    $xml_resp = $xml->xpath('//cred:receiveCreditDecision/decision');
                    $otp_result_parse_array = json_decode(json_encode($xml_resp[0]), true);


Returns 500 error

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Shamanov, 2020-03-10
@SilenceOfWinter

why such perversions when there are extensions for php?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question