Modules@robinpath/soap
soap

@robinpath/soap

0.1.1Node.jsPublic

SOAP web service client, XML-RPC support, WSDL parsing, and envelope building

SOAP

SOAP web service client, XML-RPC support, WSDL parsing, and envelope building

Package: @robinpath/soap | Category: Web | Type: Utility

Authentication

No authentication required. All functions are available immediately.

Use Cases

Use the soap module when you need to:

  • Call a SOAP web service -- Use soap.call to perform this operation
  • Build SOAP XML envelope -- Use soap.buildEnvelope to perform this operation
  • Parse SOAP XML response -- Use soap.parseEnvelope to perform this operation
  • Call XML-RPC service -- Use soap.xmlRpc to perform this operation
  • Build XML-RPC request -- Use soap.buildXmlRpc to perform this operation

Quick Reference

FunctionDescriptionReturns
callCall a SOAP web service{status, ok, fault, result, raw}
buildEnvelopeBuild SOAP XML envelopeSOAP XML
parseEnvelopeParse SOAP XML response{fault, result}
xmlRpcCall XML-RPC service{status, ok, fault, params, raw}
buildXmlRpcBuild XML-RPC requestXML-RPC XML
parseXmlRpcParse XML-RPC response{fault, params}
wsdlFetch and parse WSDL{services, operations, bindings, raw}
faultCreate SOAP fault XMLFault XML
getFaultExtract fault from SOAP XML{code, message, detail} or null

Functions

call

Call a SOAP web service

Module: soap | Returns: object -- {status, ok, fault, result, raw}

soap.call "http://example.com/ws" "GetUser" {"id": 1} {"namespace": "http://example.com"}
ParameterTypeRequiredDescription
urlstringYesService URL
methodstringYesMethod name
paramsobjectNoParameters
optionsobjectNo{namespace, soapAction, headers, timeout}

buildEnvelope

Build SOAP XML envelope

Module: soap | Returns: string -- SOAP XML

soap.buildEnvelope "GetUser" {"id": 1}
ParameterTypeRequiredDescription
methodstringYesMethod name
paramsobjectNoParameters
namespacestringNoXML namespace

parseEnvelope

Parse SOAP XML response

Module: soap | Returns: object -- {fault, result}

soap.parseEnvelope $xml
ParameterTypeRequiredDescription
xmlstringYesSOAP XML

xmlRpc

Call XML-RPC service

Module: soap | Returns: object -- {status, ok, fault, params, raw}

soap.xmlRpc "http://example.com/rpc" "system.listMethods" []
ParameterTypeRequiredDescription
urlstringYesService URL
methodstringYesMethod name
paramsarrayNoParameters array
optionsobjectNo{headers, timeout}

buildXmlRpc

Build XML-RPC request

Module: soap | Returns: string -- XML-RPC XML

soap.buildXmlRpc "getUser" [1, "admin"]
ParameterTypeRequiredDescription
methodstringYesMethod name
paramsarrayNoParameters

parseXmlRpc

Parse XML-RPC response

Module: soap | Returns: object -- {fault, params}

soap.parseXmlRpc $xml
ParameterTypeRequiredDescription
xmlstringYesXML-RPC XML

wsdl

Fetch and parse WSDL

Module: soap | Returns: object -- {services, operations, bindings, raw}

soap.wsdl "http://example.com/ws?wsdl"
ParameterTypeRequiredDescription
urlstringYesWSDL URL
optionsobjectNo{timeout}

fault

Create SOAP fault XML

Module: soap | Returns: string -- Fault XML

soap.fault "Client" "Invalid request"
ParameterTypeRequiredDescription
codestringYesFault code
messagestringYesFault message
detailstringNoDetail

getFault

Extract fault from SOAP XML

Module: soap | Returns: object -- {code, message, detail} or null

soap.getFault $xml
ParameterTypeRequiredDescription
xmlstringYesSOAP XML

Error Handling

All functions throw on failure. Common errors:

ErrorCause
(standard errors)Check function parameters and authentication
@desc "Call and validate result"
do
  set $result as soap.call "http://example.com/ws" "GetUser" {"id": 1} {"namespace": "http://example.com"}
  if $result != null
    print "Success"
  else
    print "No result"
  end
enddo

Recipes

1. List and iterate Fault

Retrieve all items and loop through them.

@desc "Get fault and iterate results"
do
  set $result as soap.getFault $xml
  each $item in $result
    print $item
  end
enddo

2. Multi-step SOAP workflow

Chain multiple soap operations together.

@desc "Call, build envelope, and more"
do
  set $r_call as soap.call "http://example.com/ws" "GetUser" {"id": 1} {"namespace": "http://example.com"}
  set $r_buildEnvelope as soap.buildEnvelope "GetUser" {"id": 1}
  set $r_parseEnvelope as soap.parseEnvelope $xml
  print "All operations complete"
enddo

3. Safe call with validation

Check results before proceeding.

@desc "Call and validate result"
do
  set $result as soap.call "http://example.com/ws" "GetUser" {"id": 1} {"namespace": "http://example.com"}
  if $result != null
    print "Success: " + $result
  else
    print "Operation returned no data"
  end
enddo

Related Modules

  • json -- JSON module for complementary functionality

Versions (1)

VersionTagPublished
0.1.1latest1 months ago
Install
$ robinpath add @robinpath/soap

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.1
LicenseMIT
Unpacked Size6.1 KB
Versions1
Weekly Downloads21
Total Downloads21
Stars0
Last Publish1 months ago
Created1 months ago

Keywords

Category

web