Wednesday Jul 30, 2008

Calling Sub Collaborations

With the release of Update 2 a while ago for Java CAPS 5.1.3, there has been the ability to call a JCD from within a JCD. I've done this tutorial in 5.1.3, but I don't see why it could not be implemented in Java CAPS 6 Repository based projects.

The following is a quick tutorial on how to implement this functionality.



  1. Create a project called SubCollabs

  2. Right Click the project and select "New" then "XML Schema Definition"



  3. Rename the schema definition from XSDDefinition1 to something more meaningful. In our case, xsdSubCollab. Then create a new element. Right click xsdSubCollab in the workspace and select "add" then "element". Rename the element to "Inbound".


  4. Repeat the above and create another element called "Outbound".


  5. Right Click Inbound, Add a Complex Type, then Right Click the Complex Type and Add a Sequence, then finally right click the sequence and add another element. Call this element "count". In the properties, change the type to "xsd:int".


  6. Create another element under Sequence and call this one "data" of type "xsd:string".


  7. Repeat the above steps and add the same elements to Outbound.


  8. Right Click on "Inbound" element and select 'Export XSD Node". This will create an entry in the project called xsdSubCollab_Inbound. Repeat this process for outbound.
    We now have our OTDs for the inner JCD.

  9. Create a new Java Collaboration, Give it the name jcdInner and make sure that the web service type is set to "New: Create a new Web Service operation".

    Make sure that you do NOT check "Callable as an external SOAP Web Service".
    Click "Next".

  10. Give the operation a name. For example "opInner".

  11. For the Input message, select our xsd OTD we created earlier. "xsdSubCollab_Inbound". Then click "Next"



  12. For the Output message, select out xsd OTD we created earlier, xsdSubCollab_Outbound. Then click "Next".

    Finally click "Finish" as we are not going to use any more additional OTDs.

  13. For the inner java collaboration, create a simple mapping. For example, map input count to output count and input data to output data.

  14. Now its time to create the outer collaboration that will call the sub collaboration.
    Create a new java collaboration called "jcdOuter".

    Leave the "Web Service Type" set at "Existing: Implement an existing Web Service operation".
    Click Next.

  15. Now, since this is the outer java collaboration, it needs to be kicked off by an incoming event. This can be done through an eWay or JMS message etc. Jut like a normal java collaboration. You do not specify the input details for the inner jcd here. For our example, this jcd is going to be kicked off by a file eWay.

    Click "Next"

  16. Now we select multiple OTDs for the outbound. This is where we specify the inner jcd. Navigate to jcdinner and select "Add".

    Select "OK" to the dialogue box that comes up.



  17. We should now have the inner jcd added to the outer java collaboration.

    Add a “FileClient” from the file eWay so we have an output from the outer JCD.
    Finally Click "Finish".

  18. Add the following code to the jcd to invoke the inner jcd.

    This code segment will populate the inner jcd's input OTD with data, invoke the inner jcd then map the output of the inner jcd to the FileClient otd so it can be sent to the output.

  19. Now lets build it.
    Create a connectivity map. In the connectivity map, you need to map the outer JCD to the Inner JCD as shown.


  20. Create a deployment profile and deploy.
    Run your project and you should see an output XML message containing the fields <count> and <data>.


Comments:

Post a Comment:
  • HTML Syntax: NOT allowed