Deploy a Callback Service with SoapUI

Introduction

Some requests sent to the Verizon ThingSpace Platform might take some time to process. Instead of blocking your application during that time, the ThingSpace Platform sends back an immediate (synchronous) acknowledgement that it has received and accepted the request, and it will send a complete response as a callback message when it has finished processing the request. In order to receive callback messages, you must set up some kind of listening service on your server, and then register it with the ThingSpace Platform so that it knows where to send the responses.

This tutorial provides step-by-step instructions for deploying a callback listening service on SmartBear's SoapUI 4.5.1 and registering the services with the Verizon ThingSpace Platform.

Before You Begin

The steps in this procedure assume that you have:

Configure Firewalls (White-Listing)

Firewalls are designed to block unwanted traffic coming from the Internet to an inside host. To make use of the callback feature described in this document, you must configure any firewalls between your computer and Verizon's ThingSpace Platform servers to allow the appropriate connections. (This is known as "white-listing.")

You (or someone at your company) should have received the list of IP addresses used by the Verizon M2M servers when your company was approved for API access to the ThingSpace Platform.

In addition to the main corporate firewall at your company, there may be internal firewalls, and your PC may have a firewall. All of these must be set to allow incoming traffic from Verizon for the specific port number on which you choose to set up your callback service.

Security Precaution

The "hole" in your PC firewall may compromise the security of your PC. You should reinstate the firewall when the open port is no longer required.

Configure SoapUI

To replicate the configuration used in this tutorial, make the following settings in the SoapUI application:

  1. Go to File > Preferences > UI Setting and enable "Wraps content in Raw Message Viewers".
  2. Go to File > Preferences > Editor Setting and enable "Defaults the Request editor to the tabbed layout".

Create a Callback Listening Service

Load the Callback Service WSDL

From within SoapUI, load the Callback Service wsdl.

  1. Navigate to File > New SOAP Project.
  2. Enter "CallbackListeningService" as the Project Name.
  3. Click Browse and then navigate to the "callback wsdls" directory in the unzipped SDK and select CallbackService.wsdl.
  4. Accept all defaults by clicking OK.

Create and Configure the Callback Listening Service

  1. Highlight the CallbackListeningService project you created in the previous task.
  2. Right-click and choose Generate MockService.
  3. In the Generate MockService window, go to the Port field and enter the port number that you opened on your firewall (this procedure uses port 50559).
  4. Click OK.

Set the Callback Respnose

Your callback service must acknowledge receiving each callback message, or the ThingSpace Platform will resend the message and eventually mark the callback as failed. An acknowledgement sends the request ID back to the service.

  1. Open the mock response (Response 1) and click the Script button in the bottom left.
  2. Paste in this script:

    // create XmlHolder for request content
    def holder = new com.eviware.soapui.support.XmlHolder(mockRequest.requestContent)
    // define the namespace used in request elements
    holder.namespaces["ns"] = "http://nphase.com/unifiedwebservice/v2"
    def reqId = holder.getNodeValue("//ns:RequestId")
    requestContext.requestid = reqId
        
  3. Save and close the window.

Start the Callback Listening Service

  1. Navigate to your newly created CallbackListeningService MockService and double-click on Callback.
  2. In the CallbackListeningService MockService window, click the green arrow icon to start the service.

    You should see a remark at the top of the window stating that the service is running on port 50559 (or whatever port you chose).

Check the Callback Listening Service

To check the service locally:

  1. Open your browser and go to http://127.0.0.1:50559/mockCallbackListeningService?wsdl.
  2. Verify that you see the XML file.

    If the MockService is not running, you will receive an error message.

Register the Callback Listening Service

Before registering the callback listening service that you created using this tutorial, you must first check to ensure that no services are currently registered with the ThingSpace Platform.

  1. Run the GetCallbackRegistrationService API in your SoapUI tool to request all callback registrations currently active for your account from the server.

  2. If a service is registered, unregister it using the Unregister Callback API.

After you have ensured that no other services are registered, you must register your callback listening service. You can register a service without credentials, or you can add another layer of security with one-way authentication. Both methods are explained in this section.

NOTE: The Verizon ThingSpace Platform supports multiple callback services, which require separate registration. Refer to the Callback Registration Service page for a comprehensive list of callback services included in the ThingSpace Platform.

To register a callback listening service without credentials:

  1. Find your IP address and register the callback listening service URL using the following address (replace your_ip:your_port_number with your information):

    http://your_ip:your_port_number/mockCallbackService?wsdl

    NOTE: Allowed port numbers for new callback registrations are 80, 443, 9001-9006 and 50551-50559.

    Leave the username and password fields blank.

  2. Use the GetCallbackRegistrationService API to check that the new URL is listed.

To use one-way authentication, register your callback listening service as explained above, plus supply username and password:

When you register a callback listening service with credentials, every callback carries the credentials in the XML data.

Use the Callback Service

  1. Double-click the CallbackListeningService MockService you created in Section 2.3 (Start the Callback Listening Service) to open the service window.
  2. Click the green arrow icon to start the service.

  3. Issue an asynchronous command that will create a callback, such as using UpdateDeviceInformation to change a custom field.

  4. Look for a notification of a response in the CallbackListeningService MockService window.
  5. Double-click on the actual callback to open a response window.
  6. Click in the pop-up response window to make the window active.
  7. Press Alt-F on your keyboard to format for XML.

Troubleshooting with Wireshark

When your Callback Listening Service is not responsive, you can use Wireshark® (http://www.wireshark.org) to verify that you are receiving traffic destined for your configured port. Look for the following: