Sei sulla pagina 1di 30

Cobol on the Bus - Cobol Copybooks & Oracle Service Bus 11g Part 1

This article is from the excellent Blog by Niall Commiskey. See complete article here - http://niallcblogs.blogspot.com/2010/06/cobol-on-buscobol-copybooks-oracle.html

I'm back doing some work on Oracle OSB11g - preparing a POC showing integration with Cobol Copybooks.I actually began my IT life programming Cobol on Honeywell DPS8 for the Irish Revenue Commissioners so it was a bit deja vu for me. For those post-Cobol baby boomers here's an example of such a cobol copybook 000100 01 PERSON. 000200 05 PERSON-FIRST-NAME PIC X(10). 000300 05 PERSON-LAST-NAME PIC X(10). 000400 05 PERSON-COUNTRY PIC X(02). 000500 05 REQUEST-TYPE PIC X(01). save the above to a file with the extension .cpy e.g. person.cpy This is a very simple person definition - X --> alpha. In this scenario we receive a message that adheres to the definition in the Cobol Copybook.If it is of request type "C" (Create) we will route to the create operation of the Person business service.If it is of request type "U" (Update) we will route to the update operation of the Person business service.If it is of request type "D" (Delete) we will route to the delete operation of the Person business service. We will now implement what will be our OSB Business Service. Create Person Web Service In JDev simply create a Java class that implements 3 methods createPerson(String name) updatePerson(String name) deletePerson(String name)

Create a new App server connection

Expose as a web service and deploy to the WLS instance running OSB.

Test the web service via the WLS console e.g. localhost:7021/console --> deployments --> test etc.

Create an OSB project with the following folder structure -

Create a new MFL in the MFL folder -

Double click on the newly created file to start Format Builder. Import Cobol Copybook...

Specify your person.cpy file

Specify delimiter we will use carraige return \n

Test the MFL

Note the HEX 0a has been added for carriage return

Save this input file for use in later testing.

Now we will create the business service based on the Person web service we deployed earlier. Create the Business Service All we need is the wsdl from the service we created earlier -

e.g. http://localhost:7021/PersonProcessorWS-PersonProcessorWS-contextroot/PersonProcessorImplPort?WSDL

Consume the existing web service

Click "OK"

Set Load Balancing Algorithm to none

We now have the following artifacts in our OSB project

Create the Proxy Service In this scenario, our proxy service will read in the Cobol data from a directory e.g. D:\WorkshopEnvs\OSB11g\demos\Cobol-In-Dir create this input directory along with ones for stage, error, archive. So now you should have 4 directories D:\WorkshopEnvs\OSB11g\demos\Cobol-In-Dir D:\WorkshopEnvs\OSB11g\demos\Cobol-Error-Dir D:\WorkshopEnvs\OSB11g\demos\Cobol-Stage-Dir D:\WorkshopEnvs\OSB11g\demos\Cobol-Archive-Dir

On the General Tab --> Messaging Service On the Messaging Tab -->

Transport Config --> File, specify input directory

File Transport -->

Implementing the Message processing logic Essentially our business processing will involve checkimg what action is specified in the data coming from the Cobol based system. Remember - PERSON-REQUEST-TYPE = "C" - Create etc. If create then we call the "createPerson" operation of the Person Business Service.

But we need to amend the payload remember OSB is getting the full Cobol payload, all the business service requires is the last name. So here are the steps we have to go thru 1. check what action is required e.g. "C" 2. create a variable reflecting the parameter the action requires. e.g. create a variable based on the createPerson operation input data type. 3. Assign the last name from the payload to this variable 4. copy the variable to the OSB message body ($body is what will be passed to the business swervice). 5. call the relevant business service. Steps Create a Pipeline pair

Insert a log activity to output the incoming message

I set the level to ERROR so that I can see the message in the WLS console. Add a Route Node

Add a Routing Table

Add case --> route based on request type

Specify target service

Specify "update" as the default operation for the Default route.

Now we can do the specific processing for the "create" route. Create an XQuery mapping for OSB-input to create-person service input

Add an Assign Activity

Add a variable of type createPerson

Add a Log activity to output the newly created variable

After the Log add a Replace activity to replace the $body value with that of $createPerson

Add a Log activity to output the new value of $body In the Response Pipeline --> result from the business service

Test

1 comments:

Raju said...

Thanks for the information shared here. that was an interesting and informative. I had a good experience by participating in the Cloud Computing and SOA Conference in 2009 which is most influential Business Technology Conference covering latest innovations and trends of Cloud Computing, SOA and its technologies. I learnt lot of new technologies in Cloud Computing. And I am planning to attend 2010 edition as well. I found the information about the conference from http://www.btsummit.com

Potrebbero piacerti anche