by Todd Appleton
• March 2, 2016
DreamFactory allows you to REST enable databases, file storage, remote web services, and more. Now you can also access XML based SOAP services using the DreamFactory REST API. Request and response payloads between your app and DreamFactory are in JSON format. DreamFactory takes care of converting the JSON request to a SOAP request and the SOAP response to a JSON response. We auto-generate a Swagger service definition from the service’s WSDL so you can use the API Docs tab in the admin console to test your service, then use the generated URLs to call the service from your own app.
In this blog post I’ll show you how to configure DreamFactory to connect to a simple SOAP service for fahrenheit/celsius temperature conversion. Before we get started, have a look at the WSDL for this simple service. Ummm yeah, this is what we’d like to avoid. Here we go. No XML, no fuss.
Create a new SOAP service
Explore the service in API Docs
Click on the API Docs tab in the admin console, and select the ‘temp’ service from the list. It’ll expand to show the available operations.
This UI was auto-generated based on the information obtained from the WSDL you specified when creating the service.
Click the blue GET button next to /temp then scroll down and click the Try it out! button. You’ll see the request URL and response.
It also shows the cURL command for the request. The URL ends with ‘temp’ which is the service name. Since we did a GET on the service name, the response indicates the available operations for the service, CelsiusToFahrenheit and FahrenheitToCelsius. Again, all of this information was discovered from the WSDL when the service was created.
To call one of these functions, click the green POST button next to /temp/CelsiusToFahrenheit.
Click Model Schema in the lower right, then click in the yellow text area to auto-populate the body text area. Change the value in the request body from “string” to a celsius temperature to convert. This is the JSON payload for your request. Click Try it out! and you’ll see the request URL, this time with the operation name CelsiusToFahrenheit appended to the service name.
The response contains the converted temperature. It’s a single value in this case, but of course the JSON can be more complex depending on your SOAP service.
Since it’s JSON, the result can be accessed as response.CelsiusToFahrenheitResult. For the other operation FahrenheitToCelsius, the request looks like this.
And the response is
Your app can make the same calls as the API Docs. Just use the request URLs in the API docs as examples. The beauty of all this is that you can access your SOAP services easily using REST and JSON, and also use roles to limit what apps and users have access to those services. Try using DreamFactory to access your own SOAP services and let us know what you think.
Join the DreamFactory newsletter list.