[ADOS] ADOS Developer's Site - XML Stadium
ADOS Company slogan - XML Total Solution

【RJOによるServiceContentの作成】

目次

概要

EISにおいてServiceContentを作成する方法について解説します。

サンプルプログラム全体を以下に示します。

【PIPSenderRJO.java】

1 : import java.io.FileInputStream;
2 : import java.util.Date;
3 : import java.util.Properties;
4 : 
5 : import com.ados.hestia.parser.rnbm.access.Validator;
6 : import com.ados.hestia.parser.rnbm.exchange.Container;
7 : import com.ados.hestia.parser.rnbm.exchange.PayloadContainer;
8 : import com.ados.hestia.parser.rnbm.exchange.StatusContainer;
9 : import com.ados.hestia.parser.rnbm.model.RootElement;
10 : import com.ados.hestia.parser.rnbm.particle.DateTimeStamp;
11 : import com.ados.hestia.parser.rnbm.particle.ServiceContent;
12 : import com.ados.hestia.parser.rnbm.repository.Repository;
13 : import com.ados.hestia.sdk.Configuration;
14 : import com.ados.hestia.sdk.Connection;
15 : import com.ados.hestia.sdk.message.DirectMessageExchanger;
16 : import com.ados.hestia.sdk.session.InitiationSession;
17 : import com.ados.hestia.sdk.session.Session;
18 : import com.ados.hestia.utils.UID;
19 : 
20 : public class PIPSenderRJO {
21 : 
22 :   public static void main(String[] args) {
23 :     try {
24 :       Properties prop = new Properties();
25 :       prop.load(new FileInputStream("sample.properties"));
26 :       String HOST = prop.getProperty("HOST");
27 :       String USER = prop.getProperty("USER");
28 :       String PASS = prop.getProperty("PASS");
29 :       String HANDLER_ID = prop.getProperty("HANDLER_ID");
30 :       String SENDER = prop.getProperty("SENDER");
31 :       String RECEIVER = prop.getProperty("RECEIVER");
32 : 
33 :       Connection connection = new Connection(HOST, USER, PASS,
34 :           Connection.EXCHANGE_MODE_DIRECT, null, null, null,
35 :           HANDLER_ID);
36 :       DirectMessageExchanger exchanger = new DirectMessageExchanger(
37 :           connection, Configuration.getInstance());
38 : 
39 :       RootElement re = Repository.getDefault().getResolver()
40 :           .resolveByVersion("0C1",
41 :         "Pip0C1AsynchronousTestNotification", "R01.01.00");
42 :       ServiceContent sc = new ServiceContent("0C1", re);
43 :       sc.setProduction(true);
44 :       sc.setGlobalDocumentFunctionCode("Request");
45 :       sc.setDocumentGenerationDateTime(new DateTimeStamp());
46 :       sc.setDocumentIdentifier(new UID().toString());
47 :       sc.setElementValue(
48 :         "AsynchronousTest/Attachment/description/FreeFormText",
49 :         "A");
50 :       sc.setElementValue(
51 :         "AsynchronousTest/Attachment/GlobalAttachmentDescriptionCode",
52 :         "Assembly drawings");
53 :       sc.setElementValue(
54 :           "AsynchronousTest/Attachment/GlobalMimeTypeQualifierCode",
55 :           "application/activemessage");
56 :       sc.setElementValue(
57 :           "AsynchronousTest/Attachment/UniversalResourceIdentifier",
58 :           "A");
59 :       sc.setElementValue(
60 :         "fromRole/PartnerRoleDescription/ContactInformation/contactName/FreeFormText",
61 :         "NAME AAAAA");
62 :       sc.setElementValue(
63 :         "fromRole/PartnerRoleDescription/ContactInformation/EmailAddress",
64 :         "NAME.AAAA@XX.XX.XX");
65 :       sc.setElementValue(
66 :         "fromRole/PartnerRoleDescription/ContactInformation/facsimileNumber/CommunicationsNumber",
67 :         "FAX-XX-XXXX");
68 :       sc.setElementValue(
69 :         "fromRole/PartnerRoleDescription/ContactInformation/telephoneNumber/CommunicationsNumber",
70 :         "Tel-XX-XXXX");
71 :       sc.setElementValue(
72 :         "fromRole/PartnerRoleDescription/GlobalPartnerRoleClassificationCode",
73 :         "Account Supplier");
74 :       sc.setElementValue(
75 :         "fromRole/PartnerRoleDescription/PartnerDescription/BusinessDescription/GlobalBusinessIdentifier",
76 :         SENDER);
77 :       sc.setElementValue(
78 :         "fromRole/PartnerRoleDescription/PartnerDescription/BusinessDescription/GlobalSupplyChainCode",
79 :         "Electronic Components");
80 :       sc.setElementValue(
81 :         "fromRole/PartnerRoleDescription/PartnerDescription/GlobalPartnerClassificationCode",
82 :         "Authorized Service Provider");
83 :       sc.setElementValue(
84 :         "toRole/PartnerRoleDescription/ContactInformation/contactName/FreeFormText",
85 :         "NAME BBBBB");
86 :       sc.setElementValue(
87 :         "toRole/PartnerRoleDescription/ContactInformation/EmailAddress",
88 :         "NAME.BBBBB@XX.XX.XX");
89 :       sc.setElementValue(
90 :         "toRole/PartnerRoleDescription/ContactInformation/facsimileNumber/CommunicationsNumber",
91 :         "FAX-XX-XXXX");
92 :       sc.setElementValue(
93 :         "toRole/PartnerRoleDescription/ContactInformation/telephoneNumber/CommunicationsNumber",
94 :         "Tel-XX-XXXX");
95 :       sc.setElementValue(
96 :         "toRole/PartnerRoleDescription/GlobalPartnerRoleClassificationCode",
97 :         "Account Supplier");
98 :       sc.setElementValue(
99 :         "toRole/PartnerRoleDescription/PartnerDescription/BusinessDescription/GlobalBusinessIdentifier",
100 :         RECEIVER);
101 :       sc.setElementValue(
102 :         "toRole/PartnerRoleDescription/PartnerDescription/BusinessDescription/GlobalSupplyChainCode",
103 :         "Electronic Components");
104 :       sc.setElementValue(
105 :         "toRole/PartnerRoleDescription/PartnerDescription/GlobalPartnerClassificationCode",
106 :         "Authorized Service Provider");
107 : 
108 :       Session session = new InitiationSession(new PayloadContainer(
109 :           new Date(), SENDER, RECEIVER, (new UID()).toString(), sc,
110 :           null));
111 :       SampleUtils.printSessionState("created", session);
112 :       PayloadContainer request = session.getMessageToSend();
113 :       SampleUtils.printSessionState("got", session);
114 :       SampleUtils.printContainerInformation(request);
115 :       SampleUtils.printServiceContent(request.getServiceContent());
116 :       new Validator(request.getServiceContent().getElement()).validate();
117 :       exchanger.sendMessage(request);
118 :       SampleUtils.printSessionState("sent", session);
119 : 
120 :       int time = 0;
121 :       boolean loop = true;
122 :       while (loop) {
123 :         Thread.sleep(5000);
124 :         exchanger.hit();
125 :         SampleUtils.printSessionState("loop=" + time++, session);
126 : 
127 :         Container container = exchanger.receiveMessage();
128 :         if (container != null) {
129 :           SampleUtils.printContainerInformation(container);
130 :           session.pushStatus((StatusContainer) container);
131 :           SampleUtils.printSessionState("pushed", session);
132 :           loop = false;
133 :         }
134 :       }
135 : 
136 :     } catch (Exception e) {
137 :       e.printStackTrace();
138 :     }
139 :   }
140 : 
141 : }

