An open API service indexing awesome lists of open source software.

https://github.com/robinbuschmann/soap-typescript

SOAP decorators for creating wsdl's and annotating services to provide metadata for node-soap
https://github.com/robinbuschmann/soap-typescript

annotations decorators schema soap

Last synced: about 1 year ago
JSON representation

SOAP decorators for creating wsdl's and annotating services to provide metadata for node-soap

Awesome Lists containing this project

README

          

[![Build Status](https://travis-ci.org/RobinBuschmann/soap-typescript.png?branch=master)](https://travis-ci.org/RobinBuschmann/soap-typescript)

# soap-decorators
SOAP decorators for creating wsdl's and annotating services to provide metadata for [node-soap](https://github.com/vpulim/node-soap).

## Installation
```
npm install soap-decorators --save
```

## Usage

### Input and output messages
Define input and output message interfaces for a soap service.
```typescript
import {XSDComplexType, XSDElement} from 'soap-decorators';

@XSDComplexType
export class CalculatorInput {

@XSDElement
a: number;

@XSDElement
b: number;
}

@XSDComplexType
export class CalculatorResult {

@XSDElement
value: number;
}
```
For a more advanced usage of creating xsd schemas with decorators
see [xsd-decorators](https://github.com/RobinBuschmann/xsd-decorators).

### Soap service and operations
Define soap service, its operations and specify input and output
messages via the previously defined classes.
```typescript
import {SoapService, SoapOperation} from 'soap-decorators';

@SoapService({
portName: 'CalculatorPort',
serviceName: 'CalculatorService'
})
export class CalculatorController {

@SoapOperation(CalculatorResult)
add(data: CalculatorInput) {

return {
value: data.a + data.b
};
}

@SoapOperation(CalculatorResult)
subtract(data: CalculatorInput) {

return Promise.resolve({
value: data.a - data.b
});
}
}
```

### Use soap service with express.js
*soap-decorators* provides a middleware for express, which does
all the magic for you. The wsdl will be resolved and the location
address and tns will be set automatically.
```typescript
import {soap} from 'soap-decorators';

const app = express();
const calculatorController = new CalculatorController();

// resolves wsdl for you and sets location address and tns to current requested url
app.use('/soap/calculation', soap(calculatorController));
```

### Requesting WSDL
Now you can ask for the **wsdl** by requesting against the defined
endpoint.
```
GET /soap/calculation?wsdl
```
*Response*
```xml































































```
### Using operations
```xml
POST /soap/calculation




3
1

```
```xml
POST /soap/calculation




8
4

```
*Response*
```xml



4

```
### Retrieving WSDL from class or instance
```typescript
import {createWsdl} from 'soap-decorators';

const instance = new CalculatorController();

createWsdl(instance) === createWsdl(CalculatorController);
```