@anhquoc96/fastxml-soap
v0.1.2
Published
SOAP 1.1 and SOAP 1.2 support for fastxml.
Readme
@anhquoc96/fastxml-soap
SOAP 1.1 and SOAP 1.2 parsing and construction helpers for fastxml.
This package validates SOAP envelope structure while leaving application
payloads as normal namespace-aware fastxml elements.
Installation
npm install @anhquoc96/fastxml-soap @anhquoc96/fastxmlParse a SOAP message
import { parseSoap } from "@anhquoc96/fastxml-soap";
const message = parseSoap(xmlText);
console.log(message.version); // "1.1" or "1.2"
console.log(message.header); // Header element or null
console.log(message.body); // Body element
console.log(message.fault?.reason); // Fault reason or nullStream and URL inputs are supported:
import { parseSoap, parseSoapUrl } from "@anhquoc96/fastxml-soap";
const streamed = await parseSoap(response.body!);
const remote = await parseSoapUrl("https://example.com/service");The parser checks the SOAP namespace, exactly one Body, at most one Header, and
Header-before-Body ordering. SOAP Fault code, reason, and detail are exposed by
message.fault.
Create an envelope
import { el } from "@anhquoc96/fastxml";
import { createSoapEnvelope } from "@anhquoc96/fastxml-soap";
const document = createSoapEnvelope("1.2", [
el("m:GetStatus", { "xmlns:m": "urn:example:service" }),
]);
console.log(document.toString());Create a fault element with createSoapFault(version, code, reason) and append
it to a SOAP Body when building an error response.
Supported standards and boundaries
- SOAP 1.1 envelope namespace and Fault shape.
- SOAP 1.2 envelope namespace and Fault shape.
- Header, Body, Envelope, and application payload validation.
WS-Addressing, WS-ReliableMessaging, full WS-Security message serialization, and transport-specific policies are separate integration layers.
Development
npm run build --workspace @anhquoc96/fastxml-soap
npm run typecheck --workspace @anhquoc96/fastxml-soapLicense
MIT License. See the package LICENSE file.
