# SOAP Client

> Make SOAP Web Service calls.

Source: https://docs.sommatic.ai/en/nodes/io.soap/

- Slug: `io.soap`
- Family: Input and output
- Version: 1.0.0
- Status: Available
- Execution: async

Make SOAP Web Service calls.

## Configuration

- `connection_id` (string, required): Credential for the SOAP endpoint / WSDL. Accepts credentials of type `basic-auth` (username + password) or `object` (WSDL URL + advanced config).
- `method` (string, required)
- `args` (object, optional)

## Output ports

- `out` (default): Soap response
- `error`: Soap fault or error

## Input contract

- `connection_id` (string, required)
- `method` (string, required)
- `args` (object, optional)

## Output contract

- `result` (object, optional): SOAP Result

## In expressions

What a later node can read from this node's output with `$("SOAP Client").item.json.<path>` (write your node's label instead of `SOAP Client`). **Editor** marks the paths the workflow editor suggests under Previous Nodes (the output contract); **Worker** marks the paths the worker really returns through `out`, from the output shown in Ports.

- `$("SOAP Client").item.json.result` (object) = `{…}`: SOAP Result
- `$("SOAP Client").item.json.result.GetQuoteResult` (object) = `{…}` (Not suggested by the editor)


## How it works

Loads a WSDL from a credential, calls one SOAP operation with `args` and returns the parsed result object.

1. Resolves the config. `connection_id`, `method` and `args` (default `{}`) fall back to the same keys of the incoming payload; `connection_id` and `method` are required.
2. Resolves the credential: the WSDL URL is `config.wsdl` (or `config.url`); `username`, `password` and `token` come from the secret.
3. Downloads the WSDL and builds the client. Sets HTTP Basic security when `username` and `password` exist, else Bearer security when `token` exists.
4. Calls the operation `method` with `args` and returns the first element of the reply (the parsed result object) as `{ result }` through `out`.

## In a workflow

### Node

```json
{
  "node_id": "node-get-quote",
  "label": "Get quote",
  "operator_slug": "io.soap",
  "operator_version": "1.0.0",
  "config": {
    "connection_id": "pi-credential-xxxx",
    "method": "GetQuote",
    "args": {
      "Symbol": "{{ $json.symbol }}"
    }
  }
}
```

### Envelope

```json
{
  "ok": true,
  "data": {
    "result": {
      "GetQuoteResult": {
        "Symbol": "ACME",
        "Price": "42.17"
      }
    }
  },
  "port": "out"
}
```

## Output ports (behaviour in the code)

### `out`

The operation answered without a SOAP fault. `result` is the response body converted to a JavaScript object.

```json
{
  "result": {
    "GetQuoteResult": {
      "Symbol": "ACME",
      "Price": "42.17"
    }
  }
}
```

### `error`

A required field is missing, the WSDL cannot be loaded, the operation does not exist, or the server returned a SOAP fault or an HTTP error.

```json
{
  "error": "Method \"GetQuote\" not found in WSDL"
}
```

## Behaviour in the code

- `connection_id`: Accepts `basic-auth` or `object` credentials with `wsdl` (or `url`) in the config. A value starting with `http://`, `https://` or `localhost` is used as the WSDL URL itself, without authentication.
- `args`: An object whose keys are the element names of the operation's input message.

## Errors

| Message | Port | Cause and fix |
| --- | --- | --- |
| `WSDL URL not found in connection config` | `error` | The credential config has neither `wsdl` nor `url`. |
| `Method "<method>" not found in WSDL` | `error` | The WSDL has no operation with that name. Use the operation name exactly as declared in the WSDL. |
| `<SOAP fault or HTTP error message>` | `error` | The server rejected the call. Check that `args` matches the input message of the operation. |
| `method is required` | `error` | No operation name in the config nor in the incoming payload (`connection_id is required` is the equivalent for the credential). |

## Notes and limits

- The WSDL is downloaded and parsed on every run. No timeout and no retries.
- Only the parsed result is returned; the raw XML and SOAP headers of the response are not exposed.


## Contracts (JSON Schema)

### All (`*.definition.js`)

```json
{
  "slug": "io.soap",
  "name": "SOAP Client",
  "category": "io",
  "version": "1.0.0",
  "description": "Make SOAP Web Service calls.",
  "capabilities": [
    "soap",
    "api",
    "xml",
    "legacy"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "connection_id": {
        "type": "string",
        "title": "SOAP Credential",
        "description": "Credential for the SOAP endpoint / WSDL. Accepts credentials of type `basic-auth` (username + password) or `object` (WSDL URL + advanced config).",
        "ui_widget": "connection_picker",
        "ui_options": {
          "credential_types": [
            "basic-auth",
            "object"
          ],
          "types": [
            "soap"
          ]
        }
      },
      "method": {
        "type": "string"
      },
      "args": {
        "type": "object"
      }
    },
    "required": [
      "connection_id",
      "method"
    ]
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "connection_id": {
        "type": "string"
      },
      "method": {
        "type": "string"
      },
      "args": {
        "type": "object"
      }
    },
    "required": [
      "connection_id",
      "method"
    ]
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "result": {
        "type": "object",
        "description": "SOAP Result"
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Response",
      "description": "Soap response",
      "is_default": true,
      "supports_condition": true
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Soap fault or error",
      "is_default": false,
      "supports_condition": false
    }
  ],
  "execution_mode": "async",
  "required_resources": [],
  "compatible_worker_pools": [
    "standard-io",
    "legacy-io"
  ],
  "tags": [
    "api",
    "legacy"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_link_loom",
    "profile": {
      "name": "Link Loom",
      "verified": true,
      "url": "https://me.veripass.com/link-loom",
      "logo_url": null
    }
  }
}
```

### config_schema

```json
{
  "type": "object",
  "properties": {
    "connection_id": {
      "type": "string",
      "title": "SOAP Credential",
      "description": "Credential for the SOAP endpoint / WSDL. Accepts credentials of type `basic-auth` (username + password) or `object` (WSDL URL + advanced config).",
      "ui_widget": "connection_picker",
      "ui_options": {
        "credential_types": [
          "basic-auth",
          "object"
        ],
        "types": [
          "soap"
        ]
      }
    },
    "method": {
      "type": "string"
    },
    "args": {
      "type": "object"
    }
  },
  "required": [
    "connection_id",
    "method"
  ]
}
```

### input_contract_schema

```json
{
  "type": "object",
  "properties": {
    "connection_id": {
      "type": "string"
    },
    "method": {
      "type": "string"
    },
    "args": {
      "type": "object"
    }
  },
  "required": [
    "connection_id",
    "method"
  ]
}
```

### output_contract_schema

```json
{
  "type": "object",
  "properties": {
    "result": {
      "type": "object",
      "description": "SOAP Result"
    }
  }
}
```

### ports

```json
[
  {
    "port_id": "out",
    "label": "Response",
    "description": "Soap response",
    "is_default": true,
    "supports_condition": true
  },
  {
    "port_id": "error",
    "label": "Error",
    "description": "Soap fault or error",
    "is_default": false,
    "supports_condition": false
  }
]
```
