Invoking a SCA composite asynchronously from an OSB service

In this recipe, we will create a SOA Suite composite application with a BPEL service component with an asynchronous direct binding service interface. The direct binding interface will be invoked from an OSB business service through the SOA-DIRECT transport. The callback message from the BPEL service will be handled by an OSB proxy service through the SB transport.

Invoking a SCA composite asynchronously from an OSB service

Getting ready

Copy the soa-suite-invoking-soa-composite-async holding the JDeveloper project from chapter-8getting-readyinvoking-soa-composite-async into a local workspace folder.

Import the base OSB project containing the necessary schemas and the right folder structure into Eclipse from chapter-8getting-readyinvoking-soa-composite-async.

How to do it...

First we need a SOA Suite composite which exposes an asynchronous direct binding interface. In JDeveloper, perform the following steps to create it:

  1. Open the workspace in JDeveloper by selecting File | Open and navigating to the invoking-soa-composite-async.jws file.
  2. Click on the composite.xml located in the CustomerManagement project to open up the SCA composite view.
  3. Drag a BPEL Process from the Service Components section of the Component Palette to the SCA composite and drop it on the Components area.
  4. In the Create BPEL Process window, enter CustomerManagentASync into the Name field.
  5. Choose Asynchronous BPEL Process for the Template drop-down listbox.
  6. Click on the magnifying glass button, right to the Input field.
  7. In the Type Chooser window expand the CustomerMessages.xsd inside the Project Schema Files folder.
  8. Select the FindCustomer element and click on OK.
  9. Click on the magnifying glass button right to the Output field.
  10. In the Type Chooser window expand the CustomerMessages.xsd inside the Project Schema Files folder.
  11. Select the FindCustomerResponse element and click onOK.
  12. Click OK to create the BPEL component:
    How to do it...

    We have created a BPEL component with an exposed SOAP binding, defining an asynchronous interface. Similar to the synchronous recipe we will now add the direct binding to the SCA composite:

  13. From the Component Palette drag the Direct Binding from the Service Adapter section and drop it on the Exposed Services section of the SCA composite.
  14. Enter CustomerManagementASyncDirect into the Name field.
  15. Make sure that Service is pre-selected for Type drop-down listbox. If not you have probably dropped the Direct Binding component on the wrong lane.
  16. Click on the icon with the green arrow next to the WSDL URL field to browse for the WSDL file that we just created. Select the CustomerManagementASync.wsdl file.
  17. Select CustomerManagementAsync or the value of Port Type drop-down listbox.
  18. Select CustomerManagementAsyncCallBack for the value of Callback Port Type drop-down listbox and click on OK:
    How to do it...
  19. Drag a wire from the CustomerManagementASyncDirect exposed service to the CustomerManagement BPEL component.

    The SCA composite should look simila to the one shown in the following screenshot:

    How to do it...

    Perform the following steps to change the BPEL component, so that it will return the customer test data:

  20. Double-click on the BPEL component icon in the SCA composite.
  21. Drag an Assign activity from the Component Palette and drop it in between the receiveInput and replyOuput activity.
  22. Double-click the Assign1 activity.
  23. Navigate to the General tab and overwrite the name field with AssignOutput.
  24. Navigate to the Copy Rules tab.
  25. In the tree on the right, (the target section) right-click on outputVariable and select Expand All Child Nodes.
  26. Drag the XM fragment to the Customer : CustomerTyp element:
    How to do it...
  27. Enter the following XML fragment into XML Fragment field of the pop-up window:
    <Customer xmlns="http://osb-cookbook/CustomerManagement" xmlns:cus1="http://osb-cookbook/customer" xmlns:cred="http://osb-cookbook/creditcard">
           <cus1:ID>100</cus1:ID>
           <cus1:FirstName>Larry</cus1:FirstName>
           <cus1:LastName>Ellison</cus1:LastName>
           <cus1:EmailAddress>[email protected]</cus1:EmailAddress>
           <cus1:Addresses/>
           <cus1:BirthDate>1967-08-13</cus1:BirthDate>
           <cus1:Rating>A</cus1:Rating>
       <cus1:Gender>Male</cus1:Gender>
           <cus1:CreditCard>
                   <cred:CardIssuer>visa</cred:CardIssuer>
                   <cred:CardNumber>123</cred:CardNumber>
                   <cred:CardholderName>Larry</cred:CardholderName>
                   <cred:ExpirationDate>2020-01-01</cred:ExpirationDate>
                  <cred:CardValidationCode>1233</cred:CardValidationCode>
           </cus1:CreditCard>
    </Customer>
  28. Click on OK to save the XML fragment.
  29. Click on OK to close the detail window of the Assign1 activity.
  30. Click on Save All and close the CustomerMangementSync.bpel and composite.xml.

    Now we can deploy the SCA composite to the SOA Suite server. In JDeveloper, perform the following steps:

  31. Right-click on the CustomerManagement project and select Deploy | CustomerManagement.
  32. Select Deploy to Application Server from the list of deployment actions and click on Next.
  33. Enable the Overwrite any existing composites with the same revision ID checkbox and click on Next.
  34. Select the ApplicationServerConnection from the list of application servers and click on Finish.
  35. Check the SOA-Log status window for errors. The deployment was successful, if a BUILD SUCCESSFUL message is shown.
  36. By that the service provider side in SOA Suite is ready. Testing doesn't make sense, because of the asynchronous nature of the interface; we would not see any response in the Enterprise Manager.
  37. The next step is to implement the service consumer side on the OSB. First, we need to get the WSDL of the SOA Direct Binding interface. We will retrieve the URL of the WSDL in JDeveloper and then use that URL to consume it in Eclipse OEPE.

    In JDeveloper, perform the following steps to retrieve the URL of the WSDL:

  38. Navigate to the Resource Palette tab on the right side of JDeveloper and expand the Application Server node.
  39. Expand the ApplicationServerConnection | SOA | [SOAManagedServerName] | default | CustomerManagement [Default 1.0], right-click on CustomerManagementASyncDirect (direct), and select Copy Path.

    With the URL of the WSDL in the clipboard, let's create the business service by consuming the WSDL from the URL. In Eclipse OEPE, perform the following steps:

  40. In the business folder, create a new business service and name it CustomerManagement.
  41. On the General tab, select WSDL Web Service.
  42. Click on Browse to define the WSDL.
  43. We want to consume the WSDL with the URL in the clipboard, so click on Consume.
  44. Select URI for the Service Resource, paste the URL into the URI field and click on OK.
  45. Select CustomerManagementASyncDirectDirectBindingPort12 (port) and click on OK:
    How to do it...
  46. Confirm the Transport Configuration Change dialog with Yes.

    The WSDL file is stored in the project folder itself. We can easily refactor by dragging it to the wsdl folder. The reference in the business service is automatically updated.

    The necessary XML schemas are also consumed and stored in the project. However, they have generated names, so let's replace them by the ones we have used in the SOA Suite project. They are already available in the xsd folder of the OSB project.

  47. Double-click on the CustomerMangementASyncDirect.wsdl and replace the value of schemaLocation for import by ../xsd/CustomerMessages.xsd.
  48. Save and close the WSDL file.
  49. Now delete the three generated XML schema files.
  50. Back on the CustomerMangagement.biz business service navigate to the Transport tab.
  51. Check the Endpoint URI.
  52. Navigate to the SOA-DIRECT Transport tab.
  53. Asynchronous client should be selected for the Role radio button.

    If the OSB and the SOA Suite are not in the same WebLogic domain, a service account needs to be created. Check the recipe, Invoking, a, SOA, composite, synchronously, from, an, OSB, service, for how to create a service account.

    Next, we create the proxy service which handles the callback from the SOA Suite.

  54. In the proxy folder, create a new proxy service and name it CustomerManagementCallback.
  55. On the General tab select WSDL Web Service.
  56. Click on Browse to define the WSDL.
  57. The Select a WSDL pop-up window appears.
  58. Expand invoking-soa-composite-async | wsdl | CustomerManagementAsyncDirect.wsdl and select CustomerManagementAsyncCallbackDirectBinding1.2 (binding) and click on OK:
    How to do it...
  59. Confirm the Transport Configuration Change dialog with Yes.
  60. Navigate to the Transport tab.
  61. Change the value of the Protocol drop-down listbox to sb.
  62. Navigate to the Message Flow tab.
  63. Drag a Pipeline Pair node from the Design Palette and drop it below the interface. Name it HandleCallbackPipelinePair.
  64. Right-click on the Request Pipeline and select Insert Into | Stage. Name it LoStage.
  65. Right-click on the LogStage and select Insert Into | Reporting | Log.
  66. On the Properties tab of the new Log action, click on the <Expression> link and enter $body into the Expression field.
  67. Click on OK.
  68. Enter Customer Response into the Annotation field.
  69. Select Warning for the Severity drop-down listbox:
    How to do it...

    Now with the proxy service handling the callback in place, we have to configure it in the business service:

  70. Open the CustomerManagement.biz business service.
  71. Navigate to the SOA-DIRECT Transport tab.
  72. On the Callback Proxy field, click on Browse.
  73. On the Select a Proxy Service Resource pop-up window, expand the tree and select the CustomerManagementCallback.proxy proxy service.
  74. Click on OK:
    How to do it...
  75. Deploy the project to the OSB server.

    Now let's test the service. In the Service Bus Console, perform the following steps:

  76. In the Project Explorer expand the invoking-soa-composite-async node and click on the business node.
  77. Click the Launch Test Console icon (icon with the bug) for the CustomerManagement business service.
  78. Change the ID to 100 and click on Execute.
  79. The Response Document section should contain the message There was no response. This is correct, because the business service does not get an answer.
  80. Check the Service Bus Console output window for the appearance of the log statement from the proxy service:
    How to do it...

The proxy service is invoked when the callback message arrives from the BPEL component and the log statement shows the callback message handled by the roxy service.

How it works...

A business service can call an asynchronous SOA Suite Direct Binding service, wired to a SCA component by using the SOA-DIRECT transport.

OSB will use the T3 RMI protocol to communicate with the SOA Suite server. Because the WSDL of the SOA Direct Binding interface defines an asynchronous request/response message exchange pattern, the SOA Suite will callback on proxy server configured on the business service when the response message is ready. The callback URL of proxy service is passed by the business service to the SOA Suite as SOAP header information using WS-Addressing.

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

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