Showing posts with label OEPE. Show all posts

Using the Publish action to asynchronously invoke a service



We will use the Publish action to asynchronously invoke a service from the proxy service message flow, without having to wait for the calling service to finish its processing.

For this recipe, we have an external Processing Service, available as a soapUI mock service which takes quite some time to do its processing. The interface in the Processing Service WSDL is defined synchronous. We have a business service Processing which allows us to invoke the external service from a proxy service.

Instead of directly invoking the business service from the Publish proxy service, an additional proxy service Processing is added, which only exposes a one-way interface. By doing that, the Publish proxy service can use a Publish action to invoke the Processing proxy service without having to wait for external service to complete.

Let's implement the Publish proxy service, which will use the Publish action to invoke the Processing proxy service. In Eclipse OEPE, perform the following steps:

1. Create a new proxy service in the proxy folder and name it Publish.

2. On the General tab select Any XML Service for the Service Type option.

3. Navigate to the Message Flow tab.

4. Insert a Pipeline Pair node and name it PublishPipelinePair.

 5. Insert a Stage node into the Request Pipeline and name it PublishStage.

6. Insert a Publish action into the Stage.

7. On the Properties tab of the Publish action, click Browse.

 8. Select the Processing proxy service inside the proxy folder and click OK.

9. Insert a Log action after the Publish action.

10. On the Properties tab of the Log action, click <Expression> and enter 'Publish completed, continue with processing in Publish proxy service' into the Expression field.

11. Click OK.

12. Select Warning from the Severity drop-down listbox.

13. Deploy the project to the OSB server.

Now, let's test OSB project by performing the following steps in the Service Bus console:

14. In the Project Explorer navigate to proxy folder inside the using-publish-to-asyncinvoke- service project.

15. Click on the Launch Test Console icon of the Publish proxy service.

16. Leave the Payload field empty and directly click Execute.

17. The output of the Log action from the Publish proxy service should be shown first in the Service Bus console window, followed a few seconds later by the output of the Log action from the Processing proxy service, which is shown after the external service has completed its work.

Using Service Callout action to invoke a service



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.



Deploying the OSB configuration from Eclipse OEPE - OSB Recipe 5



Eclipse OEPE is creating a JAR file (a Java Archive) with all the artifacts which belong to the OSB configuration and deploys that archive to the OSB server.

The mechanism to deploy directly from Eclipse should only be used during development. Later when deploying to integration, quality assurance, or a production system, of course, a more automatic and reproducible way is necessary. This can be achieved through Apache Ant and WLST.


First we need to create the server reference inside Eclipse OEPE and after that we can deploy the OSB configuration with its projects to the server.

In Eclipse OEPE, perform the following steps to create a server:

1. Switch to the Servers tab and right-click in the empty window
.
2. Select New | Server.

3. In the Define a New Server window, select the right WebLogic Server version (Oracle WebLogic Server 11gR1 PatchSet 3).

4. Click on the Next button twice.

5. Select the Local option and select the Domain Directory of the local OSB server installation. If the Domain Directory drop-down list is empty, then click on Browse button to navigate to the domain directory on your machine:


6. Click on the Finish button.

Now the local OSB server is configured in Eclipse OEPE. The next step is to deploy the OSB configuration to this sever. Still in Eclipse OEPE, perform the following steps:

7. On the Servers tab, right-click on the server item that you just created and select Add and Remove.

8. In the Available list on the left, click on the osb-learnorasoa-configuration OSB configuration.

9. Click on Add to move it to the Configured list on the right and click on the Finish button.

10. The OSB configuration is deployed to the running OSB server and after a while the status will change from [Started] to [Started, Republish].

11. Right-click on the OSB server and select Publish.

12. After a while the status will change to [Started, Synchronized], indicating that Eclipse OEPE and the OSB server are synchronized.

13. Expand the tree and the status of each single OSB project within the OSB configuration is shown:




The OSB configuration is now successfully deployed and ready to be used.

Deploying to a remote server from Eclipse OEPE


Eclipse OEPE can also be used to deploy to a remote server. Just click on the Remote option when defining the WebLogic Server in the New Server wizard:



Creating an OSB Configuration Jar and use the OSB console to deploy it


An OSB configuration can also be deployed by using the OSB console. In Eclipse OEPE, perform the following steps:

1. In the Project Explorer, right-click on the OSB Configuration that you want to deploy to and select Export | Oracle Service Bus – Configuration Jar.

2. In the pop-up window, select the resources to export, enter the location of the configuration jar into the Jar File field and click on the Finish button.


In the OSB console, perform the following steps to import the Configuration Jar that we just created:

3. Select the menu System Administration on the left-hand side. You might have to use the scroll bar in order to see all the menu items.

4. Click on Create in the Change Center to start a new change session.

5. Click on the Import Resources button and use Browse to select the file created in the export (c:\temp\sbconfig.jar).

6. Click on the Next button.

7. Check that the right sources will be imported:



8. Click on the Import button to start the import.

9. The successful import is confirmed by the message the import was completed successfully.

10. Click on the Activate button in the Change Center.

11. Enter a text describing the changes into the Description field and click on the Submit button to activate
the changes.

If we need to adapt some properties like endpoint URI to match the target environment, we can use a customization file and apply that when doing the deployment.

Generating a simple pass-through proxy service - OSB Recipe 4



