ngx-soap-next
Version:
SOAP service for Angular
280 lines (200 loc) • 6.51 kB
Markdown
[](https://www.npmjs.com/package/ngx-soap-next)
[](https://angular.io)
Simple SOAP client for Angular based on [node-soap](https://github.com/vpulim/node-soap).
**✨ Angular 20 Ready** with full support for signals, standalone components, and modern features.
**🔄 Backwards Compatible** - Works with Angular 10+ (both NgModule and standalone).
```bash
npm install ngx-soap-next
npm install buffer concat-stream core-js crypto-js events lodash sax stream debug
```
**Recommended for new applications**
```typescript
// main.ts
import { bootstrapApplication } from '@angular/platform-browser';
import { provideHttpClient } from '@angular/common/http';
import { provideNgxSoap } from 'ngx-soap-next';
bootstrapApplication(AppComponent, {
providers: [
provideHttpClient(),
provideNgxSoap()
]
});
```
**For existing NgModule apps**
```typescript
import { NgModule } from '@angular/core';
import { NgxSoapModule } from 'ngx-soap-next';
@NgModule({
imports: [NgxSoapModule]
})
export class AppModule { }
```
```typescript
import { Component, inject } from '@angular/core';
import { NgxSoapService, Client, ISoapMethodResponse } from 'ngx-soap-next';
@Component({
selector: 'app-calculator',
standalone: true
})
export class CalculatorComponent {
private soap = inject(NgxSoapService);
client: Client | null = null;
async ngOnInit() {
this.client = await this.soap.createClient('assets/calculator.wsdl');
}
calculate(a: number, b: number) {
if (!this.client) return;
(this.client as any).Add({ intA: a, intB: b })
.subscribe((res: ISoapMethodResponse) => {
console.log('Result:', res.result.AddResult);
});
}
}
```
```typescript
import { Component, computed, model, inject, resource } from '@angular/core';
import { NgxSoapService, ISoapMethodResponse } from 'ngx-soap-next';
@Component({
selector: 'app-calculator',
standalone: true,
template: `
@if (soapClient.isLoading()) {
<p>Loading...</p>
}
@if (soapClient.error()) {
<p>Error: {{ soapClient.error()?.message }}</p>
}
@if (soapClient.value()) {
<input type="number" [(ngModel)]="intA">
<input type="number" [(ngModel)]="intB">
<button (click)="calculate()" [disabled]="!isValid()">Calculate</button>
<p>Result: {{ result() }}</p>
}
`
})
export class CalculatorComponent {
private soap = inject(NgxSoapService);
// 🆕 Angular 20 features
intA = model<number>(0);
intB = model<number>(0);
result = signal('');
isValid = computed(() => !isNaN(this.intA()) && !isNaN(this.intB()));
soapClient = resource({
loader: () => this.soap.createClient('assets/calculator.wsdl')
});
calculate() {
const client = this.soapClient.value();
if (!client) return;
(client as any).Add({ intA: this.intA(), intB: this.intB() })
.subscribe((res: ISoapMethodResponse) => {
this.result.set(res.result.AddResult);
});
}
}
```
Provider function for standalone applications.
```typescript
provideNgxSoap(): EnvironmentProviders
```
### `NgxSoapModule`
NgModule for traditional applications. Includes `NgxSoapService` and `HttpClient`.
### `NgxSoapService`
Main service for creating SOAP clients.
#### `createClient(wsdlUrl, options?, endpoint?): Promise<Client>`
Creates a SOAP client from a WSDL URL.
**Parameters:**
- `wsdlUrl` - URL to WSDL file (relative or absolute)
- `options` - Optional configuration object
- `endpoint` - Optional endpoint override
**Returns:** Promise that resolves to a SOAP Client
**Example:**
```typescript
const client = await this.soap.createClient('assets/service.wsdl');
```
Common options for `createClient()`:
```typescript
{
endpoint: 'https://api.example.com/soap', // Override WSDL endpoint
forceSoap12Headers: false, // Use SOAP 1.2
returnFault: true, // Return faults as data
envelopeKey: 'soap', // Envelope prefix
disableCache: true, // Disable WSDL cache
exchangeId: 'custom-id' // Request tracking ID
}
```
See [full options list](./docs/OPTIONS.md).
```typescript
import { security } from 'ngx-soap-next';
const client = await this.soap.createClient('service.wsdl');
client.setSecurity(new security.BasicAuthSecurity('user', 'pass'));
```
```typescript
client.setSecurity(new security.BearerSecurity('your-token'));
```
```typescript
const wsSecurity = new security.WSSecurity('user', 'pass', {
passwordType: 'PasswordText',
hasTimeStamp: true
});
client.setSecurity(wsSecurity);
```
See all security options: `BasicAuthSecurity`, `BearerSecurity`, `WSSecurity`, `WSSecurityCert`, `WSSecurityCertWithToken`, `WSSecurityPlusCert`.
This package version follows Angular versions:
- `0.20.x` = Angular 20
- `0.19.x` = Angular 19
- `0.18.x` = Angular 18
See [CHANGELOG.md](./CHANGELOG.md) for details.
```bash
npm install
npm test
npm run test:lib
npm run test:coverage
npm run build:lib
npm run build
npm start
```
See example app in `src/app/` for full working demos.
```bash
npm run bump:patch
npm run bump:minor
npm run build:lib:publish
npm run build:lib:publish:dry-run
```
MIT
- [GitHub Repository](https://github.com/seyfer/ngx-soap)
- [npm Package](https://www.npmjs.com/package/ngx-soap-next)
- [Issues](https://github.com/seyfer/ngx-soap/issues)
- [Example App](./src/app) - Working Angular 20 examples
Based on [node-soap](https://github.com/vpulim/node-soap) by vpulim.
**Maintainers:**
- [Oleg Abrazhaev](https://github.com/seyfer)
- [Luca Lulani](https://github.com/lula)
- [Marc Ward](https://github.com/marcward)