/
Hello World SOAP Example

Hello World SOAP Example

 

This example will create a SOAP API hello world example that will allow a couple parameters to be passed into the API and will return a hello message incorporating the name passed in.

Open the workspace 

(If you haven't created an example workspace, create a workspace called papihello. See Using Workspaces

Open the example workspace by pointing your browser to the URL:

http://[HOST]:[PORT]/ide/papihello

Where host is the server you installed Profound.js on and port is the port number Profound.js is running on. If the installation is on your PC or Mac computer, use localhost.

OR open the workspace from the ide with the Open button and then select the example workspace:

 

Create API file

Create a new SOAP API JSON file by clicking the New button and selecting API file. Select SOAP from the drop down in the pop-up and click Create. The file will be opened and the Canvas, Schema, Input and Output Message Parts, API Routes, and General Info panel will be initialized.

            

 

Set General Info

On the left hand lower panel select the General Info tab and fill on the following values

  • Name: soapHello

  • Summary: Hello SOAP API example

  • HTTP Path: /soaphello

  • Category, Sub Category, Tag, and Description all help improve documentation and organization. 

 

Building the Schema Definition

SOAP messages are defined using an XML-based schema, which provides a standardized way to describe the structure and content of the messages.

For this example we will define a complex type that we can use for input which will allow us to provide multiple properties values. We will also define a simple element to use for our output.

On the Schema tab at the bottom click on the green plus sign. For Tag select complexType, and personType for the name and then click OK

We will add a sequence tag to indicate the child elements must appear in sequence. While the complexType is selected in the Schema list, click the plus sign again. Select sequence and then click OK.

 

Next we will add 2 elements to the sequence. Each time, make sure the sequence tag is selected in the list and then click the plus sign. First we will create a name element. select element, enter name as the name, and then select xsd:string as the Data type.

Then repeat the process to add age of type xsd:integer.

                 

Finally we will add elements at the root level that out inputs and outputs can be bound to.

Add a person element that is Data type tns:personType. Then add a message element type xsd:string.

 

             

It is sometimes difficult to create a record at the correct level. However, it is very easy to rearrange the elements by clicking and dragging.

 

Once complete the Schema tab should look like this.

 

Input Message Parts and Output Message Parts

We are now ready to add the inputs and outputs

On the Input tab click the green plus sign to open the dialog. enter parameters as the name. Check the Bind to Element box and then select tns:person from the drop down. the person element is already defined to contain both the name and age.

Note: only element tags at the root will be available to select in the Binding box

   

On the outputs tab, click plus and add a parameter named message bound to the message element.

 

     

 

Adding the Logic

Adding Low Code steps is the same whether you are creating a REST API or a SOAP API except that the input parameters are named a little differently. 

For this example we will only add 1 step which will be to set the API output message concatenating a hello message and the name that is passed in.

Click Add Step and then select Program Data and then Set API Output.

   

Sometimes it is helpful to expand the dialog when entering longer values. You can do this by clicking and holding on the lower right corner and dragging the dialog larger.

 

For the value of the message output enter "Hello " + input["person"]["name"]

This is where things are a little different. If you look at what we set up in the Input tab  

It may seem like you should refer to the input as input["parameters"]. However, because the parameters is bound to the element named person, you will use input["person"].  These can both be named the same but were intentionally named differently to make this point.

Done

Click and you have created a SOAP API.

 

Testing

Currently the built in testing tab in Profound API does not support SOAP APIs.

Fortunately, SOAP APIs are easy to test using tools like SoapUI ( https://www.soapui.org/downloads/soapui/ )

You will first need to get the WSDL for your new SOAP API. There is detailed information about the WSDL available at Obtaining a WSDL file from a SOAP API Route. You will need the address to the WSDL to start a SOAP project in SoapUI.

The URL for the WSDL is the project run URL followed by ?wsdl

If you used the same workspace and route names as described in these directions the address will be: http://[HOST]:[PORT]/run/papihello/wsapi/soaphello?wsdl

You can verify the WSDL is available by entering the URL in a web browser. (In my example I am running Profound API locally on port 8081. Your server and port may be different)

In SoapUI click the SOAP button or File > New SOAP Project to open the New SOAP Project dialog.

Give the project a name and add the wsdl url in the Initial WSDL  field and click OK. The project will be displayed. Expand the node to see the sample request.

                                   

 

Double click the sample request to the open it.

 

Enter values for the name and age properties and then click the green arrow at the top of the request.

If everything went right you will see your response in the right hand panel.