uCosminexus Service Platform, Reception and Adapter Definition Guide
This subsection describes how to define file adapters.
Contents of the message format to be created in file adapters are described here.
Send the following information in the request message used for requesting execution of file operations:
Table 3-14 File operation information
| Information | Description |
|---|---|
| File name | Specifies the name of the file that is to be read or written. Specify the file name in the absolute path. Length of the file name can be within the range of 1 to 200 bytes when it is converted to UTF-8. Spaces present before and after the file name are deleted. For Windows, the path is case-insensitive. You cannot specify a file in the following manner:
|
| Reading mode | Specifies the mode for reading a file. The mode name is as follows:
|
| Writing mode | Specifies the mode for writing a file. Mode names are as follows:
|
The contents of a request message differ as per the format or type of the file to be read or written. Therefore, describe only the required information in a message from the file operation information and data for writing a file at the time of message creation.
The following table describes the information required for a request message, when reading an XML file:
Table 3-15 Information of a request message when reading an XML file (XML message)
| Information | Tag name within a message | Specified value | Default value at the time of omission | Specification |
|---|---|---|---|---|
| Root element | ReadRequest | - | - | Y |
| File header element | fileheader | - | - | Y |
| File name element | filename | File name | - | Y |
| File mode element | filemode | all | all | N |
The following table describes the information required for a request message, when writing an XML file:
Table 3-16 Information of a request message when writing an XML file (XML message)
| Information | Tag name within a message | Specified value | Default value at the time of omission | Specification |
|---|---|---|---|---|
| Root element | WriteRequest | - | - | Y |
| File header element | fileheader | - | - | Y |
| File name element | filename | File name | - | N |
| File mode element | filemode | new | new | N |
| Data for writing a file | userdata | Optional to user | - | Y |
The following table describes the information required for a request message, when reading a binary file:
Table 3-17 Information of a request message when reading a binary file (XML message)
| Information | Tag name within a message | Specified value | Default value at the time of omission | Specification |
|---|---|---|---|---|
| Root element | ReadRequest | - | - | Y |
| File header element | fileheader | - | - | Y |
| File name element | filename | File name | - | Y |
| File mode element | filemode | all | all | N |
When writing a binary file, the request message will have binary format. The following figure shows the structure of a request message in binary format:
Figure 3-6 Structure of a request message in binary format
The overall length of a message must consist of the following relational expression:
Overall length >= 10 + L1 + 10 + L2
The following table describes the information required for a request message, when writing a binary file:
Table 3-18 Information of a request message when writing a binary file (binary message)
| Information | Specified value | Default value at the time of omission | Specification |
|---|---|---|---|
| Length of a file name | Specify byte length of a file name with decimal numeric string. | - | Y |
| File name | File name | - | Y |
| Length of a file option | Specify byte length of a file option with decimal numeric string. | - | Y |
| File option | New writing: mode=new Additional writing: mode=append |
mode=new | N |
| User data | Optional to user | - | Y# |
For details on the sample of each request message, see (f) Message examples.
Send the following information in the response message that returns the information on reading a file adapter to the invoker of a file adapter:
The contents of a response message differ as per the format and type of the file to be read or written. The following table describes the information of a response message that is returned when a file is to be read and written:
Table 3-19 Information of response message
| File format and type | Information | Tag name within a message | Return value |
|---|---|---|---|
| Reading an XML file | Data for reading a file | Optional to user | Optional to user |
| Writing an XML file | Result of file writing process | status | OK |
| Reading a binary file | Data for reading a file | - | Optional to user |
| Writing a binary file | Result of file writing process | status | OK |
If message formats of a file adapter invoker (standard message) and a file adapter (service component message) are different, create message format definition files of a file adapter invoker (standard message) and a file adapter (service component message). Map the respective message formats from the data transformation (mapping) definition screen.
The following table describes the message format definition file to be created when performing data transformation:
Table 3-20 Message format definition file to be created
| File format and type | Request message | Response message | ||
|---|---|---|---|---|
| Standard message (invoker) | Service component message (file adapter) | Standard message (invoker) | Service component message (file adapter) | |
| Reading an XML file | XML# | XML | XML# | XML |
| Writing an XML file | XML# | XML | XML# | XML |
| Reading a binary file | XML# | XML | XML | Binary |
| Writing a binary file | XML | Binary | XML# | XML |
The message format definition file to be created differs depending on whether to handle data in XML format or in binary format (other than XML format) in a message to be used in a file adapter.
Method of creating a standard message and file adapter (service component message) is as follows:
Table 3-21 Definition file used by the user and the need for editing this file
| File operation mode | Message type | Definition file that is used | Editing by user |
|---|---|---|---|
| Reading | Request message | adpff_read.xsd | N |
| Response message | Created by user | Y | |
| Writing | Request message | adpff_header.xsd | N |
| adpff_write.xsd | Y | ||
| Response message | adpff_result.xsd | N |
Figure 3-7 Message flow at the time of reading an XML file
Figure 3-8 Message flow at the time of writing an XML file
Figure 3-9 Format definition template file for a request message
The following table describes the format definition template file for a request message according to the line number given in the figure. Note that line numbers given in the figure are not included in the actual template.
Table 3-22 Description of the format definition template file for a request message
| Line number | Description |
|---|---|
| 4th line | Specifies name space declaration of the file operation information file (for XML format writing: adpff_header.xsd) for a request message. |
| 5th line | Specifies name space declaration of this template file. The user declares any prefix in the value of targetName space attribute specified in the 7th line. |
| 6th line | When importing another schema file, specify name space declaration of that schema.#1, #2 |
| 7th line | Specifies the target name space of this template file. The user specifies a unique target name space in the value of targetName space attribute. |
| 9th ~10th line | Specifies import declaration of the file operation information file for a request message (for XML format writing: adpff_header.xsd). For this template file, import the file operation information file for a request message (for XML format writing). The user modifies the value of schemaLocation attribute in the relative path on which the file operation information file for a request message exists (for XML format writing). Same directory is mentioned by default. |
| 14th~20th line | Specifies WriteRequest element declaration. It is the root element of a request message. For a file adapter, acquire this element name and determine file I/O type (WriteRequest: Writing, ReadRequest: Reading). Wait for fileheader element and userdata element. The user specifies the prefix declared in the 5th line as a prefix of userdata element. |
| 22nd line | Specifies userdata element declaration. |
| 23rd line | Specifies the XML schema information used for user data.#1, #2 |
The method to create a binary format definition file is described here.
The following table describes the definition file used by the user and the need for editing this file, when creating a binary format definition file:
Table 3-23 Definition file used by the user and the need for editing this file
| File operation mode | Message type | Definition file that is used | Editing by user |
|---|---|---|---|
| Reading | Request message | adpff_read.xsd | N |
| Response message | Created by user | Y | |
| Writing | Request message | adpff_write.fdx | Y |
| Response message | adpff_result.xsd | N |
The method to create a binary format definition file is described here.
Figure 3-10 Message flow at the time of reading a binary file
Figure 3-11 Message flow at the time of writing a binary file
Figure 3-12 Format definition template file for a request message screen
Table 3-24 Setup value of the format definition template file for a request message
| Element name | Data type | Size (byte) | Occurrence count | Description |
|---|---|---|---|---|
| adpff_write | - | - | - | Root element |
| fileheader | - | - | 1 time | File operation information element |
| filename_length | Integer | 10 | 1 time | File name length element |
| filename | String | Variable | 1 time | File name element |
| fileoption_length | Integer | 10 | 1 time | File option length element |
| fileoption | String | Variable | 1 time | File option element |
Figure 3-13 Sample screen after the binary format definition file is created
Examples of a request message when performing each file operation are as follows:
To describe message examples, the following table lists the format definition files for a request message used for defining the request message format:
Table 3-25 Format definition file list for a request message that is provided
| File name | Contents | Editing |
|---|---|---|
| adpff_read.xsd | Format definition file for a request message (for XML and binary format reading) | N |
| adpff_write.xsd | Format definition template file for a request message (for XML format writing) | Y |
| adpff_write.fdx | Format definition template file for a request message (for binary format writing) | Y |
<?xml version="1.0" encoding="UTF-8"?>
<adpff:ReadRequest xmlns:adpff="http://FlatFiles.cstmadp.csc.soft.Hitachi.co.jp/ReadRequest">
<fileheader>
<filename>C:\WORK\ReadFile.xml</filename>
<filemode>all</filemode>
</fileheader>
</adpff:ReadRequest>
<?xml version="1.0" encoding="UTF-8"?>
<!-- All Rights Reserved. Copyright (C) 2007, Hitachi, Ltd. -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:adpff="http://FlatFiles.cstmadp.csc.soft.Hitachi.co.jp/WriteRequest"
xmlns:wr="http://WriteRequest"
targetName space="http://WriteRequest">
<xsd:import name space="http://FlatFiles.cstmadp.csc.soft.Hitachi.co.jp/WriteRequest"
schemaLocation="adpff_header.xsd"/>
<xsd:element name="WriteRequest" type="wr:format"/>
<xsd:complexType name="format">
<xsd:sequence>
<xsd:element name="fileheader" type="adpff:fileheader"/>
<xsd:element name="userdata" type="wr:userdata"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="userdata">
<xsd:sequence>
<xsd:element name="customer" type="wr:customer"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="customer">
<xsd:sequence>
<xsd:element name="name" type="xsd:string" />
<xsd:element name="address" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
An example of describing a request message that complies with above-mentioned XML schema is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<wr:WriteRequest xmlns:wr="http://WriteRequest">
<fileheader>
<filename>C:\WORK\writeXML.xml</filename>
<filemode>new</filemode>
</fileheader>
<userdata>
<customer>
<name>Hitachi Taro</name>
<address>Yokohama Totsuka</address>
</customer>
</userdata>
</wr:WriteRequest>
<?xml version="1.0" encoding="UTF-8"?>
<!-- All Rights Reserved. Copyright (C) 2007, Hitachi, Ltd. -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:adpff="http://FlatFiles.cstmadp.csc.soft.Hitachi.co.jp/WriteRequest"
xmlns:wr="http://WriteRequest"
targetName space="http://WriteRequest"
xmlns:usr="http://UserSchema">
<xsd:import name space="http://FlatFiles.cstmadp.csc.soft.Hitachi.co.jp/WriteRequest"
schemaLocation="adpff_header.xsd"/>
<xsd:import name space="http://UserSchema" schemaLocation="User.xsd"/>
<xsd:element name="WriteRequest" type="wr:format"/>
<xsd:complexType name="format">
<xsd:sequence>
<xsd:element name="fileheader" type="adpff:fileheader"/>
<xsd:element name="userdata" type="wr:userdata"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="userdata">
<xsd:sequence>
<xsd:element ref="usr:customer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
The contents of the imported User.xsd are as follows:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:usr="http://UserSchema"
targetName space="http://UserSchema">
<xsd:element name="customer">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="address" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
An example of specifying a request message that complies with the above-mentioned XML schema is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<wr:WriteRequest xmlns:wr="http://WriteRequest">
<fileheader>
<filename>C:\WORK\writeXML.xml</filename>
<filemode>new</filemode>
</fileheader>
<userdata>
<usr:customer xmlns:usr="http://UserSchema">
<name>Hitachi Tarou</name>
<address>Yokohama Totsuka</address>
</usr:customer>
</userdata>
</wr:WriteRequest>
Figure 3-14 Definition screen in which the provided file is imported
Figure 3-15 Definition screen in which definition of the user data is added
Transform the data from the calling request message format of a file adapter into the binary format definition file that is created. Data length of filename and fileoption elements is automatically set in filename_length and fileoption_length elements using the data transformation function.
Figure 3-16 Data transformation definition screen
Set the message format definition file of transformation source and the message format definition file of transformation destination on the data transformation (mapping) definition screen and define the transformation.
For details on how to define data transformation, see 6. Defining Data Transformation in the manual Service Platform Basic Development Guide.
The procedure for defining a file adapter is as follows:
Create the file adapter execution environment property file using a sample file. Storage location of the sample file is as follows:
Installation directory of the service platform\CSC\custom-adapter\File\config\templates\adpff_exe.properties
The procedure for creating the file adapter execution environment property file is as follows:
Installation directory of the service platform\CSC\custom-adapter\File\config
The file adapter execution environment property file is reflected in the execution environment, when you start a file adapter. When changing the contents of the file adapter execution environment property file, stop the file adapter, and then perform the operation. If you restart the file adapter, the changed contents are reflected in the execution environment.
For details on the file adapter execution environment property file, see File adapter execution environment property file in the manual Service Platform Reference Guide.
All Rights Reserved. Copyright (C) 2015, Hitachi, Ltd.