uCosminexus Service Platform, Reception and Adapter Definition Guide

[Contents][Glossary][Index][Back][Next]

Appendix D.3 Sample for reading XML data

In the sample for reading XML data, a file adapter is used to read data from a file in XML format, and the data is stored in the database through a DB adapter.

The following table lists the items that are input and output:

Table D-4 Input and output items (sample for reading XML data)

Input or output item Description
Input file of file adapter service-platform-installation-directory\CSC\custom-adapter\File\sample\read_xml\read_xml_data.xml
Output table of DB adapter ADMIN.CSAFF_SAMPLE_RX#

#
Do not change the schema name.

Organization of this subsection
(1) Defining the file adapter
(2) Defining the business process
(3) Distributing the file adapter and business process deployment definitions
(4) Creating tables
(5) Creating request messages
(6) Executing the business process

(1) Defining the file adapter

(a) Adding and validating the file adapter

To add and validate a file adapter:

  1. From the Eclipse menu, select Window, Show View, and then Other.
    The Show View dialog box appears.
  2. Select HCSC-Definer and then HCSCTE View, and click OK.
    The Service Definition List appears in the tree view.
  3. Right-click the Service Definition List in the tree view, and select Add Service Adapter.
    The Service adapter definition addition wizard appears.
  4. From the Service component type: drop-down list, select File adapter.
  5. Click Next.
    The Service adapter definition addition (File Adapter) wizard appears.
  6. Enter the service name.
    Enter CSAFF_SAMPLE_READ_XML as the service name.
  7. Click Finish.
    The necessary files are created, and stored in the repository. The Service adapter definition (standard) window appears.
  8. Enter settings in the Service adapter definition (standard) and Service adapter definition (details) windows.
    For details on the settings you need to enter, see File adapter settings (sample for reading XML data).
  9. Review the content of the definition, and then save the definition by selecting File and then Save from the Eclipse menu.
  10. Verify the file adapter settings.
    Select Verify from the pop-up list displayed when you right-click the Service Definition List in the tree view. The results of the verification process appear in Console View.

File adapter settings (sample for reading XML data)
The table below shows the items you need to set in the Service adapter definition (standard) window when defining the file adapter for the sample for reading XML data. You do not need to set items that do not appear in this table.

Table D-5 Settings in Service adapter definition (standard) window (sample for reading XML data)

Category Item Value to set Requires setting
Service component control information Service name CSAFF_SAMPLE_READ_XML Y
Service ID CSAFF_RX Y
Service type File adapter N
Maximum instances 0 Y
Operation Pattern: XML file reading
Operation name: CSAFF_SAMPLE_READ_XML
Y
Operation information Operation name CSAFF_SAMPLE_READ_XML N
Communication model Sync Y
Request message Standard Use check box Do not use (leave the check box cleared) Y
Service component Format ID SAMPLE_READ_XML_Request Y
Message format adpff_read.xsd N
Response message Standard Use check box Do not use (leave the check box cleared) Y
Service component Format ID SAMPLE_READ_XML_Response Y
Message format csaff_sample_read_xml.xsd Y

Legend:
Y: Must be set.
N: Check the content that is already displayed.

The table below shows the items you need to set in the Service adapter definition (details) window when defining the file adapter for the sample for reading XML data. You do not need to set items that do not appear in this table.

Table D-6 Settings in Service adapter definition (details) window (sample for reading XML data)

Category Item Value to set Requires setting
Service adapter control information Service adapter (EJB-JAR file) cscmsg_adpejb.jar N
Utility class (JAR file) adpffpc.jar N

Legend:
N: Check the content that is already displayed.

(b) Creating the file adapter runtime-environment property file

To create the file adapter runtime-environment property file:

  1. Open the sample file adapter runtime-environment property file in a text editor.
    The sample file adapter runtime-environment property file is service-platform-installation-directory\CSC\custom-adapter\File\sample\read_xml\CSAFF_RX.properties.
  2. Add the following content to the file:
    fileaccess.path1 = service-platform-installation-directory\\CSC\\custom-adapter\\File\\sample\\read_xml
    Note
    Use \\ as the delimiting characters between directories.
  3. Save the file in the following directory: service-platform-installation-directory\CSC\custom-adapter\File\config

