Invoking a SCA composite synchronously from an OSB service

In this recipe, we will create a SOA Suite composite application, which has a BPEL service component with a synchronous Direct Binding service interface. The direct binding interface will be invoked from an OSB business service through the SOA-DIRECT transport:

Invoking a SCA composite synchronously from an OSB service

The SOA-DIRECT transport supports transactions and identity propagation across JVMs and uses the T3 RMI protocol to communicate with the SOA Suite server. It's important that the SOA Suite and the OSB server are on the same patch set level, otherwise we can get java class version errors.

Getting ready

Copy the soa-suite-invoking-soa-composite-sync holding the JDeveloper project from chapter-8getting-readyinvoking-soa-composite-sync 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-sync.

How to do it...

First we need a SOA Suite composite which exposes a synchronous Direct Binding interface. In JDeveloper perform the following steps to create it:

  1. Open the SOA workspace in JDeveloper by selecting File | Open and navigating to the invoking-soa-composite-sync.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:
    How to do it...
  4. In the Create BPEL Process window, enter CustomerManagentSync into the Name field.
  5. Choose Synchronous 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:
    How to do it...
  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 on OK:
    How to do it...
  12. Click on OK.

    This will create a BPEL component with an exposed SOAP binding as shown in the following screenshot:

    How to do it...

    Now let's add a Direct Binding to the SCA composite. In JDeveloper perform the following steps:

  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 CustomerManagementSyncDirect into the Name field.
  15. Make sure that Service is pre-selected for Type drop-down listbox, if you have not 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 created earlier. Select the CustomerManagementSync.wsdl file and lick on OK.
  17. Click on OK to finish the Create Direct Binding dialog:
    How to do it...
  18. Drag a wire from the CustomerManagementSyncDirect exposed service to the CustomerManagement BEL component:
    How to do it...

    Next, we will change the BPEL component so that it will return the customer test data:

  19. Double-click on the BPEL component symbol on the SCA composite.
  20. Drag an Assign activity from the Component Palette and drop it inbetween the receiveInput and replyOuput activity.
    How to do it...
  21. Double-click on the Assign activity.
  22. Navigate to the General tab and overwrite the name field wih AssignOutput.
  23. Navigate to the Copy Rules tab.
  24. In the tree on the right (the target section) right-click on outputVariable and select Expand All Child Nodes.
  25. Drag XML fragment to the Customer : CustomerTyp element:
    How to do it...
  26. 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>
  27. Click on OK to close the pop-up window.
  28. Click on OK to close the detail window of the Assign activity.
  29. 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 he following steps:

  30. Right-click on the CustomerManagement project and select Deploy | CustomerManagement.
  31. Select Deploy to Application Server from the list of deployment actions and click on Next.
  32. Enable the Overwrite any existing composites with the same revision ID check box and click on Next.
  33. Select the ApplicationServerConnection from the list of application servers and click on Finish.
  34. Check the SOA-Log and Deployment status window for errors. The deployment is successful, if a deployment finished message is shown.

    Next let's test CustomerManagement composite. In Enterprise Manager, perform the following steps:

  35. Expand the SOA folder in the tree on the left.
  36. Expand soa-infra folder and click on the default node.
  37. Click on CustomerManagement [1.0] in the list of composites and the details of the composite are displayed:
    How to do it...
  38. Click on the Test tab.
  39. The Test Web Service screen is shown, which allows us to test the SOAP Binding of the composite.
  40. On the Request tab, in the Input Arguments section enter 100 into the ID field and click on Test Web Service in the top-right corner.
  41. The result of the test is shown in the Response tab:
    How to do it...

    So far we have successfully created and tested the service provider side in SOA Suite. Now, let's 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:

  42. Navigate to the Resource Palette tab on the right side of JDeveloper and expand the Application Server node.
  43. Expand the ApplicationServerConnection | SOA | [SOAManagedServerName] | default | CustomerManagement [Default 1.0], right-click on CustomerManagementSyncDirect (direc) and select Copy Path:
    How to do it...

    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:

  44. In the business folder, create a new business service and name it CustomerManagement.
  45. On the General tab select WSDL Web Service.
  46. Click on Browse to define the WSDL.
  47. We want to consume the WSDL through the URL in the clipboard, so click on Consume.
  48. Select URI for the Service Resource, paste the URL into the URI field and click on OK.
  49. Select CustomerManagementSyncDirectDirectBindingPort2 (port) and click on OK.
  50. Confirm the Transport Configuration Change dialog with Yes.
  51. The WSDL 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.
  52. 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.
  53. Double-click on the CustomerMangementSyncDirect.wsdl and replace the value of schemaLocation for the import by ../xsd/CustomerMessages.xsd:
    How to do it...
  54. Save and close the wsdl file.
  55. Now delete the three generated XML schema files.
  56. Back on the CustomerMangagement.biz business service, naigate to the Transport tab.
  57. Check the Endpoint URI.
  58. Navigate to the SOA-DIRECT Transport tab.
  59. Synchronous client should be selected for the Role radio-button.
  60. Save the project and deploy it to the OSB server.

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

  61. In the Project Explorer expand the invoking-soa-composite-sync node and click on the business node.
  62. Click on the Launch Test Console icon (icon with the bug) for the CustomerManagement business service.
  63. Change the ID to 100 and click on Execute.
  64. The response message from the BPEL component is shown inthe Response Document section:
    How to do it...

How it works...

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

In this recipe, we have used a BPEL component, but it could have been any other SCA component, such as a Mediator or Rule component. OSB will use the T3 RMI protocol to communicate to the SOA Suite server but IIOP could be used as well. Because the WSDL of the SOA Direct Binding interface defines a synchronous request/response message exchange pattern, the business service will wait for the response.

There's more...

If the OSB and the SOA Suite are not in the same WebLogic domain, a service account needs to be created. The business service will use the service account to authenticate against the SOA Suite server.

  1. Right-click on the security folder and select New | Service Account.
  2. Enter ServiceAccountSOA into the File name.
  3. Click on Finish.
  4. Select Static at the Resource Type radio button.
  5. Enter weblogic into the User Name field.
  6. Enter the password of the SOA Server into the Password and Confirm Password field.
  7. Save and close the service account.
  8. Go back to the CustomerManagement.biz business service and open the SOA-DIRECT Transport tab.
  9. Expand Advanced Settings.
  10. Click on Browse on the Invocation Service Account field.
  11. In the pop-up window navigate to the security folder in the invoking-soa-composite-synchronously project and select ServiceAccountSOA.sa.
  12. Click on OK.
    There's more...

See also

For an asynchronous message exchange pattern, check the other recipe Invoking, a, SCA, composite, asynchronously.

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

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