ServiceContentの生成

PIP名等を指定し、ServiceContentを生成します。

39 :       RootElement re = Repository.getDefault().getResolver()
40 :           .resolveByVersion("0C1",
41 :         "Pip0C1AsynchronousTestNotification", "R01.01.00");
42 :       ServiceContent sc = new ServiceContent("0C1", re);

ServiceContentへの値の設定

ServiceContent#setProductionは、ServiceContentでなくServiceHeaderの下記のパスに値を設定します。これは、このPIPメッセージが本番用(true)かテスト用(false)かを識別します。

  • /ServiceHeader/ProcessControl/GlobalUsageCode
43 :       sc.setProduction(true);

その他、ServiceContentへの値の設定に、以下のようなメソッドを使用可能です。

44 :       sc.setGlobalDocumentFunctionCode("Request");
45 :       sc.setDocumentGenerationDateTime(new DateTimeStamp());
46 :       sc.setDocumentIdentifier(new UID().toString());
47 :       sc.setElementValue(
48 :         "AsynchronousTest/Attachment/description/FreeFormText",
49 :         "A");

トップ   差分 バックアップ リロード   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: Mon, 24 Oct 2005 17:12:21 JST (4925d)

Copyright 2005-2008. ADOS Co., Ltd. All Rights Reserved.