(2) Defining the business process

The task of defining a business process involves adding a business process, defining the contents of the business process, and then validating the business process.

(a) Adding a business process

To add a business process:

  1. From the Eclipse menu, select Window, Show View, and then Other.
    The Show View dialog box appears.
  2. Select HCSC-Definer and then HCSCTE View, and click OK.
    The Service Definition List appears in the tree view.
  3. Right-click the Service Definition List in the tree view, and select Add Business Process.
    A dialog box appears in which you can add a business process definition.
  4. Enter the name of the business process, and select whether to make its status persistent (whether to save the execution status of the business process in the database).
    Enter CSAFF_SAMPLE_BP_READ_XML as the business process name.
    Select yes for Status Persistence.
    Reference note
    Do not use a BPEL file.
  5. Click Finish.
    The necessary files are created, and stored in the repository. The Define Business Process window appears.
(b) Setting variables

Set the following variables:

Reference note
The sample business process does not use a correlation set.

To set the variables:

  1. On the canvas of the Define Business Process window, double-click the Variable-Correlation icon.
    The List Of Variables And Correlation Sets dialog box appears.
  2. Select Variable List from the list.
  3. Enter the variable name.
  4. From the Type: drop-down list, select XML.
  5. Perform whichever of the following operations is relevant for the variable you are defining:
    For CSAFF_DB_ResponseMessage, CSAFF_RequestMessage, and CSAFF_ResponseMessage
    In the Take In Message Format dialog box displayed by clicking the Take In button, specify the message format you want to use. For details on the settings you need to enter, see Variable settings (sample for reading XML data).
    For CSAFF_DB_RequestMessage
    Click the ... button and select the csaff_sample_read_xml_dt.xsd file.
  6. Click Add.
    The variable you added appears in the list of variables.
  7. Repeat steps 2 to 6 for each variable.
  8. Click OK.
    The variable settings are saved and the List Of Variables And Correlation Sets dialog box closes.

Variable settings (sample for reading XML data)
The tables below show the settings for the CSAFF_DB_ResponseMessage, CSAFF_RequestMessage, and CSAFF_ResponseMessage variables. You do not need to set items that do not appear in this table.

Table D-7 Settings for CSAFF_DB_ResponseMessage (sample for reading XML data)

Category Item Value to set
Service/Reception Service name CSAFF_SAMPLE_DB
Reception name --
Target for take in Operation name CSAFF_SAMPLE_DB
Message type Response message (Body)
-- Message format csaff_sample_sqlformat

Legend:
--: Not applicable.

Table D-8 Settings for CSAFF_RequestMessage (sample for reading XML data)

Category Item Value to set
Service/Reception Service name CSAFF_SAMPLE_READ_XML
Reception name --
Target for take in Operation name CSAFF_SAMPLE_READ_XML
Message type Request message (Body)
-- Message format adpff_read

Legend:
--: Not applicable.

Table D-9 Settings for CSAFF_ResponseMessage (sample for reading XML data)

Category Item Value to set
Service/Reception Service name CSAFF_SAMPLE_READ_XML
Reception name --
Target for take in Operation name CSAFF_SAMPLE_READ_XML
Message type Response message (Body)
-- Message format csaff_sample_read_xml

Legend:
--: Not applicable.

(c) Setting up activities

The following describes how to arrange and define the activities in the figure below, define the data transformations, and connect the activities.

Figure D-3 Overall view of business process definition (sample for reading XML data)

[Figure]

Arranging and defining activities

In the sample for reading XML data, set up the activities shown in the following table.

Table D-10 List of activities (sample for reading XML data)

Activity Activity name Description
Reception CSAFF_SAMPLE_BP_READ_XML Receives messages into the business process.
Reply CSAFF_SAMPLE_BP_READ_XML_RSP Issues a response from the business process.
Invoke Service InvokeFileAadapter Invokes the file adapter.
Invoke Service InvokeDBAdapter Invokes the DB adapter.
Data transformation CreateDBAdapterRequestMessage Transforms a response message from the file adapter to a request message for the DB adapter.