The proxy service offers the same SOAP-based web service interface as the business service/external service, so it's basically just doing a pass-through of the request and response message.

This can be handy if we want to use the OSB for adding an additional abstraction layer to apply service virtualization. If all the service consumers no longer access the external services directly, but only through the OSB proxy-service, a lot of the features of OSB can be used transparently by a service consumer, such as SLA monitoring and alerting, service pooling and throttling, or message validation. This directly supports the main goal of service virtualization—adding operational agility.

By setting the Invoking property to Use inbound operation for outbound, we make sure that the whole WSDL with all its operations is handled by one single Routing action. The inbound operation name on the proxy service is used as the outbound operation name invoked on the business service. Apart from the Routing action there are no other actions in this proxy service. By that, both the request and the response messages in the $body variable are not touched by the OSB. This guarantees that the overhead of adding OSB as a service virtualization layer has minimal impact on the performance.


The proxy service will allow a consumer to call our service on the OSB. If the OSB needs to support the same web service interface as the backend service does, then the quickest and easiest way is to create a pass-through service:


In Eclipse OEPE, perform the following steps:

1. In the project tree, right-click on the CustomerService.biz artifact and select Oracle Service Bus | Generate Proxy Service.

2. Enter CustomerService in the File name field and select the proxy folder for the location of the new proxy service.

3. Click on the Finish button.

4. Click on the Transport tab and check the value of the Endpoint URI field. It should be /basic-osb-service/proxy/CustomerService.

5. Navigate to the Message Flow tab and have a look at the message flow, which has been generated by Eclipse OEPE. A Route node with a nested Routing action has been created with its Invoking properties set to Use inbound operation for outbound:




Creating a business service to call an external SOAP-based web service - OSB recipe 3



The business service acts as a wrapper of our external service. Once created, we will no longer have to use the WSDL to refer to the external service, but can use the business service.

This forms an additional abstraction layer, which is applied before the real endpoint is invoked, such as SLA monitoring, service throttling, service pooling, and others. Sentence is too long, runs on too long. Would be better split into two sentences.



Verify that the service is running and available by asking it for its WSDL definition.

In Eclipse OEPE, perform the following steps:

1. In the project tree, right-click on the business folder and select New | Business Service.

2. Enter CustomerService into the File name field, check a second time that the business folder is selected, and click on the Finish button:


3. A new business service artifact is created in the business folder and the editor for the business service opens automatically.

4. Navigate to the General tab, if it does not already have the focus, and select the WSDL Web Service radio button.

5. Click on the Browse button and a pop up window will show up, where the WSDL resource of the external service to be wrapped, can be selected.

6. Click on the Consume button.

7. A second pop-up window will show up where the WSDL resource can be specified:



8. Select URI in the Service Resource drop-down listbox.

9. In the URI field, enter the URL of the WSDL resource to consume. The external service provides its WSDL through the following URL: http://localhost:8088/mockCustomerServiceSOAP?WSDL.

10. Click on the OK button and Eclipse will consume the WSDL from this URL.

11. Select the CustomerServiceSOAP port on the next window.

12. Click on the OK button.

13. Select Yes on the pop-up message window to confirm that the transport configuration settings will be overwritten by the information from the selected WSDL.

14. Save the OSB project by selecting File | Save.

15. In the Project Explorer, right-click on the imported WSDL file mockCustomerServiceSOAP.wsdl and select Rename. Enter CustomerService.wsdl into the New name field of the pop-up window and confirm.

16. In the Project Explorer, drag the CustomerService.wsdl file into the wsdl folder and drop it there. All the references to the WSDL file are automatically adapted by Eclipse OEPE.

17. Navigate to the Transport tab and check that the Endpoint URI has been replaced with the service endpoint setting from the WSDL that we consumed:



18. Save the artifact by selecting File | Save or by clicking on the Save toolbar button.






Defining a folder structure for the OSB project - OSB recipe 2



In Eclipse OEPE, perform the following steps:

1. Right click on the basic-osb-service project and select New | Folder.

2. Enter proxy in the Folder name field:

3. Repeat these two steps for the folders business, wsdl, xsd, and transformation. These are the most common folders and they altogether form the basic OSB project .

Folders help to structure the projects and by that organize the different artifacts that we will create later. The folder structure will also be visible after the deployment of a project in the OSB console. So at runtime, if someone (that is, the administrator) needs to navigate to a certain artifact through the console, a clever folder structure can make life much easier.


Folder name
Used for organizing
business
business services artifacts
proxy
proxy services artifacts
wsdl
SOAP-based web service interfaces
xsd
the XML schema files
transformation
Artifacts for doing data model transformations, such as XQuery and XSLT scripts

Creating a new OSB project




Eclipse OEPE is an Eclipse IDE with Oracle Enterprise Plugin for Eclipse (OEPE) and the OSB plugin installed.


1. In Eclipse OEPE, perform the following steps

2. From the File menu, pick New | Other

Type Oracle Service Bus in the Wizards tree list:




4. Choose Oracle Service Bus Project from the list and click on the Next button.

5. Enter basic-osb-service into the Project name field:




6. Click on the New button to create an OSB Configuration (if there is not yet one).
Enter osb-cookbook-configuration into the Configuration name field.

7. Click on the Finish button to create the empty OSB project.

8. Click on Yes to confirm that Eclipse OEPE will switch to the Oracle Service Bus perspective.


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 -