'NUSOAP client fails to parse response payload with namespace change

I have 2 servers A and B. A works fine with my nusoap client. B is giving my nusoap client trouble. I will explain why.

SOAP call to A: $client = new nusoap_client("http://IP_to_A/service", array('local_cert'=>'pathtocert')); $client->setCurl(1); $result=$client->send($hard_coded_request, 'http://IP_to_A/service'); $result gives me Array with parsed response from A. $client->responseData gives me unstructured XML string. All is good.

SOAP call to B:

$client = new nusoap_client("http://IP_to_B/service", array('local_cert'=>'pathtocert')); $client->setCurl(1); $result=$client->send($hard_coded_request, 'http://IP_to_B/service'); $result gives me an empty result (failed parse) instead of the Array. $client->responseData gives me unstructured XML string. Not happy with this failed parse. I am unable to parse responseData either.

While the SOAP response structure from A and B are the similar, the one from B has a namespace prefix of 'ser' included now. Example: getCarResourceResponse is now ser:getCarResourceResponse. How can I tell nusoap client how to handle this difference?

SOAP Response from A:

 <?xml version='1.0' encoding='ISO-8859-1'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <getCarResourceResponse xmlns="http://sos.joburg.com/webservice/ecare/services">
            <GetCarResourceReply>
                <resCode>10652981251</resCode>
                <departName>Ingolstadt</departName>
                <resStatus>4</resStatus>
                <statusDate>2022-05-09 09:24:50</statusDate>
                <isScheduled>0</isScheduled>
                <departStatus>0</departStatus>
            </GetCarResourceReply>
            <ResultOfOperationReply>
                <resultCode>0</resultCode>
                <resultMessage>Successful</resultMessage>
            </ResultOfOperationReply>
        </getCarResourceResponse>
    </soapenv:Body>
</soapenv:Envelope>
    XML;

SOAP Response from B has prefix ser for elements.

 <?xml version='1.0' encoding='ISO-8859-1'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <ser:getCarResourceResponse xmlns:ser="http://sos.joburg.com/webservice/ecare/services">
            <ser:GetCarResourceReply>
                <ser:resCode>10652981251</ser:resCode>
                <ser:departName>Ingolstadt</ser:departName>
                <ser:resStatus>4</ser:resStatus>
                <ser:statusDate>2022-05-09 09:24:50</ser:statusDate>
                <ser:isScheduled>0</ser:isScheduled>
                <ser:departStatus>0</ser:departStatus>
            </ser:GetCarResourceReply>
            <ser:ResultOfOperationReply>
                <ser:resultCode>0</ser:resultCode>
                <ser:resultMessage>Successful</ser:resultMessage>
            </ser:ResultOfOperationReply>
        </ser:getCarResourceResponse>
    </soapenv:Body>
</soapenv:Envelope>
    XML;


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source