To position and set up an activity:

  1. In the palette, click the basic or structure activity you want to place on the canvas.
    The activity you clicked is selected.
  2. Click the appropriate location on the canvas.
    The selected activity is placed on the canvas. You can reposition the activity by dragging it with your mouse.
  3. Double-click the activity on the canvas.
    A dialog box appears in which you can enter settings for the activity you double-clicked.
  4. Enter the necessary information in the dialog box.
    For details on the information you need to set, see Activity settings (sample for reading XML data).
  5. Click OK.
    The dialog box for the activity closes.
  6. Repeat steps 1 to 5 for each activity.

Activity settings (sample for reading XML data)
The tables below show the settings for the business process activities used in the sample for reading XML data. You do not need to set items that do not appear in this table.

Table D-11 Settings for CSAFF_SAMPLE_BP_READ_XML

Item Value to set
Activity name CSAFF_SAMPLE_BP_READ_XML
Operation name CSAFF_SAMPLE_BP_READ_XML
Body allocated variable CSAFF_RequestMessage
Communication model Sync
Instance generation Yes

Table D-12 Settings for CSAFF_SAMPLE_BP_READ_XML_RSP

Item Value to set
Activity name CSAFF_SAMPLE_BP_READ_XML_RSP
Operation name CSAFF_SAMPLE_BP_READ_XML
Body allocated variable CSAFF_DB_ResponseMessage

Table D-13 Settings for InvokeFileAadapter (sample for reading XML data)

Item Value to set
Activity name InvokeFileAadapter
Service name CSAFF_SAMPLE_READ_XML
Operation name CSAFF_SAMPLE_READ_XML
Communication model Sync
Request message Body allocated variable CSAFF_RequestMessage
Response message Body allocated variable CSAFF_ResponseMessage

Table D-14 Settings for InvokeDBAdapter (sample for reading XML data)

Item Value to set
Activity name InvokeDBAdapter
Service name CSAFF_SAMPLE_DB
Operation name CSAFF_SAMPLE_DB
Communication model Sync
Request message Body allocated variable CSAFF_DB_RequestMessage
Response message Body allocated variable CSAFF_DB_ResponseMessage

Table D-15 Settings for CreateDBAdapterRequestMessage (sample for reading XML data)

Item Value to set
Activity name CreateDBAdapterRequestMessage
Source Variables CSAFF_ResponseMessage
Destination Variable CSAFF_DB_RequestMessage
Data TransDefn File SAMPLE_READ_XML_DT
Setting the data transformation definition for the CreateDBAdapterRequestMessage activity

Set the data transformation definition for the CreateDBAdapterRequestMessage activity. The following figure shows the data transformation definition you need to set:

Figure D-4 Data conversion definition window for CreateDBAdapterRequestMessage activity (sample for reading XML data)

[Figure]

To set the data transformation definition for the CreateDBAdapterRequestMessage activity:

  1. Display the data transformation (mapping) definition screen from the CreateDBAdapterRequestMessage activity.
    After the data transformation (mapping) definition screen is displayed, the Select Root Element dialog box appears.
  2. Select the root elements for all logical schema names.
    The OK button becomes available.
  3. Click OK.
    The schemas of the selected root elements appear in tree format in the transformation-source schema tree viewer and the transformation-destination schema tree viewer.
  4. Perform mapping.
    Mapping involves the following tasks:
    • Placing and setting functions
      The following table shows the function settings:

      Table D-16 Function settings (sample for reading XML data)

      Function Function name Value to set
      loop loop1 Select Node DATA
      Set Node Condition Do not set
    • Setting inter-node mapping
      The following table shows the inter-node mapping settings:

      Table D-17 Mapping settings (function for reading XML data)

      Source node Function Target node
      -- loop1 DBA_MULTI_SQL
      ORDER_NO -- val1
      CUSTOMER_CODE -- val2
      PRODUCT_CODE -- val3
      ORDER_COUNT -- val4

      Legend:
      --: Not applicable.

  5. In the data transformation (mapping) definition screen, right-click an appropriate location in the transformation-source schema tree viewer, transformation-destination schema tree viewer, or mapping viewer, and select Validate.
    Validation takes place. You can ignore any warning messages that appear.
Connecting activities

In the sample business process for reading XML data, connect the activities as shown in the following table.

