-
Notifications
You must be signed in to change notification settings - Fork 5
Use Case: Implement a SOAP Web Service
do- edited this page Dec 11, 2022
·
14 revisions
You have:
- a WSDL file
myService.wsdlstored in a local filesystem with all dependencies; - a function named
myMethod (rq)that calculates a response for any given HTTP request:- normally, the output is a single property object
{MyMethodResponse: {...}}, whereMyMethodResponseis a local name of the element representing the corresponding message type; - otherwise, an
Erroris thrown.
- normally, the output is a single property object
Send the HTTP response rp representing the obtained result as a SOAP message.
const {XMLSchemata, SOAP11, SOAPFault} = require ('xml-toolkit')
const xs = new XMLSchemata (`myService.wsdl`)
let body, statusCode
try {
body = xs.stringify (myMethod (rq))
statusCode
}
catch (x) {
body = new SOAPFault (x)
}