{"id":13388852,"url":"https://github.com/loopbackio/loopback-connector-soap","last_synced_at":"2025-05-16T09:02:57.260Z","repository":{"id":8139874,"uuid":"9558565","full_name":"loopbackio/loopback-connector-soap","owner":"loopbackio","description":"LoopBack's SOAP based Web Services Connector","archived":false,"fork":false,"pushed_at":"2025-05-14T21:00:53.000Z","size":1146,"stargazers_count":82,"open_issues_count":2,"forks_count":46,"subscribers_count":52,"default_branch":"master","last_synced_at":"2025-05-14T22:18:53.910Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loopbackio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2013-04-20T03:16:04.000Z","updated_at":"2025-05-14T21:00:56.000Z","dependencies_parsed_at":"2023-11-20T14:29:51.079Z","dependency_job_id":"9d0a16c3-1e38-40e9-9017-e693e8038290","html_url":"https://github.com/loopbackio/loopback-connector-soap","commit_stats":{"total_commits":257,"total_committers":38,"mean_commits":"6.7631578947368425","dds":0.7042801556420233,"last_synced_commit":"9a204a2c37385f1534c9c242a86cbd70c9da803a"},"previous_names":["strongloop/loopback-connector-soap"],"tags_count":54,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopbackio%2Floopback-connector-soap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopbackio%2Floopback-connector-soap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopbackio%2Floopback-connector-soap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopbackio%2Floopback-connector-soap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loopbackio","download_url":"https://codeload.github.com/loopbackio/loopback-connector-soap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254301426,"owners_count":22047902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T13:00:55.420Z","updated_at":"2025-05-16T09:02:57.157Z","avatar_url":"https://github.com/loopbackio.png","language":"JavaScript","readme":"# loopback-connector-soap\n\n[![CI](https://github.com/loopbackio/loopback-connector-soap/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/loopbackio/loopback-connector-soap/actions/workflows/continuous-integration.yml)\n[![Build Status](https://app.travis-ci.com/loopbackio/loopback-connector-soap.svg?branch=master)](https://app.travis-ci.com/loopbackio/loopback-connector-soap)\n[![Coverage Status](https://coveralls.io/repos/github/loopbackio/loopback-connector-soap/badge.svg?branch=master)](https://coveralls.io/github/loopbackio/loopback-connector-soap?branch=master)\n\nThe SOAP connector enables LoopBack applications to interact with\n[SOAP](http://www.w3.org/TR/soap)-based web services described using\n[WSDL](http://www.w3.org/TR/wsdl).\n\n\u003cp class=\"gh-only\"\u003e\nFor more information, see the\n\u003ca href=\"http://loopback.io/doc/en/lb3/SOAP-connector.html\"\u003eLoopBack documentation\u003c/a\u003e.\n\u003c/p\u003e\n\n## Installation\n\nIn your application root directory, enter:\n\n```shell\n$ npm install loopback-connector-soap --save\n```\n\nThis will install the module from npm and add it as a dependency to the application's \n[package.json](http://loopback.io/doc/en/lb2/package.json.html) file.\n\n## Overview\n\nThere are two ways to use the SOAP connector:\n\n- Use the LoopBack CLI `lb soap` command to automatically create a set of models based on a SOAP service WSDL file.  Often, this will be the easiest way to connect to a SOAP web service, but may not be suitable for all applications.  For more information, see [SOAP generator](http://loopback.io/doc/en/lb3/SOAP-generator.html).\n- Write the code manually, calling the `loopback-connector-soap` and data source APIs directly.  **This is the approach illustrated here**.\n\nWhile both approaches use the `loopback-connector-soap` data source connector, they appear quite different.\n\n## SOAP data source properties\n\nThe following table describes the SOAP data source properties you can set in `datasources.json`.\n\n\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eProperty\u003c/th\u003e\n\u003cth\u003eType\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e    \n\u003ctr\u003e\n\u003ctd\u003eurl\u003c/td\u003e\n\u003ctd\u003eString\u003c/td\u003e\n\u003ctd\u003eURL to the SOAP web service endpoint. If not present, defaults to the\n\u003ccode\u003elocation\u003c/code\u003e attribute of the SOAP address for the service/port\nfrom the WSDL document; for example below it is \u003ccode\u003ehttp://www.webservicex.net/periodictable.asmx\u003c/code\u003e:\n\u003cpre\u003e\n\u0026lt;wsdl:service name=\"periodictable\"\u0026gt;\n\u0026lt;wsdl:port name=\"periodictableSoap\" binding=\"tns:periodictableSoap\"\u0026gt;\n\u0026lt;soap:address location=\"http://www.webservicex.net/periodictable.asmx\"/\u0026gt;\n\u0026lt;/wsdl:port\u0026gt;\n\u0026lt;/wsdl:service\u0026gt;\u003c/pre\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003ewsdl\u003c/td\u003e\n\u003ctd\u003eString\u003c/td\u003e\n\u003ctd\u003eHTTP URL or local file system path to the WSDL file. Default is \u003ccode\u003e?wsdl\u003c/code\u003e.\nIn the example above, it would be \u003ccode\u003ehttp://www.webservicex.net/periodictable.asmx?wsdl\u003c/code\u003e.\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003ewsdl_options\u003c/td\u003e\n\u003ctd\u003eObject\u003c/td\u003e\n\u003ctd\u003eIndicates additonal options to pass to the SOAP connector, for example allowing self signed certificates.\nFor example:\n\u003cpre\u003e\u003ccode\u003ewsdl_options: {\n  rejectUnauthorized: false,\n  strictSSL: false,\n  requestCert: true,\n}\u003c/code\u003e\u003c/pre\u003e\u003c/td\u003e    \n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003ewsdl_headers\u003c/td\u003e\n\u003ctd\u003eObject\u003c/td\u003e\n\u003ctd\u003eIndicates additonal headers to pass to the SOAP connector, for example for sending http authorizations header.\nFor example:\n\u003cpre\u003e\u003ccode\u003ewsdl_headers: {\n  Authorization: \"Basic UGVyc29uYWwgYWNjb3VudDpORVdsazIwMTVAKSEl\"\n}\u003c/code\u003e\u003c/pre\u003e\u003c/td\u003e    \n\u003c/tr\u003e  \n\u003ctr\u003e\n\u003ctd\u003eremotingEnabled\u003c/td\u003e\n\u003ctd\u003eBoolean\u003c/td\u003e\n\u003ctd\u003eIndicates whether the operations are exposed as REST APIs. To expose or hide a specific method, override with:\n\u003cpre\u003e\u003ccode\u003e\u0026lt;Model\u0026gt;.\u0026lt;method\u0026gt;.shared = true | false;\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eoperations\u003c/td\u003e\n\u003ctd\u003eObject\u003c/td\u003e\n\u003ctd\u003eMaps WSDL binding operations to Node.js methods. Each key in the JSON\nobject becomes the name of a method on the model.\nSee \u003ca href=\"#operations-property\"\u003eoperations property\u003c/a\u003e below.\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003esecurity\u003c/td\u003e\n\u003ctd\u003eObject\u003c/td\u003e\n\u003ctd\u003esecurity configuration.\nSee \u003ca href=\"#security-property\"\u003esecurity property\u003c/a\u003e below.\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003esoapHeaders\u003c/td\u003e\n\u003ctd\u003eArray of objects.\u003c/td\u003e\n\u003ctd\u003eCustom SOAP headers. An array of header properties.\n For example:\n\u003cpre\u003e\u003ccode\u003esoapHeaders: [{\nelement: {myHeader: 'XYZ'}, // The XML element in JSON object format\n  prefix: 'p1', // The XML namespace prefix for the header\n  namespace: 'http://ns1' // The XML namespace URI for the header\n}]\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e       \n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003ehttpHeaders\u003c/td\u003e\n\u003ctd\u003eObject\u003c/td\u003e\n\u003ctd\u003eCustom HTTP headers. An object of header properties.\n For example:\n\u003cpre\u003e\u003ccode\u003ehttpHeaders: {\n  \"custom-header\": \"value of custom-header\",\n  \"custom-header-2\": \"value of custom-header-2\"\n}\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e       \n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n### operations property\n\nThe `operations` property value is a JSON object that has a property (key) for each\nmethod being defined for the model. The corresponding value is an object with the\nfollowing properties:\n\n| Property | Type | Description |\n|---|---|---|\n| service | String | WSDL service name |\n| port | String | WSDL port name |\n| operation | String | WSDL operation name |\n\nHere is an example operations property for the periodic table service:\n\n```javascript\noperations: {\n  // The key is the method name\n  periodicTable: {\n    service: 'periodictable', // The WSDL service name\n    port: 'periodictableSoap', // The WSDL port name\n    operation: 'GetAtomicNumber' // The WSDL operation name\n  }\n}\n```\n\n**IMPORTANT**: When using the CLI data source generator, you must supply the \"stringified JSON\" value for this property.\nFor example:\n\n```\n{\"getAtomicWeight\":{\"service\":\"periodictable\",\"port\":\"periodictableSoap\",\"operation\":\"GetAtomicWeight\"},\"getAtomicNumber\":{\"service\":\"periodictable\",\"port\":\"periodictableSoap\",\"operation\":\"GetAtomicNumber\"}}\n```\n\nTo generate the stringified value, you can use the following code (for example):\n\n```\nvar operations = {\n  \"operations\": {\n    \"getAtomicWeight\": {\n      \"service\": \"periodictable\",\n      \"port\": \"periodictableSoap\",\n      \"operation\": \"GetAtomicWeight\"\n    },\n    \"getAtomicNumber\": {\n      \"service\": \"periodictable\",\n      \"port\": \"periodictableSoap\",\n      \"operation\": \"GetAtomicNumber\"\n    }\n  }\n};\n\nvar stringifiedOps = JSON.stringify (operations);\nconsole.log(stringifiedOps);\n```\n\n### security property\n\nThe `security` property value is a JSON object with a `scheme` property.\nThe other properties of the object depend on the value of `scheme`.  For example:\n\n```javascript\nsecurity: {\n    scheme: 'WS',\n    username: 'test',\n    password: 'testpass',\n    passwordType: 'PasswordDigest'\n}\n```\n\n\u003ctable\u003e\n  \u003ctbody\u003e\n   \u003ctr\u003e\n    \u003cth\u003eScheme\u003c/th\u003e\n    \u003cth\u003eDescription\u003c/th\u003e\n    \u003cth\u003eOther properties\u003c/th\u003e    \n   \u003c/tr\u003e\n\n   \u003ctr\u003e\n    \u003ctd\u003eWS\u003c/td\u003e\n    \u003ctd\u003eWSSecurity scheme\u003c/td\u003e\n    \u003ctd\u003e\n    \u003cul\u003e\n     \u003cli\u003eusername: the user name\u003c/li\u003e\n     \u003cli\u003epassword: the password\u003c/li\u003e\n     \u003cli\u003epasswordType: default is 'PasswordText'\u003c/li\u003e\n    \u003c/ul\u003e\n    \u003c/td\u003e    \n   \u003c/tr\u003e\n\n   \u003ctr\u003e\n    \u003ctd\u003eBasicAuth\u003csup\u003e1\u003c/sup\u003e\u003c/td\u003e\n    \u003ctd\u003eBasic auth scheme\u003c/td\u003e\n    \u003ctd\u003e    \n    \u003cul\u003e\n     \u003cli\u003eusername: the user name\u003c/li\u003e\n     \u003cli\u003epassword: the password\u003c/li\u003e\n    \u003c/ul\u003e\n    \u003c/td\u003e    \n   \u003c/tr\u003e\n\n   \u003ctr\u003e\n    \u003ctd\u003eClientSSL\u003c/td\u003e\n    \u003ctd\u003eClientSSL scheme\u003c/td\u003e\n    \u003ctd\u003e\n     \u003cul\u003e\n     \u003cli\u003ekeyPath: path to the private key file\u003c/li\u003e\n     \u003cli\u003ecertPath: path to the certificate file\u003c/li\u003e\n    \u003c/ul\u003e    \n    \u003c/td\u003e    \n   \u003c/tr\u003e\n\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n1 **currently unsupported**, use `\"wsdl_headers\": { \"Authorization\": \"Basic …\" },` instead, details: \u003ca href=\"https://github.com/loopbackio/loopback-connector-soap/issues/92\" target=\"_blank\"\u003eissue #92\u003c/a\u003e.\n\n## Creating a model from a SOAP data source\n\nInstead of defining a data source with `datasources.json`, you can define a data source in code; for example:\n\n```js\nds.once('connected', function () {\n\n  // Create the model\n  var PeriodictableService = ds.createModel('PeriodictableService', {});\n\n  // External PeriodTable WebService operation exposed as REST APIs through LoopBack\n  PeriodictableService.atomicnumber = function (elementName, cb) {\n    PeriodictableService.GetAtomicNumber({ElementName: elementName || 'Copper'}, function (err, response) {\n      var result = response;\n      cb(err, result);\n    });\n  };\n...\n}\n```\n\n## Extending a model to wrap and mediate SOAP operations\n\nYou can extend a LoopBack model to wrap or mediate SOAP operations\nand define new methods.\nThe following example simplifies the `GetAtomicNumber` operation:\n\n```javascript\nperiodictableperiodictableSoap.GetAtomicNumber = function(GetAtomicNumber, callback) {\n    periodictableperiodictableSoap.GetAtomicNumber(GetAtomicNumber, function (err, response) {\n      var result = response;\n      callback(err, result);\n    });\n}\n```\n\n## Creating a model from a SOAP data source\n\nThe SOAP connector loads WSDL documents asynchronously.\nAs a result, the data source won't be ready to create models until it's connected.\nThe recommended way is to use an event handler for the 'connected' event; for example\nas shown below.\n\nOnce you define the model, you can extend it to wrap or mediate SOAP operations\nand define new methods. The example below shows adding a LoopBack remote method\nfor the SOAP service's `GetAtomicNumber` operation.\n\n```javascript\n...\nds.once('connected', function () {\n\n  // Create the model\n  var PeriodictableService = ds.createModel('PeriodictableService', {});\n\n  // External PeriodTable WebService operation exposed as REST APIs through LoopBack\n  PeriodictableService.atomicnumber = function (elementName, cb) {\n    PeriodictableService.GetAtomicNumber({ElementName: elementName || 'Copper'}, function (err, response) {\n      var result = response;\n      cb(err, result);\n    });\n  };\n\n  // Map to REST/HTTP\n  loopback.remoteMethod(\n      PeriodictableService.atomicnumber, {\n        accepts: [\n          {arg: 'elementName', type: 'string', required: true,\n            http: {source: 'query'}}\n        ],\n        returns: {arg: 'result', type: 'object', root: true},\n        http: {verb: 'get', path: '/GetAtomicNumber'}\n      }\n  );\n})\n...\n```\n\n## Example\n\nFor a complete example using the LoopBack SOAP connector in LoopBack 4, see [SOAP calculator tutorial](https://loopback.io/doc/en/lb4/soap-calculator-tutorial.html).\n","funding_links":[],"categories":["Enterprise Connectors"],"sub_categories":["Third Party"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floopbackio%2Floopback-connector-soap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floopbackio%2Floopback-connector-soap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floopbackio%2Floopback-connector-soap/lists"}