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

json2Soap

Version

Converts a JSON body to the SOAP message of a WSDL operation: in the request flow to the operation's request, in the response flow to its response. The XML Schema of the WSDL decides the names, namespaces and order of the elements; a JSON array becomes a repeated element, properties prefixed with @ become XML attributes, $value becomes the text of an element that also carries attributes, and null becomes xsi:nil. This is the mapping wsdl2openapi applies to requests, and the reverse of soap2Json.

Without a configured operation, the operation recorded by soap2Json in the request flow is used. Together they put a SOAP interface in front of a JSON backend, as in the example.

A converted request is sent with POST and carries the SOAPAction header (SOAP 1.1) or the action in the Content-Type (SOAP 1.2) that the WSDL binding declares. A converted response has status 200. A response of the backend with an error status becomes a SOAP Fault, Client for a 4xx status and Server otherwise; what the backend sent is not passed on. A fault has status 500, except a Client fault in SOAP 1.2, which has status 400. Errors are reported in the format of the client: problem details (RFC 7807) for the JSON client in the request flow, a SOAP Fault for the SOAP client in the response flow. Messages without a body pass through unchanged. Only document/literal messages are supported. Placed directly in a flow, it converts in both directions, so it usually goes under request or response.

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

Example Configuration

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

Syntax

json2Soap:
wsdl: <string> # required
operation: <string>
port: <string>
service: <string>
json2Soap:
  wsdl: <string> # required
  operation: <string>
  port: <string>
  service: <string>

Attributes

NameRequiredDefaultDescriptionExamples
operationfalse-The WSDL operation whose message the JSON is converted to. Without it, the operation is taken from the exchange property membrane.soap.operation, which soap2Json sets in the request flow and which can also be set with setProperty. A message whose operation is not known is not converted and is answered with an error.getCity
portfalse-The name of the port of the service whose messages are produced. It also decides the SOAP version. 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 produced. 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