{"id":17230082,"url":"https://github.com/robinbuschmann/soap-typescript","last_synced_at":"2025-04-14T01:42:28.246Z","repository":{"id":57364922,"uuid":"75713775","full_name":"RobinBuschmann/soap-typescript","owner":"RobinBuschmann","description":"SOAP decorators for creating wsdl's and annotating services to provide metadata for node-soap","archived":false,"fork":false,"pushed_at":"2018-04-22T20:20:01.000Z","size":180,"stargazers_count":19,"open_issues_count":8,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T15:52:34.802Z","etag":null,"topics":["annotations","decorators","schema","soap"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RobinBuschmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-06T09:03:53.000Z","updated_at":"2024-02-12T23:52:22.000Z","dependencies_parsed_at":"2022-09-13T21:01:07.670Z","dependency_job_id":null,"html_url":"https://github.com/RobinBuschmann/soap-typescript","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinBuschmann%2Fsoap-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinBuschmann%2Fsoap-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinBuschmann%2Fsoap-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobinBuschmann%2Fsoap-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobinBuschmann","download_url":"https://codeload.github.com/RobinBuschmann/soap-typescript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248809044,"owners_count":21164895,"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":["annotations","decorators","schema","soap"],"created_at":"2024-10-15T04:52:23.964Z","updated_at":"2025-04-14T01:42:28.226Z","avatar_url":"https://github.com/RobinBuschmann.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/RobinBuschmann/soap-typescript.png?branch=master)](https://travis-ci.org/RobinBuschmann/soap-typescript)\n\n# soap-decorators\nSOAP decorators for creating wsdl's and annotating services to provide metadata for [node-soap](https://github.com/vpulim/node-soap).\n\n## Installation\n```\nnpm install soap-decorators --save\n```\n\n## Usage\n\n### Input and output messages\nDefine input and output message interfaces for a soap service.\n```typescript\nimport {XSDComplexType, XSDElement} from 'soap-decorators';\n\n@XSDComplexType\nexport class CalculatorInput {\n\n  @XSDElement\n  a: number;\n\n  @XSDElement\n  b: number;\n}\n\n@XSDComplexType\nexport class CalculatorResult {\n\n  @XSDElement\n  value: number;\n}\n```\nFor a more advanced usage of creating xsd schemas with decorators \nsee [xsd-decorators](https://github.com/RobinBuschmann/xsd-decorators).\n\n### Soap service and operations\nDefine soap service, its operations and specify input and output \nmessages via the previously defined classes.\n```typescript\nimport {SoapService, SoapOperation} from 'soap-decorators';\n\n@SoapService({\n  portName: 'CalculatorPort',\n  serviceName: 'CalculatorService'\n})\nexport class CalculatorController {\n\n  @SoapOperation(CalculatorResult)\n  add(data: CalculatorInput) {\n\n    return {\n      value: data.a + data.b\n    };\n  }\n\n  @SoapOperation(CalculatorResult)\n  subtract(data: CalculatorInput) {\n\n    return Promise.resolve({\n      value: data.a - data.b\n    });\n  }\n}\n```\n\n### Use soap service with express.js\n*soap-decorators* provides a middleware for express, which does\nall the magic for you. The wsdl will be resolved and the location \naddress and tns will be set automatically.\n```typescript\nimport {soap} from 'soap-decorators';\n\nconst app = express();\nconst calculatorController = new CalculatorController();\n\n// resolves wsdl for you and sets location address and tns to current requested url\napp.use('/soap/calculation', soap(calculatorController));\n```\n\n### Requesting WSDL\nNow you can ask for the **wsdl** by requesting against the defined\nendpoint.\n```\nGET /soap/calculation?wsdl\n```\n*Response*\n```xml\n\u003c?xml version='1.0' encoding='UTF-8'?\u003e\n\u003cwsdl:definitions xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' \n                  xmlns:xsd='http://www.w3.org/2001/XMLSchema' \n                  xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' \n                  name='CalculatorService' \n                  targetNamespace='https://calculation.example.com'\n                  xmlns:tns='https://calculation.example.com'\u003e\n    \u003cwsdl:types\u003e\n        \u003cxsd:schema attributeFormDefault='unqualified' elementFormDefault='unqualified' xmlns:xsd='http://www.w3.org/2001/XMLSchema' targetNamespace='https://calculation.example.com'\u003e\n            \u003cxsd:element name='add' type='tns:CalculatorInput'/\u003e\n            \u003cxsd:element name='CalculatorResult' type='tns:CalculatorResult'/\u003e\n            \u003cxsd:element name='subtract' type='tns:CalculatorInput'/\u003e\n            \u003cxsd:complexType name='CalculatorInput'\u003e\n                \u003cxsd:sequence\u003e\n                    \u003cxsd:element name='a' type='xsd:int'/\u003e\n                    \u003cxsd:element name='b' type='xsd:int'/\u003e\n                \u003c/xsd:sequence\u003e\n            \u003c/xsd:complexType\u003e\n            \u003cxsd:complexType name='CalculatorResult'\u003e\n                \u003cxsd:sequence\u003e\n                    \u003cxsd:element name='value' type='xsd:int'/\u003e\n                \u003c/xsd:sequence\u003e\n            \u003c/xsd:complexType\u003e\n        \u003c/xsd:schema\u003e\n    \u003c/wsdl:types\u003e\n    \u003cwsdl:message name='addMessage'\u003e\n        \u003cwsdl:part name='add' element='tns:add'/\u003e\n    \u003c/wsdl:message\u003e\n    \u003cwsdl:message name='CalculatorResultMessage'\u003e\n        \u003cwsdl:part name='CalculatorResult' element='tns:CalculatorResult'/\u003e\n    \u003c/wsdl:message\u003e\n    \u003cwsdl:message name='subtractMessage'\u003e\n        \u003cwsdl:part name='subtract' element='tns:subtract'/\u003e\n    \u003c/wsdl:message\u003e\n    \u003cwsdl:portType name='CalculatorPortType'\u003e\n        \u003cwsdl:operation name='add'\u003e\n            \u003cwsdl:input message='tns:addMessage'/\u003e\n            \u003cwsdl:output message='tns:CalculatorResultMessage'/\u003e\n        \u003c/wsdl:operation\u003e\n        \u003cwsdl:operation name='subtract'\u003e\n            \u003cwsdl:input message='tns:subtractMessage'/\u003e\n            \u003cwsdl:output message='tns:CalculatorResultMessage'/\u003e\n        \u003c/wsdl:operation\u003e\n    \u003c/wsdl:portType\u003e\n    \u003cwsdl:binding name='CalculatorServiceBinding' type='tns:CalculatorPortType'\u003e\n        \u003csoap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/\u003e\n        \u003cwsdl:operation name='add'\u003e\n            \u003cwsdl:input\u003e\n                \u003csoap:body use='literal' parts='add'/\u003e\n            \u003c/wsdl:input\u003e\n            \u003cwsdl:output\u003e\n                \u003csoap:body use='literal' parts='CalculatorResult'/\u003e\n            \u003c/wsdl:output\u003e\n            \u003csoap:operation soapAction='add'/\u003e\n        \u003c/wsdl:operation\u003e\n        \u003cwsdl:operation name='subtract'\u003e\n            \u003cwsdl:input\u003e\n                \u003csoap:body use='literal' parts='subtract'/\u003e\n            \u003c/wsdl:input\u003e\n            \u003cwsdl:output\u003e\n                \u003csoap:body use='literal' parts='CalculatorResult'/\u003e\n            \u003c/wsdl:output\u003e\n            \u003csoap:operation soapAction='subtract'/\u003e\n        \u003c/wsdl:operation\u003e\n    \u003c/wsdl:binding\u003e\n    \u003cwsdl:service name='CalculatorService'\u003e\n        \u003cwsdl:port name='CalculatorPort' binding='tns:CalculatorServiceBinding'\u003e\n            \u003csoap:address location='https://calculation.example.com/soap/v1'/\u003e\n        \u003c/wsdl:port\u003e\n    \u003c/wsdl:service\u003e\n\u003c/wsdl:definitions\u003e\n```\n### Using operations\n```xml\nPOST /soap/calculation\n\n\u003csoapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:cal=\"https://calculation.example.com\"\u003e\n   \u003csoapenv:Header/\u003e\n   \u003csoapenv:Body\u003e\n      \u003ccal:add\u003e\n         \u003ca\u003e3\u003c/a\u003e\n         \u003cb\u003e1\u003c/b\u003e\n      \u003c/cal:add\u003e\n   \u003c/soapenv:Body\u003e\n\u003c/soapenv:Envelope\u003e\n```\n```xml\nPOST /soap/calculation\n\n\u003csoapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:cal=\"https://calculation.example.com\"\u003e\n   \u003csoapenv:Header/\u003e\n   \u003csoapenv:Body\u003e\n      \u003ccal:subtract\u003e\n         \u003ca\u003e8\u003c/a\u003e\n         \u003cb\u003e4\u003c/b\u003e\n      \u003c/cal:subtract\u003e\n   \u003c/soapenv:Body\u003e\n\u003c/soapenv:Envelope\u003e\n```\n*Response*\n```xml\n\u003csoap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tns=\"http://localhost:3000/calculation\"\u003e\n   \u003csoap:Body\u003e\n      \u003cCalculatorResult\u003e\n         \u003cvalue\u003e4\u003c/value\u003e\n      \u003c/CalculatorResult\u003e\n   \u003c/soap:Body\u003e\n\u003c/soap:Envelope\u003e\n```\n### Retrieving WSDL from class or instance\n```typescript\nimport {createWsdl} from 'soap-decorators';\n\nconst instance = new CalculatorController();\n\ncreateWsdl(instance) === createWsdl(CalculatorController);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinbuschmann%2Fsoap-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobinbuschmann%2Fsoap-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinbuschmann%2Fsoap-typescript/lists"}