We have used the Service Callout action in this recipe to invoke an additional service besides the one already called through the Routing action. By doing that, we are able to, for example, enrich a message, either before or after doing the routing. In our case, we have added the credit card information to the canonical response message returned to the consumer. By adding the Service Callout action into the Response Action of the Routing action, we decided that the callout is done after the Routing has been successfully executed.

A Service Callout only works with WSDL operation which implements the request/response message exchange pattern. One-way operations cannot be invoked by the Service Callout action, use the Publish action instead.

We will use a Service Callout action to call another service from a proxy service message flow.

Aadd an additional service call to another service Credit Card Info Service, which returns the credit card information. The service call will be done using the Service Callout action. Both the information from the Credit Card Info Service and from the Customer Service will then be merged by the XQuery transformation into one single response returned by the proxy service.


First, we will create a new business service which will wrap the additional Credit Card Info Service interface on the CRM system. In Eclipse OEPE, perform the following steps:

1. Create a new business service in the business folder and name it CreditCardInfoService.

2. On the General tab choose WSDL Web Service for the Service Type option and click Browse.

3. Click Consume and select URI from the Service Resource drop-down listbox.

4. Enter the endpoint URI of the soapUI mock service http://localhost:8090/mockCreditCardInfoServiceSOAP?WSDL into the URI field and click OK.

5. Select the CreditCardInfoServiceSOAP (port) node and click OK.

6. Confirm the pop-up window by clicking OK.

7. Rename the imported WSDL from mockCreditCardInfoServiceSOAP.wsdl to CreditCardInfoService.wsdl and move it into the wsdl folder.

By doing that, we have created the new business service. Now, let's add the Service Callout action to the proxy service calling the new business service. In Eclipse OEPE, perform the following steps:

8. Open the Message Flow tab of the CustomerManagement proxy service.

9. In the FindCustomer branch, right-click on the Response Action flow of the Routing action and select Insert Into | Communication | Service Callout to add a Service Callout action just before the Replace action. We want to enrich the message, before the transformation to the canonical format is made.

10. On the Properties tab of the Service Callout action, click Browse and select the CreditCardInfoService business service.

11. Select RetrieveCreditCardById from the Invoking drop-down listbox.

12. Select the Configure Soap Body option.

13. Enter creditCardInfoRequest into the Request Body field and creditCardInfoResponse into the Response Body field.


14. Insert an Assign action into the Request Action flow of the Service Callout action.

15. On the Properties tab of the Assign action, click on <Expression> and enter the following XML fragment into the Expression field:

<soap-env:Body>
<cred:RetrieveCreditCardById>
<id>{$body/cus:FindCustomer/ID/text()}</id>
</cred:RetrieveCreditCardById>
</soap-env:Body>

16. Navigate to the Namespace Definition tab, add a namespace with cred for the Prefix and http://www.crm.org/CreditCardInfoService/ for the URI field and click OK.

17. Enter creditCardInfoRequest into the Variable field.

We have added the Service Callout  action to the proxy service. The message flow should look as shown in the following screenshot:


The result of the Service Callout action is available in the creditCardInfoResponse variable. We now have to adapt the XQuery transformation to merge the message from the Service Callout and the Routing into one single response message. In Eclipse OEPE, perform the following steps:

18. Open the TransformFindCustomerResponse.xq XQuery transformation and navigate to the Source tab.

19. Add an additional parameter to the XQuery transformation by adding the following line to the top:

(:: pragma bea:global-element-parameter parameter="$retrieveCreditCardInfoByIdResponse1" element="ns4:RetrieveCreditCardByIdResponse" location="../wsdl/CreditCardInfoService.wsdl" ::)

20. Declare an additional namespace:

declare namespace ns4 = "http://www.crm.org/CreditCardInfoService/"; 

21. Add the parameter to the declaration of the TransformFindCustomerResponse function:

declare function xf:TransformFindCustomerResponse ($retrieveCustomerByCriteriaResponse1 as element(ns0:RetrieveCustomerByCriteriaResponse), $retrieveCreditCardInfoByIdResponse1 as element(ns4:RetrieveCreditCardByIdResponse)) as element(ns3:FindCustomerResponse) { <ns3:FindCustomerResponse>

22. Declare an additional variable and add the variable to the invocation call:

declare variable $retrieveCreditCardInfoByIdResponse1 as element(ns4:RetrieveCreditCardByIdResponse) external; 

xf:TransformFindCustomerResponse( $retrieveCustomerByCriteriaResponse1, $retrieveCreditCardInfoByIdResponse1) 
23. Navigate back to the Design tab and the new parameter with the Credit Card Info data will be shown. Map the credit card information to the FindCustomerResponse message. The mapping should look as shown in the following screenshot:



Last but not least we have to change the existing invoke of the XQuery in the Replace action so that the additional parameter is passed. In Eclipse OEPE, perform the following steps:

24. Select the Replace action following the Service Callout action and navigate to the Properties tab.

25. Click on the link to the right of Expression to reselect the XQuery transformation.

26. Click Browse, select the TransformFindCustomerResponse.xq XQuery resource and click OK.

27. Enter $body/ext:RetrieveCustomerByCriteriaResponse into the retrieveCustomerByCriteriaResponse1 field and $creditCardInfoResponse/ cred: RetrieveCreditCardByIdResponse into the retrieveCreditCardInfoByIdResponse1 field.

28. Click OK.

29. Deploy the project to the OSB server.

Now let's test the proxy service from soapUI:

30. Import the CustomerManagement-soapui-project.xml .

31. Double-click on Request 1 inside the FindCustomer operation.

32. Check that the endpoint of the proxy service is correctly set up in the drop-down listbox on the top.

33. Click on the green arrow to execute the test and make sure that the CreditCard information is returned in the response.



{ 2 comments... read them below or Comment }


  1. Nice post! Thank you admin for this wonderful post about cloud computing. As you said AWS is the best way to secure your data since the presence of end to end process in AWS.

    Regards:

    AWS Training in Adyar | AWS Training center in Chennai

    ReplyDelete

About This Site

Howdy! My name is Suersh Rohan and I am the developer and maintainer of this blog. It mainly consists of my thoughts and opinions on the technologies I learn,use and develop with.
Powered by Blogger.

- Copyright © My Code Snapshots -Metrominimalist- Powered by Blogger - Designed by Suresh Rohan -