Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

easy-soap-request

circa10a98.7kMIT5.6.1TypeScript support: definitely-typed

A small library to make SOAP requests easier

soap, http, axios, xml, wsdl

readme

easy-soap-request

Build Status npm version npm downloads Buy Me A Coffee NPM

A small library to make SOAP requests easier via Node.js, Deno, and your browser

Installation

npm install easy-soap-request

Usage

Node.js

const soapRequest = require('easy-soap-request');
const fs = require('fs');

// example data
const url = 'https://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php';
const sampleHeaders = {
  'user-agent': 'sampleTest',
  'Content-Type': 'text/xml;charset=UTF-8',
  'soapAction': 'https://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl#LatLonListZipCode',
};
const xml = fs.readFileSync('test/zip-code-envelope.xml', 'utf-8');

// usage of module
(async () => {
  const { response } = await soapRequest({ url: url, headers: sampleHeaders, xml: xml, timeout: 1000 }); // Optional timeout parameter(milliseconds)
  const { headers, body, statusCode } = response;
  console.log(headers);
  console.log(body);
  console.log(statusCode);
})();

Deno

import soapRequest from 'https://deno.land/x/easy_soap_request/index.d.js';

// example data
const url = 'https://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php';
const sampleHeaders = {
  'user-agent': 'sampleTest',
  'Content-Type': 'text/xml;charset=UTF-8',
  'soapAction': 'https://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl#LatLonListZipCode',
};

// usage of module
(async () => {
  const xml = await Deno.readFile('test/zip-code-envelope.xml');
  const { response } = await soapRequest({ url: url, headers: sampleHeaders, xml: xml });
  const { headers, body, statusCode } = response;
  console.log(headers);
  console.log(body);
  console.log(statusCode);
})();

Browser

Note: CORS policies apply

<html>
<script src="https://cdn.jsdelivr.net/npm/easy-soap-request/dist/easy-soap-request.js"></script>
<script>
    const url = 'https://my-soap-server';
    const sampleHeaders = {
        'Content-Type': 'text/xml;charset=UTF-8',
        SOAPAction: 'https://my-soap-action/something',
    };
    const xml = `<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                 <soapenv:Header/>
                 <soapenv:Body>Some Data</soapenv:Body>
                 </soapenv:Envelope>`;
    async function makeRequest() {
        const { response } = await soapRequest({ url: url, headers: sampleHeaders, xml: xml, timeout: 1000 });
        const { headers, body, statusCode } = response;
        console.log(headers);
        console.log(body);
        console.log(statusCode);
        document.body.innerHTML = body;
    };
    makeRequest();
</script>
<body></body>
</html>

Changelog

Changelog.md

Tests

changelog

5.6.1(2024-01-30)

  • Revert chai dependency from 5.X to 4.X

5.6.0(2024-01-30)

  • Update axios to 1.6.7

5.5.0(2023-09-09)

  • Update axios to 1.6.2

5.4.0(2023-09-09)

  • Update axios to stable 1.4.0

5.3.0(2023-05-01)

  • Update axios to stable 1.4.0

5.2.0(2022-11-02)

  • Remove Promise wrapper

5.1.0(2022-10-08)

  • Update axios to stable 1.1.2

5.0.0(2022-09-24)

  • Breaking change: Reject entire error object from axios instead of just error.response.data

4.8.0(2022-07-10)

  • Update Axios vesion 0.27.2

4.7.0(2022-03-17)

  • Update Axios vesion 0.26.1

4.6.0(2022-01-18)

  • Update Axios vesion 0.25.0

4.5.0(2021-12-01)

  • Update Axios vesion 0.24.0

4.4.0(2021-10-17)

  • Update Axios vesion 0.23.0

4.3.0(2021-10-10)

  • Update Axios vesion 0.22.0

4.2.0(2021-09-06)

  • Update Axios vesion 0.21.3

4.1.3(2021-03-17)

  • Support overriding http method

4.1.2(2021-01-05)

  • Update axios to v0.21.1

4.1.1(2020-12-11)

  • Switch to github actions

4.0.1(2020-12-03)

  • Remove logging from deno module

4.0.0(2020-12-01)

  • Remove logging

3.5.0(2020-11-01)

  • Update to axios v0.21
  • Update webpack to v5

3.4.0(2020-09-08)

Update to axios v0.20

3.3.3(2020-08-12)

Update deps, fix deno tests again.

3.3.2(2020-07-01)

Fix deno tests

3.3.1(2020-04-26)

Update docs to point to deno.land for easy-soap-request deno module instead of github

3.3.0(2020-04-25)

Added

Deno support

3.2.2(2020-04-08)

Updated

Update dependencies

3.2.1 (2020-03-13)

Fixed

3.2.0 (2019-10-19)

Fixed

3.1.0(2019-10-09)

Added

  • Added maxContentLength parameter default of Infinity. See axios docs
  • Added extraOpts parameter that can be used to pass more config options for axios so a library update frequency is lower

Fixed

3.0.1(2019-10-02)

Changed

  • Fix typo in docs

3.0.0(2019-10-01)

Changed

  • Changed format of input parameters from positional to object to follow traditional javascript library patterns.

Old format of input parameters:

const { response } = await soapRequest(url, headers, xml, 1000);

New format of input parameters:

const { response } = await soapRequest({
  url: url,
  headers: headers,
  xml: xml,
  timeout: 1000,
});

Updated

  • Dependencies

Added

  • Added changelog(#24)