⚠️
This is the documentation for the old GraphQL Mesh version v0. We recommend upgrading to the latest GraphQL Mesh version v1.

Migrate to GraphQL Mesh v1

SOAP

image

This handler allows you to consume SOAP WSDL files and generate a remote executable schema for those services.

To get started, install the handler library:

npm i @graphql-mesh/soap

Now, you can use it directly in your Mesh config file:

.meshrc.yaml
sources:
  - name: CountryInfo
    handler:
      soap:
        source: http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL

Headers

If you want to add SOAP headers to the request body like below;

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:header="http://foo.com/">
   <soap:Header>
      <header:MyHeader>
         <header:UserName>user</header:UserName>
         <header:Password>password</header:Password>
      </header:MyHeader>
   </soap:Header>

You can add the headers to the configuration like below;

sources:
  - name: CountryInfo
    handler:
      soap:
        source: ...
        soapHeaders:
          namespace: http://foo.com
          headers:
            MyHeader:
              UserName: user
              Password: password

Body Alias

You can now choose the name of the alias you want to use for SOAP body;

.meshrc.yaml
sources:
  - name: CountryInfo
    handler:
      soap:
        source: ...
        bodyAlias: my-body

Then it will generate a body like below by using the alias;

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:my-body="http://foo.com/">
   <soap:Body>
      <my-body:Foo>
          <my-body:Bar>baz</my-body:Bar>
      </my-body:Foo>
   </soap:Body>
</soap:Envelope>

CodeSandBox Example

You can check out our example that uses SOAP Handler.

Config API Reference

  • source (type: String, required) - A url to your WSDL or generated SDL with annotations
  • schemaHeaders (type: Any) - JSON object representing the Headers to add to the runtime of the API calls only for schema introspection You can also provide .js or .ts file path that exports schemaHeaders as an object
  • operationHeaders (type: JSON) - JSON object representing the Headers to add to the runtime of the API calls only for operation during runtime
  • bodyAlias (type: String) - The name of the alias to be used in the envelope for body components

default: body

  • soapHeaders (type: Object) - SOAP Headers to be added to the request:
    • alias (type: String) - The name of the alias to be used in the envelope

default: header

  • namespace (type: String, required) - The namespace of the SOAP Header For example: http://www.example.com/namespace
  • headers (type: JSON, required) - The content of the SOAP Header For example: { “key”: “value” } then the content will be <key>value</key>