Table D-18 Activity connections (sample for reading XML data)

Connection-source activity Connection-target activity
Start CSAFF_SAMPLE_BP_READ_XML
CSAFF_SAMPLE_BP_READ_XML InvokeFileAadapter
InvokeFileAadapter CreateDBAdapterRequestMessage
CreateDBAdapterRequestMessage InvokeDBAdapter
InvokeDBAdapter CSAFF_SAMPLE_BP_READ_XML_RSP
CSAFF_SAMPLE_BP_READ_XML_RSP Finish

To connect the activities:

  1. On the palette, click Connection.
    Connection mode is selected.
    When you align your cursor with an activity that can be specified as a connection source, the background color of the activity changes.
  2. On the canvas, click the activity that you want to serve as the connection source.
    The activity is set as the connection source.
    If you then align your cursor with another activity, the background color of the activity changes if it can be specified as a connection target.
  3. On the canvas, click the activity that you want to serve as the connection target.
    The activity you selected as the connection source is connected to the activity you selected as the connection target.
(d) Saving and validating the business process

To save and validate the business process:

  1. Review the definition contents, and then save the business process definition by selecting File and then Save from the Eclipse menu.
    In properties view, set CSAFF_B1 as the service ID of the business process.
  2. Validate the business process settings.
    Select Verify from the pop-up list displayed when you right-click the Service Definition List in the tree view. The results of the validation process appear in Console View.

(3) Distributing the file adapter and business process deployment definitions

Deploy the file adapter and business process and start them on the server.

To distribute the file adapter and business process deployment definitions:

  1. Right-click the Service Definition List in the tree view, and select Deploy all services to server and start.
    If the file adapter or business process fails to start, a dialog box appears describing the nature of the error. Look up the message ID displayed in the error details and take the appropriate action.

    If you are not logged in, the Account Verification window appears. In this case, perform step 2.
  2. Enter admin in the User ID field and the Password field, and then click OK.
    A message indicating that account verification is in progress appears, followed by a message indicating whether verification was successful.

(4) Creating tables

Create the table the sample business process will access in the database.

Open HiRDB SQL Executer and execute the following SQL statement:

CREATE TABLE CSAFF_SAMPLE_RX
(ORDER_NO INT,
 CUSTOMER_CODE CHAR(5),
 PRODUCT_CODE CHAR(4),
 ORDER_COUNT INT);
Note
Use ADMIN as the user ID.

(5) Creating request messages

The following describes how to create a request message by editing the sample request message used when executing the business process.

  1. Open the sample request message file in a text editor.
    The sample request message file is service-platform-installation-directory\CSC\custom-adapter\File\sample\read_xml\read_xml_message.xml.
  2. Add the part in italics below:
    <?xml version="1.0" encoding="UTF-8"?>
    <adpff:ReadRequest xmlns:adpff="http://FlatFiles.cstmadp.csc.soft.Hitachi.co.jp/ReadRequest">
      <fileheader>
        <filename>service-platform-installation-directory\CSC\custom-adapter\File\sample\read_xml\read_xml_data.xml</filename>
        <filemode>all</filemode>
      </fileheader>
    </adpff:ReadRequest>
  3. Save the file.

(6) Executing the business process

To execute the sample, start the business process from the service requester.

The flow of service requester processing is as follows:

  1. Service requester execution
    The request message of the business process is used as the request message of the file adapter without transformation.
  2. File adapter execution
    The file specified in the request message is read.
  3. DB adapter message creation
    The response message from the file adapter is transformed to a request message for the DB adapter.
  4. DB adapter execution
    The file specified in the request message is registered in the database.
  5. Service requester termination
    The response message from the DB adapter is used as the response message of the business process without transformation.

To execute the service requester:

  1. Navigate to service-platform-installation-directory\CSC\custom-adapter\File\sample\bin.
  2. Execute request.bat.
    Execute request.bat in the following format:
    request read_xml service-platform-installation-directory\CSC\custom-adapter\File\sample\read_xml\read_xml_message.xml

Reference note
You can check the contents of the table by starting HiRDB SQL Executer and executing the following SQL statement (using ADMIN as the user ID):
SELECT * FROM CSAFF_SAMPLE_RX;