uCosminexus Service Platform, Reception and Adapter Definition Guide
This subsection describes how to define mail adapters.
Please note the following points before setting mail adapters.
The following shows the types and forms of the message formats used by mail adapters.
Mail adapters use either of the following two message formats:
For the request message format, set the mail server information or user input information (such as the email body, address, and subject). For the response message format, the message ID of the sent mail is set.
A mail adapter uses the XML schema provided by the service platform as the message format. The XML schemata used for request messages and response messages are adpmail_smtp_request.xsd and adpmail_smtp_response.xsd, respectively.
The following describes the request message format and response message format used by mail adapters.
The files are stored in installation-directory-of-the-service-platform\CSC\schema\mail.
Table 3-66 Request message format
| Tag name | Number of occurrences | Description | ||||
|---|---|---|---|---|---|---|
| <request> | Once | -- | ||||
| |
<smtp-host-name> | 0 or once | A tag that indicates the IP address or host name of the mail server to connect with.
|
|||
| <request-id> | 0 or once | A tag that indicates the request ID created at the reception.
|
||||
| <smtp-port> | 0 or once | A tag that indicates the port number of the mail server to connect with.
|
||||
| <mail-user> | 0 or once | A tag that indicates the login user name of the mail server to connect with.
|
||||
| <mail-addr-to>#1 | 0 or once | A tag that indicates the email address of the user the email is sent to. If you specify multiple email addresses, use a comma (,) as the delimiter for the email addresses.
|
||||
| <mail-addr-from> | 0 or once | A tag that indicates the email address of the user who sends the email. You can specify only one email address.
|
||||
| <mail-addr-cc>#1 | 0 or once | A tag that indicates the email address of the user who is set for the CC field. If you specify multiple email addresses, use a comma (,) as the delimiter for the email addresses.
|
||||
| <mail-addr-bcc>#1 | 0 or once | A tag that indicates the email address of the user who is set for the BCC field. If you specify multiple email addresses, use a comma (,) as the delimiter for the email addresses.
|
||||
| <mail-subject-text> | 0 or once | A tag that indicates the subject of the email.
|
||||
| <mail-body>#2 | 0 or once | A tag that indicates the body of the email. Specify the email body by using <message> and <file>.
|
||||
| |
<message> | 0 or once | A tag that indicates the character string used as the email body. Before you use a character such as < or >, sanitize the character string.
|
|||
| <file> | 0 or once | A tag that indicates the path to the file whose contents are used as the email body and the character set. Specify the file path and the character set by <folder-name>, <mail-body-file-name>, and <file-charset>.
|
||||
| |
<folder-name> | Once | A tag that indicates the folder in which the file is to be stored.
|
|||
| <mail-body-file-name> | Once | A tag that indicates the file name to be acquired. Specify the file directly under the work folder or common folder. You can use a delimiter, such as a slash (/) or back slash (\) only for the beginning of the file name. If you use a slash (/) at the beginning of the file name, the slash (/) is ignored. Specify a file that is not a symbolic link. You cannot specify multiple file names.
|
||||
| <file-charset> | 0 or once | Specify the character set of the file containing the email body text.
|
||||
| <attachment-file> | 0 or once | A tag that indicates the email attachment. Specify the attachment by using <item>. You can specify multiple attachments.
|
||||
| |
|
<item> | Once or more | A tag that indicates the details of the email attachment. Specify the details of the attachment by using <attach-folder> and <attach-file-name>.
|
||
| |
<attach-folder> | Once | A tag that indicates the folder in which the attachment is stored.
|
|||
| <attach-file-name> | Once | A tag that indicates the name of the attachment. Specify the file directly under the work folder or common folder. You can use a delimiter, such as a slash (/) or back slash (\), only for the beginning of the file name. If you use a slash (/) at the beginning of the file name, the slash (/) is ignored. Specify a file that is not a symbolic link. You cannot specify multiple file names.
|
||||
| <mail-format> | 0 or once | A tag that indicates the email format. Specify one of the following: text/plain: Creates the email body in plain text. text/html: Creates the email body in html format. text/xml: Creates the email body in xml format.#4
|
||||
| <mail-encoding> | 0 or once | A tag that indicates the encoding of the email.
|
||||
| <mail-auth> | 0 or once | A tag that indicates the SMTP authentication format. Specify either of the following: PLAIN: Authentication is not performed. LOGIN: The user name and password are used for authentication when the user logs in.
|
||||
| <mail-option> | 0 or more | A tag that indicates the user-defined email header. Specify the header name and value by combining <option-key> and <option-value>.
|
||||
| |
<option-key> | Once | Specify the key name of the user-defined email header.
|
|||
| <option-value> | Once | Specify the value of the user-defined email header.
|
||||
Table 3-67 Response message format
| Tag name | Number of occurrences | Description | |
|---|---|---|---|
| <response> | Once | -- | |
| <message-id> | Once | A tag that indicates the message ID of the sent email message. When an email is sent, the internally created MimeMessage is sent to the mail server. The ID of this MimeMessage will be the message ID. |
|
The following are the types of definition files to be created:
The following describes how to create individual definition files.
For details about the definitions that can be edited in the mail adapter command definition file, see Mail adapter command definition file in the manual Service Platform Reference Guide.
For details about the definitions that can be edited in the email header definition file, see Mail header definition file in the manual Service Platform Reference Guide.
For details about the definitions that can be edited in the mail adapter runtime environment property file, see Mail adapter runtime environment property file in the manual Service Platform Reference Guide.
The contents of the mail adapter runtime environment property file are applied to the execution environment when the mail adapter starts operating. Therefore, if you change the contents of the mail adapter runtime environment property file, you need to temporarily stop the mail adapter.
To define a mail adapter:
The figure below shows the directory structure after the service platform is installed. Note that only the directories for storing the definitions and message schema of a mail adapter are shown in this figure.
Figure 3-23 Directory structure of a mail adapter
For details about directory structures other than the above, see 2.1.2 Installing Service Platform in the manual Service Platform Setup and Operation Guide.
Below are examples of setting a mail adapter and business process. In these examples, the message passed to the standard reception is set to the email body, and the email is sent to the destination set in the mail adapter runtime environment property file.
Below are examples of setting a mail adapter in the development environment and the mail adapter runtime environment property file.
Set the individual items in the Service Adapter Settings window in the development environment as shown below. For details about the storage location of the email format and definition file, and how to operate in the development environment, see 3.2.12 Adding a new mail adapter.
Figure 3-24 Example of configuring the Service Adapter Settings (standard) window
Table 3-68 Settings in the Service Adapter Settings (standard) window
| Category | Item | Setting | |
|---|---|---|---|
| Service component control information | Service name | mailadp | |
| Service ID | mailadp | ||
| Service type | Mail adapter | ||
| Address | -- | ||
| Maximum instances | 0 | ||
| Service class name | -- | ||
| Operation | SEND | ||
| Operation information | Operation name | SEND | |
| Communication model | Sync | ||
| Request message | Use any type check box | Do not use (leave the check box cleared) | |
| Standard | Use check box | Do not use (leave the check box cleared) | |
| Format ID | -- | ||
| Message format | -- | ||
| Service component | Format ID | mailadp_request | |
| Message format | adpmail_smtp_request.xsd | ||
| Data-conversion definition | -- | ||
| Response message | Use any type check box | Do not use (leave the check box cleared) | |
| Standard | Use check box | Do not use (leave the check box cleared) | |
| Format ID | -- | ||
| Message format | -- | ||
| Service component | Format ID | mailadp_response | |
| Message format | adpmail_smtp_response.xsd | ||
| Data-conversion definition | -- | ||
| Fault message | -- | -- | |
Figure 3-25 Example of setting the Service Adapter Settings (details) window
Table 3-69 Setting items in the Service Adapter Settings (details) window
| Category | Item | Setting |
|---|---|---|
| Service adapter control information | Service adapter (EJB-JAR file) | cscmsg_adpejb.jar |
| Utility class (JAR file) | adpmailpc.jar | |
| Self-defined file | -- |
Create the mail adapter runtime environment property file that corresponds to the mail adapter defined in the development environment. In the example below, the file name mailadp.properties is used.
For details about how to create the mail adapter runtime environment property file, see 3.3.12(3) Creating the mail adapter definition file.
An example of creating the mail adapter runtime environment property file is shown below. Italics indicate modified parts.
# All Rights Reserved. Copyright (C) 2011, Hitachi, Ltd. mailadp.smtp.host.name = mail-server #mailadp.smtp.port = 25 #mailadp.user = mailadp.addr.from = sampleuser2@XXXXXX.com mailadp.addr.to = sampleuser@XXXXXX.com #mailadp.addr.cc = #mailadp.addr.bcc = #mailadp.addr.count.max = 768 #mailadp.mail.body.size = 1024000 #mailadp.attach.path.1 = #mailadp.attach.file.size = 5242880 #mailadp.max.attach.count.per.mail = 10 #mailadp.mail.format = text/plain #mailadp.mail.body-text = #mailadp.mail.body-filepath = #mailadp.mail.body-filecharset = UTF-8 #mailadp.subject.size = 80 #mailadp.subject.text = mailadp.smtp.encoding = ISO-2022-JP #mailadp.smtp.auth = PLAIN #mailadp.user.header.path = #mailadp.account.file.path = #mailadp.methodtrace.level = 3 #mailadp.methodtrace.filepath = #mailadp.methodtrace.filenum = #mailadp.methodtrace.filesize = 2097152 #mailadp.messagelog.level = 10 #mailadp.smtp.timeout = 180 #mailadp.smtp.connectiontimeout = 180 #mailadp.read-lock.retry.count = 0 #mailadp.read-lock.retry.interval = 1 |
The created mail adapter runtime environment property file is stored in the installation-directory-of-the-service-platform\CSC\config\mail folder.
Below are examples of setting a business process in the development environment and data transformation definition.
For details about the window used in the development environment, see Chapter 1. Windows (Development Environment) in the manual Service Platform Reference Guide. For details about how to operate in the development environment, see Chapter 5. Defining Business Processes and Chapter 6. Defining Data Transformation in the manual Service Platform Basic Development Guide.
In the Define Business Process window in the development environment, define an activity as follows.
Figure 3-26 Example of setting a business process
Create variables for service component messages and standard messages, that are necessary for passing messages within a business process. Note that this setting example does not use a correlation set.
Table 3-70 Variables for service component message
| Variable name | Description |
|---|---|
| mail_input | A variable for request messages of the mail adapter |
| mail_output | A variable for response messages of the mail adapter |
Table 3-71 Setting values in the Take In Message Format dialog box
| Item name | Variable name | |
|---|---|---|
| mail_input | mail_output | |
| Service/Reception | Service name | Service name |
| Service name/Reception name | mailadp | mailadp |
| Operation name | SEND | SEND |
| Message type | Request message (Body) | Response message (Body) |
| Message format | mail_input | mail_output |
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="SampleSOAPinput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="MAIL_BODY" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
|
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="SampleSOAPoutput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="MESSAGE_ID" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
|
Table 3-72 Variables for standard messages
| Variable name | Description |
|---|---|
| input | Variable for request messages for standard reception |
| output | Variable for response messages for standard reception |
Table 3-73 Message format to be specified
| Variable name | Message format to be specified |
|---|---|
| input | input.xsd |
| output | output.xsd |
In the data transformation activity (CreateMailAdapterRequestMessage), you can perform mapping for creating a request message of the mail adapter from a request message of the standard reception. In the same way, in the data transformation activity (CreateResponseMessage), you can perform mapping for creating a response message of the standard adapter from a response message of the mail adapter.
First, right-click the data transformation activity (CreateMailAdapterRequestMessage) in the Define Business Process window, and then select Launch &mapping definition.
Map the MAIL_BODY element in the request message of the standard reception to the message element, which is the child element of the mail-body element in the request message of the mail adapter.
Figure 3-27 Mapping for the request message
In the same way, right-click the data transformation activity (CreateResponseMessage) in the Define Business Process window, and then select Launch &mapping definition.
Map the message-id element in the response message of the mail adapter to the MESSAGE_ID element in the response message of the standard reception.
Figure 3-28 Mapping for the response message
In the Define Business Process window, double-click the invoke service activity (InvokeMailAdapter), and then make the following settings in the displayed Invoke Service Activity dialog box.
Figure 3-29 Setting values for the invoke service activity
The following table describes the settings.
Table 3-74 Settings of the invoke service activity
| Category | Item | Setting value |
|---|---|---|
| Activity name | InvokeMailAdapter | |
| Service name | mailadp | |
| Operation name | SEND | |
| Communication model | Sync | |
| Request message | Body allocated variable | mail_input |
| Header allocated variable | -- | |
| Response message | Body allocated variable | mail_output |
| Header allocated variable | -- | |
| Correlation set group | -- | |
This completes the mail adapter and business process settings.
To execute the business process in this example setting, you need to specify a request message for the standard reception from the service requester, and then send the message. For details about how to create a service requester, see 8.2 Service Requester That Sends Requests to a Standard Synchronous Reception (Web Services) (SOAP communication infrastructure) in the manual the Service Platform Basic Development Guide.
After the above operation, perform validation and packaging of the component, perform deployment definition in the test environment, and then check the operation. For details, see Chapter 7. Packaging HCSC Components and Defining Deployment in the manual Service Platform Basic Development Guide.
All Rights Reserved. Copyright (C) 2015, Hitachi, Ltd.