Overview :
Simple Object Access Protocol (SOAP) is a protocol that facilitates the exchange of structured information between applications over a network. It establishes a standardized method for applications to communicate with each other, and it finds frequent use in web service architectures. In a real-life project, we may need to expose our webMethods flow services as a web service for others to retrieve data. We can utilize the webMethods web service descriptor to construct this architecture.
Prerequisites :
- Basics of webMethods flow service.
- Knowledge of how to use SOAP client tools.
Code Area :
In this project, we will create a flow service that takes two parameters, num1
and num2
. As a response, it will provide the output by adding both num1
and num2
.
Create Package :
- Create a package named `HG_WebService_Demo` and follow the package structure below.
- HG_WebService_Demo
- v1
- protocol
- soap
- provider
- soap
- services
- protocol
- v1
- HG_WebService_Demo
Create Flow service :
- Create a flow service with the name `additionOfTwoNum` in the
services
folder. - In the input section of the service, create two variables named
num1
andnum2
. In the output section, create a variable namedsum
, and ensure that all variables are of string type. - Invoke ‘pub.math:addInts‘ flow service and follow the below mapping.
- num1->num1
- num2->num2
- value->sum
- drop num1, num2 and value
- Note: Here we have not implemented Try-Catch, you can implement it in your project and write your own error-handling framework.
Expose flow service as web service :
- Right-click on the provider -> New -> Web Service Descripter.
- Now one popup will be opened to configure the Web Service, follow the below instructions to expose our flow service as a web service.
- It will ask you to provide the element name(Web Service descriptor) name, name it as ‘additionOfTwoNum‘ and click next.
- Now select as shown below and click next.
- Select the flow service that you want to expose as a web service and click next.
- Configure the binding details like below and click finish.
- Now we have created a web service descriptor, open it and copy the WSDL URL.
Impose Authentication :
As we are exposing our web service to an external client, we cannot provide them with our admin credentials. Instead, we need to create an Access Control List (ACL) and generate credentials. These credentials will be used by end-users or external clients to access this specific web service.
- Open the Integration server administrator page.
- Click on the ‘ACLs‘ under the ‘Security‘ tab and click on ‘Add and Remove ACLs‘ link at the top of the page.
- Name the AC as ‘Addition‘.
- Navigate to the ‘User Management‘ page under the ‘Security‘ tab.
- Click on ‘Add and Remove Groups‘ and create a group with the name ‘Addition‘.
- Once the group is created click on the ‘Add and Remove Users‘ to create a user with a user ID and password.
- Now, we need to add the user to the group, include the group in the ACL, and finally, configure the ACL in the webservice descriptor. This enables external clients to access the web service using the configured userID and password.
- Select the ‘Addition‘ group in the group panel and add the user created into the group like below.
- Again navigate to ‘ACLs‘ under the ‘Security‘ tab.
- Now add the ‘Addition‘ group to the ‘ACL‘ by following the below procedure.
- Now go back to the designer and open the Web Service descriptor that we created earlier.
- In the Properties panel, click on ‘Permissions,’ set the ‘Execute ACL‘ to ‘Addition‘ ACL, and then click Apply and Close.
- After doing this the end user will be able to access the web service using only the custom credential created.
Consume Web Service using SoapUI :
- Open Soap UI
- Click on “File -> New Soap Project” and name the project ‘AdditionOfTwoNum‘ In the Initial WSDL field, paste the URL copied from the designer, and then click ‘OK‘.
- Once WSDL is imported you will see the operation and parameters available in the service.
- Click on Auth->Auth Type->Basic.
- Provide the User ID and Password that we created earlier.
- Insert value for both
num1
andnum2
variables and run the soap project.
- Congratulations we are able to consume the Web service that we have created.
Please click on the download link below to access the source code.