Creating private proxy service

In this recipe, we will create a proxy service which can be reused and which is only available for other proxy services within the same OSB configuration, therefore we call it private proxy service in this recipe. The setup of the recipe is shown in the following screenshot:

Creating private proxy service

Getting ready

Make sure to have the latest state of the basic-osb-service project from the first chapter available in Eclipse OEPE. We will use it for this recipe. If necessary, it can be imported from here: chapter-1solutionwith-transformation-proxy-service-created.

How to do it...

First, we will create a new proxy service which will provide the internal functionality that can be reused by other proxy services. In Eclipse OEPE, perform the following steps:

  1. Create a new proxy service in the proxy folder and name it Tracing.
  2. On the General tab choose Any XML Service for the Service Type option.
  3. On the Transport tab choose local from the protocol drop-down listbox.
  4. Navigate to the Message Flow tab and add a Pipeline Pair node and name it TracingPipeline.
  5. Insert a Stage into the Request Pipeline and name it TracingStage.
  6. Insert a Log action into the Stage.
  7. On the Properties tab of the Log action, click on <Expression>.
  8. Enter $body/custom/correlationID/text() into the Expression field.
  9. Enter Message received with ID into the Annotation field.
  10. Select Warning from the Severity drop-down listbox.
  11. Insert a Report action after the Log action just created previously.
  12. On the Properties tab of the Report action, click <Expression>.
  13. Enter $body into the Expression field and click OK.
  14. Click Add a Key.
  15. Enter CorrelationId into the Name field.
  16. Click on <XPath> and enter./custom/correlationID into the Expression field and click OK.
  17. Enter body into the In Variable field.
    How to do it...

    Our reusable tracing functionality is now available. Let's use it from the CustomerManagement proxy service.

  18. Open CustomerManagement proxy service and navigate to Message Flow tab.
  19. Navigate to the Design Palette and drag a Publish Action from the Stage Actions into the Request Action of the Routing action in the StoreCustomerRoute node.
  20. On the Properties tab of the Publish action click Browse.
  21. Select the Tracing proxy service and click OK.
  22. Add a Replace action into the Request Action flow of the Publish action.
  23. On the Properties tab of the Replace action, enter body into the In Variable field
  24. Click <Expression>, enter $header/custom into the Expression field and click OK.
  25. Select the Replace node contents option.
  26. Copy the created Publish action into the Request Action of the Routing action of the FindCustomerRoute node.
    How to do it...
  27. Deploy the project to the OSB server.

    Now, let's test the added functionality through the Test console. In the Service Bus console, perform the following steps:

  28. In the Project Explorer, navigate to the CustomerManagement proxy service and click on Launch Test Console icon.
  29. In the SOAP Header field insert <custom><correlationID>abcd1234</correlationID></custom> in between the soap:Header element and click Execute.
    How to do it...

How it works...

The CustomerManagement proxy service calls the Tracing proxy for all incoming messages. Because we have used a Publish action instead of a Service Callout action, the Tracing proxy gets invoked by the CustomerManagement proxy service without waiting for any response. The information written by the Reporting action can be viewed through the Oracle Service Bus console by clicking on Message Reports in the Reporting section.

When using the Local transport for a proxy service, as shown in this recipe for the Tracing proxy service, no Endpoint URI has to be configured. The reason for that is that a local proxy service can never be called from outside the OSB; it's only available for other proxy services within the same OSB.

We used a simple example to centrally use the Log and Report action of the OSB. However, private proxy services can be used for multiple tasks which have a high repetitive nature. Think of error handling or similar transformation of XML messages in multiple operations.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset