n8n-nodes-soaprequest
Version:
n8n node for soap requests
55 lines • 1.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SOAPMessageBuilder = void 0;
class SoapMessage {
constructor(headers, body, envelopeAttributes) {
this.headers = headers;
this.body = body;
this.envelopeAttributes = envelopeAttributes;
}
toString() {
const envelopeAttrs = Object.entries(this.envelopeAttributes)
.map(([key, value]) => `${key}="${value}"`)
.join(' ');
const headerSection = this.headers.length > 0
? `<soap:Header>${this.headers.join('')}</soap:Header>`
: '';
const bodySection = `<soap:Body>${this.body}</soap:Body>`;
return `
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<soap:Envelope ${envelopeAttrs}>
${headerSection}
${bodySection}
</soap:Envelope>
`
.replace(/\n/g, '')
.replace(/\>\s+\</g, '><')
.trim();
}
}
class SOAPMessageBuilder {
constructor() {
this.headers = [];
this.body = '';
this.envelopeAttributes = {
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema',
'xmlns:soap': 'http://www.w3.org/2003/05/soap-envelope'
};
}
addHeader(header) {
if (header !== undefined) {
this.headers.push(header);
}
return this;
}
setBody(body) {
this.body = body;
return this;
}
build() {
return new SoapMessage(this.headers, this.body, this.envelopeAttributes);
}
}
exports.SOAPMessageBuilder = SOAPMessageBuilder;
//# sourceMappingURL=SoapMessage.js.map