Creating a Simple SOAP Web Service

In this section:

There are several steps for creating a configuration that will make a configuration Plan or Component available as a Web service.


Top of page

x
Preconditions

In this example, you will create a service that verifies the first name and last name of certain individuals and returns their phone number in the output. Assume that you have created the component phonebook.comp.

This component contains an Integration Input Step named phonebook_in, and an Integration Output Step named phonebook_out.

The Input Step has the following columns:

The Output Step has the following columns:


Top of page

x
Procedures for Creating the Service

This example consists of four procedures.



x
Procedure: How to Create the Online Service Configuration
  1. Right-click the phonebook.comp item in the DQC Explorer tree and click the Publish as Online Service menu item. The Publish Component as Service dialog box opens.
  2. In the Input drop-down list, click the phonebook_in input step and click SOAP format in the drop-down list on the right.
  3. In the Output drop-down list, click the phonebook_out output step and click SOAP format in the drop-down list on the right.

    The selection SOAP format means that the content of the input and output messages will have a SOAP message structure.

    The following image shows the Publish Component as Service dialog box.

    Publish Compoent as Service dialog box

  4. Click the Next button.
  5. In the dialog box that opens, type the name of the online service configuration file. By default, it is the name of the component with a .online suffix. Change it to phoneService.online and click the Finish button.

    In the following image, the name of the online service configuration file is supplied in the File input field.

    File input field

    The phoneService.online file is created and opened in the GUI editor. As you can see by some errors, the configuration is not finished. You can see all the errors in the Properties view. You must supply the namespaces that you want to use in the messages.



x
Procedure: How to Supply Namespaces
  1. Double-click an error message.
  2. Supply the namespace URI, for example, http://example.com/webservices. You can set different namespaces for the input and output. In this example, you use the same values for both input and output.

    The following image shows the errors in the Properties view.

    Errors in Properties view



x
Procedure: How to Change the Service Location

By default, the location of the service is set to the same value as the name of the online service configuration file without the extension. You can change the location.

  1. Click the Input node in the left tree. A dialog box, in which you can change the location, opens.
  2. Type the service location in the Location input field.

    In the following image, the service location is supplied in the Location input field.

    Location input field

    Now the service configuration is ready to be deployed on the server. But first look at another feature.



x
Procedure: How to Rename XML Elements (nodeName Attribute)

It is possible to have different column names in the online configuration and in the configuration Plan or Component. You will change the nodeName attribute of the input and output columns.

  1. Select the first XmlColumn element in the input section.
  2. Change the nodeName value to firstname_in.
  3. Select the second XmlColumn element in the input section.
  4. Change the nodeName value to lastname_in.

    In the following image, the values for nodeName are supplied in the fields in the input section.

    nodeName supplied in fields in input section

  5. Similarly, rename the nodeName values to firstname_out and lastname_out for the XmlColumns in the output section.

    In the following image, the values for nodeName are supplied in the fields in the output section.

    nodeName supplied in fields in output section

  6. Try the service by running it internally on the local computer. Just open the phoneService.online configuration file, and click the Start icon in the toolbar.

Top of page

x
Sample Input Message

Use a sample SOAP input message similar to the following:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope 
   xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  xmlns:ns1="http://example.com/webservices">
  <soap:Body>
    <ns1:phonebook>
      <ns1:firstname_in>Ferda</ns1:firstname_in>
      <ns1:lastname_in>Mravenec</ns1:lastname_in>
    </ns1:phonebook>
  </soap:Body>
</soap:Envelope>

Top of page

x
Sample Output Message

As a result, you receive a message similar to the following:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:ns1="http://example.com/webservices"  
  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <ns1:serviceResponse>
      <ns1:phonebookResponse>
        <ns1:firstname_out>Ferda</ns1:firstname_out>
        <ns1:lastname_out>Mravenec</ns1:lastname_out>
        <ns1:phone>+420111222333</ns1:phone>
      </ns1:phonebookResponse>
    </ns1:serviceResponse>
  </soap:Body>
</soap:Envelope>

iWay Software