In this code crumb, we will call ChromeData in NodeJS and PHP.

We will call the “describeVehicle” method of ChromeData ADS(Automotive Description Service). The “describeVehicle” method accepts a vehicle’s VIN, searches its database for a match then responds with information for that vehicle.

ChromeData uses WSDL and one way for us to make use of its services is to connect to it by passing our credentials along with our request parameters using SOAP(Simple Object Access Protocol).

The process is pretty much the same between languages, however there is one key difference when passing credentials using NodeJS “node-soap” module. It seems that in NodeJS, we need to explicitly tell the module  to treat the credentials(number, secret, country, language) as attributes of the AccountInfo XML element instead of children. This is something we don’t have to explicitly define when passing our request parameters to SoapClient in PHP.

Using PHP

Prepare Request Parameters

$url = 'http://services.chromedata.com/Description/7c?wsdl';
$request_params = [
    'accountInfo' => [
        'number'=>'12345',
        'secret'=>'A12B345C67890123',
        'country'=>'US',
        'language' =>'en'    
    ],
    'vin' => '5GAKVCED2CJ310674',
];

Step 2. Create a SOAP Client

References: SoapClient


try {
    $client = new SoapClient($url);
} catch (SoapFault $e) {
    $msg = 'chrome_ads_get_client -- Could not get client. ' . $e->getMessage();
}

Call the ChromeData ADS “describeVehicle” Method

try {
    $response = $client->__soapCall('describeVehicle', [$request_params]);
} catch (Exception $e) {
    $msg = 'chrome_ads_describe_vehicle -- Could not get data. ' . $e->getMessage();
}

Using Node JS

Prepare Request Parameters

NOTE: The “AccountInfo” parameter here is written differently than how we are doing it on PHP. In the code below, we are explicitly defining that “number”, “secret”, “country” and “language” are attributes of “AccountInfo”. If we do not do it this way, the resulting request XML would treat those as children of AccountInfo rather than attributes resulting in an “Unable to authenticate account –**UNKNOWN**–“ error.


const url = 'http://services.chromedata.com/Description/7c?wsdl';
const requestParams = {
    accountInfo: {
        attributes: {
            number: '12345',
            secret: 'A12B345C67890123',
            country: 'US',
            language: 'en'
        }
    },
    vin: '5GAKVCED2CJ310674,
};

Install Required Modules

References: vpulim/node-soap, @types/Sax

In your command line interface, install “soap” and it’s build dependency “@types/sax”
npm install soap
npm install --save-dev @types/sax

Create a SOAP Client

const soap = require('soap');
const soapClient = await soap.createClientAsync(url);

Call the ChromeData ADS “describeVehicle” Method

const results = await soapClient['describeVehicleAsync']([requestParams]);