Open Source API Gateway
6. Web Services with SOAP and WSDL

soap2Json

Version

Converts the Body of a SOAP 1.1 or 1.2 message to JSON, using the WSDL to map it. The element in the Body selects the message of the WSDL, and its XML Schema decides the shape of the result: numbers and booleans come out typed, an element that may repeat is always a JSON array, and xsi:nil becomes null. XML attributes appear as properties prefixed with @; the text of an element that also carries attributes appears under $value. This is the mapping wsdl2openapi applies to SOAP responses.

A message the WSDL does not declare, a SOAP Fault, or XML that cannot be converted is answered with a problem details document (RFC 7807): status 400 in the request flow, 500 in the response flow. A body that is not XML, such as an MTOM/XOP package, is answered the same way, with status 415 in the request flow. For a fault from a service, the content of a fault the WSDL declares appears under details, keyed by the name of the declared fault. SOAP headers are not part of the result. Only document/literal messages are supported. Messages without a body pass through unchanged.

In the request flow, the operation the request belongs to is recorded in the exchange property membrane.soap.operation, so that json2Soap can turn the JSON answer of a backend back into that operation's SOAP response.

 soap2Json:
   wsdl: <url or path>
   [ service: <service name> ]
   [ port: <port name> ]
 

Example Configuration

api:
port: 2000
flow:
- response:
- soap2Json:
wsdl: cities.wsdl
target:
url: http://localhost:2001
api:
   port: 2000
   flow:
     - response:
         - soap2Json:
             wsdl: cities.wsdl
   target:
     url: http://localhost:2001

Syntax

soap2Json:
wsdl: <string> # required
port: <string>
service: <string>
soap2Json:
  wsdl: <string> # required
  port: <string>
  service: <string>

Attributes

NameRequiredDefaultDescriptionExamples
portfalse-The name of the port of the service whose messages are converted. Only needed when the service has ports for different interfaces; of the SOAP 1.1 and 1.2 ports of one interface, the SOAP 1.1 port is chosen.CitySoap12Port
servicefalse-The name of the WSDL service whose messages are converted. Only needed when the WSDL declares more than one service.CityService
wsdltrue-The WSDL that describes the SOAP messages: a URL or a file path, relative to the configuration file.cities.wsdl

Can be used in