NodeJS Soap request/response

581 views Asked by At

The request or parsing response is incorrect in NodeJS. But it works in PHP.

Here is PHP version which works:

ini_set("soap.wsdl_cache_enabled", "0");

try {
    $oWsdl = @new \SoapClient(
        "https://xml.proveid.experian.com/IDSearch.cfc?wsdl",
        array(
            "exceptions" => 1,
            "timeout" => 0,
            "connect_timeout" => 0,
            "ssl_verify_peer" => false,
        )
    );
    $sAnswer = $oWsdl->Search(getXML());
}
catch (\SoapFault $e)
{
    throw $e;
}

print_r($sAnswer);


// ******************************************
function getXML() {
    return <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<Search>
    <Authentication>
        <Username>test_acc</Username>
        <Password>test_pw</Password>
    </Authentication>
    <CountryCode>GBR</CountryCode>
    <Person>
        <Name>
            <Forename>Wexhuy</Forename>
            <Surname>Cutfamjungofguc</Surname>
        </Name>
        <Gender></Gender>
        <DateOfBirth>1987-02-17</DateOfBirth>
    </Person>
    <Addresses>
        <Address Current="1">
            <Premise>random</Premise>
            <Postcode>BD634HP</Postcode>
            <CountryCode>GBR</CountryCode>
        </Address>
    </Addresses>
    <SearchOptions>
        <ProductCode>ProveID_AML</ProductCode>
        <DecisionCode>Ssdz</DecisionCode>
    </SearchOptions>
</Search>
XML;
}

And here is NodeJS version using the node-soap lib. I also tried the xml2js library to parse the response, but without success.

soap.createClient(url , function(err, client) {
    client.search(xml, function(err, result) {
        if(err) {
            console.log("Error:", err.message); // Error: Cannot parse response    
        }
        console.log(result); // {}
    });
});

How to fix the NodeJS version?

Maybe some headers or Envelope are required?

0

There are 0 answers