MOND Cloud by ConnectGlobalOne

Lesson 9 Link to other lessons

Define a Web Service that returns multiple values


In this section you will learn how easy it is to define a Web Service that return multiple output parameters.

Web Service Overview

MOND provides a browser based Wizard for defining Web Services. Using the Wizard, Web Service definition is simplified into a 6 step process. Once the Web Service is defined using the wizard, you can generate the WSDL and the documentation for the Web Service and its operations by the click of a button.

Challenges in returning multiple values from a Web Service

According to the industry Returning Multiple WS values is not easy., Although returning multiple values from a Web Service is quite a common requirement, it could be quite a daunting task for a beginner learning web service." This is because, in Java a method cannot return multiple values. Java provides a workaround by using the concept of WS Holder. MOND WS makes it extremely easy to return multiply values by generating the java code to take care of multiple output parameters.

Example Web Service

In 20 minutes or less, let us create a Web Service that takes two input numbers, and returns the sum and product of the two numbers.

Requirements

There is no software to download, install. No knowledge of Java/WSDL is required.The development and testing can be done using a browser.You do not need Eclipse to create the web services or SOAPUI to test it.

Define Web Service

  • Click here to login to MOND BPM
  • Navigate to Wizards -> Web Service Page

Step 1


  • Click New Web Service.
  • In the Web Service Name field, enter the name "MathService" for the Web Service
  • In the Version field, enter the version number "1.0". You can use the version number to trace and control the change history of the Web Service.
  • In the Namespace field, enter the namespace "com.fin.math". The Namespace is a logical name for information about this service. Please ensure that the namespace entered is unique across all Web Services.
  • In the Description field, enter a brief description for the Web Service. The documentation generated for the Web Service will contain the description and hence it is only appropriate to mention a detailed description of the Web Service.This will also be part of the generated document.
  • Click Next

Step 2


  • Click New Operation..
  • In the Web Service Operation field, enter a name for the Web Service Operation. There should not be any spaces in the Web Service Operation name.
  • In the Description field, enter a brief description for the Web Service Operation. The documentation generated for the Web Service will contain the description and hence it is only appropriate to mention a lucid description of the Web Service Operation.
  • Click Next.

Step 3


Enter Web Service Operation Input Details

  • Click Add New Row and choose int in Data Type drop down and type firstNumber in Field Name. Press Enter to save row.
  • Click Add New Row and choose int in Data Type and type secondNumber in Field Name. Press Enter to save row.
  • Click Next.

Step 4


Enter Web Service Operation Output Details

  • Click Add New Row and choose int in Data Type and type sumOutput in Field Name. Press Enter to save row.
  • Click Add New Row and choose int in Data Type and type productOutput in Field Name. Press Enter to save row.
  • Click Next.

Step 5


Enter Web Service Operation Implementation Details

  • In the Project field, select a Project where the Web Service implementation map will be created. Choose New Project and enter project name MathProjects
  • In the Map field, select New Map in order to define a new implementation map.
  • In the Map Name field, enter the name of the implementation map. You can enter AddAndMultiplyMap
  • Click Next.

Step 6


Publish Web Service

  • Click Save & Publish
  • Once the Web Service details are saved successfully, you will receive success message.
  • Click x button on the success message

Step 7


  • Once Web Service is saved successfully, the deployment process would have started in the background.
  • The deployment process may take 20-30 seconds. While it is being deployed, you will see intermediate status messages from the deployment process. For example, you may see something like “Compiling required classes”, “Generating Service Endpoint” etc.

Step 8


  • Once the Web Service is fully deployed, you will see the WSDL URL

Step 9


  • Click WSDL URL to see the contents of the published WSDL file in the next tab of browser

Step 10


Web Service Published and Available

  • That is all – your Web Service is fully deployed and available!
  • All but one step is remaining – that is to actually implement the business logic which computes sum and product.

Define Web Service Implementation using MOND ESB

Implementation of Web Service can be done without writing Java code. MOND Integration Development Console provides a Service development interface which can be used by Business Analysts to develop Service logic using a standard Web Browser.


  • Click here to login to MOND ESB
  • Click the Build tab. Based on your access rights you might see Build, Test, Deploy and Manage tabs.

Step 11


Define business logic of the Web Service Operation

  • Choose MathProjects in Project drop down and the list of MOND Services under MathProjects Project will be shown
  • The MOND Map which you created as part of the Web Service Implementation, that is, AddAndMultiplyMap is listed
  • Click MOND Service AddAndMultiply to start defining the business logic

Step 12


Define business logic of the Web Service Operation

  • You will see the MOND Service development interface using which you can define the business logic to be applied when Web Service operation addAndMultiply is invoked
  • On the first row, Click Add at Same Level

Step 13


Define business logic of the Web Service Operation

  • For computing sum of the two numbers, choose the operator Math->Add
  • Choose $firstNumber as Operand1 and $secondNumber as Operand2
  • You will notice that the Operation input variables defined in the Web Service Wizard, that is, firstNumber and secondNumber are automatically populated in the Operand drop downs.
  • Choose $sumOutput as Set Field
  • You will notice that the Operation output variables defined in Web Service Wizard, that is sumOutput and productOutput are automatically populated in the Set Field drop down.
  • Click Save

Step 14


Define business logic of the Web Service Operation

  • Click Add at Same Level
  • For computing product of the two numbers, choose the operator Math->Multiply
  • Choose $firstNumber as Operand1 and $secondNumber as Operand2
  • You will notice that the Operation input variables defined in the Web Service Wizard, that is, firstNumber and secondNumber are automatically populated in the Operand drop downs.
  • Choose $productOutput as Set Field
  • You will notice that the Operation output variables defined in Web Service Wizard, that is sumOutput and productOutput are automatically populated in the Set Field drop down.
  • Click Save

Step 15


Define business logic of the Web Service Operation

  • Now your MOND Service should look similar to below screenshot.
  • That is all! The web service implementation is complete.
  • Now, all that is remaining is to actually test the web service.
  • To see the input and output for this service, click Input Output button.

Step 16


Test Web Service Operation

You can quickly test the Web Service from within MOND without needing SOAP UI or any other Web Service Client


Test Web Service Operation

  • On the Left Hand Side Navigation menu choose Web Service/Rest->Web Service
  • You will notice that the Web Service which you created, that is, MathService is listed
  • Click MathService to view details

Step 17


Test Web Service Operation

  • Click Service Operation tab to view details of the Operation addAndMultiply
  • Click Simulate icon that is next to operation name and SOAP version

Step 18


Test Web Service Operation

  • In the Simulate screen you will see the WSDL URL, Port and Operation details
  • Click Generate Sample Request and MOND will generate a sample SOAP request for the addAndMultiply operation

Step 19


Test Web Service Operation

  • Edit the generated sample request to set firstNumber as 10 and secondNumber as 5
  • Click Simulate

Step 20


Test Web Service Operation

  • You will see the Web Service SOAP response where in and sumOutput and productOutput have been computed by MOND Web Service Operation and returned as a SOAP response
  • That is it! You have defined, deployed and tested a fully operational Web Service that returns multiple values in just a few clicks.

Step 21



Conclusion

In this section, you defined a Web Service that takes two input numbers and returns the sum and product of the two numbers. You deployed and tested the Web Service without leaving the browser window and all this took not more than 20 minutes!


Continue to tutorials