Temp Conversion SOAP API

From DreamFactory
Jump to: navigation, search
DreamFactoryTutorialsTemp Conversion SOAP API

DreamFactory can automatically wrap any SOAP WSDL with REST. This tutorial shows how to configure a SOAP service with an example of a public temperature conversion WSDL.

Note: In Windows Bitnami environments you'll need to edit the php.ini file found from the installation path: C:\Bitnami\dreamfactory-2.1.1-0\php. Uncomment the extension by removing the semicolon.


Create the SOAP Service

  • In the admin console, go to the Services tab and click Create.
  • Set the Service Type to 'SOAP Service'.
  • Set the service name to 'temp'. This will be part of the URL when you call the service.
  • Set the label to ‘Temperature’.
  • Click the Config tab and enter the WSDL URI for the SOAP service. Set it to 'http://www.w3schools.com/xml/tempconvert.asmx?WSDL'.
  • Click Create Service to save your new service.

Call the SOAP Service via REST

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.

GET http://localhost:8888/api/v2/temp
  "resource": [
      "name": "CelsiusToFahrenheit"
      "name": "FahrenheitToCelsius"

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.

POST http://localhost:8888/api/v2/temp/CelsiusToFahrenheit

  "Celsius": "100"

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.

  "CelsiusToFahrenheitResult": "212"

Since it's JSON, the result can be accessed as response.CelsiusToFahrenheitResult. For the other operation FahrenheitToCelsius, the request looks like this.

POST http://localhost:8888/api/v2/temp/FahrenheitToCelsius

  "Fahrenheit": "32"

And the response is:

  "FahrenheitToCelsiusResult": "0"

Your app can make the same calls as the API Docs. Just use the request URLs in the API docs as examples. This feature lets you access your SOAP services easily using REST and JSON and use role-based access control to limit which apps and users have access to those services.