[ADOS] ADOS Developer's Site - XML Stadium
ADOS Company slogan - XML Total Solution
RIGHT:[[目次>Hestia Hacks#SDKDevGuide]]|[[前>SDKの概要]]|[[次>連携方式]]

#contents
*メッセージコンテナ [#msgcontainer]
Hestiaは、EISとメッセージのやりとりを行う際にビジネスメッセージをJava Objectとして扱います。

下記にビジネスメッセージに対応したJava Objectのクラス図を示します。

#ref(figure3.png)

**Container [#sa57a68c]
HestiaとEIS間でメッセージ連携を行う際は、メッセージの''容れ物''であるContainerオブジェクトがやりとりされます。実際には、Containerクラスはabstractであり、PayloadContainerまたはStatusContainerがインスタンス化されます。
**PayloadContainer [#id1ebbd7]
ビジネスメッセージ本体のServiceContent、および添付ファイルに対応するAttachmentオブジェクトのコンテナです。
**ServiceContent [#qdfce7c0]
RosettaNetのパブリックプロセスにおけるActionメッセージ(RosettaNetのPIP、Chem eStandardsのビジネスメッセージ)本体です。公開APIにおいては、XMLメッセージとServiceContentの相互変換、およびXMLのXPathリストからServiceContentインスタンスを作成する関数群が公開されています。
**Attachment [#s4c3e67f]
ビジネスメッセージに添付されたファイルへのインターフェースを提供します。

Attachmentオブジェクト自体は添付ファイルの実体を持っておらず、ファイルの実体はHestiaの内部データベースに格納されていますが、EISはAttachmentオブジェクトが提供するAPI関数を利用しそれを意識せずに透過的にファイル実体のストリームへアクセスできます。
**StatusContainer [#lf6982e9]
RosettaNetのパブリックプロセスにおけるSignalメッセージ(ReceiptAcknowledgment, Exception等)を示すオブジェクトです。
*サンプルコード [#JOsample]
**XMLからServiceContentへの変換 [#xml2sc]
以下はXML実ファイルからServiceContentオブジェクトへの変換例です。
 001: import com.ados.hestia.parser.rnbm.exchange.*;
 002: import com.ados.hestia.sdk.rnbm.access.*;
 003: import java.io.*;
 004: public class MessageUtil {
 005: /**
 006:  * Construct ServiceContent from XML file
 007:  *
 008:  * @param filename  stored XML file
 009:  * @param pipid     PIP ID (e.g. 3A4)
 010:  * @param pipver    PIP Version (e.g. V02.00.00)
 011:  * @param isRequest indicate XML file is a request or not. For instance, if XML file is 3A4Configmation, isRequest must be false.
 012:  * @return created ServiceContent Object
 013:  * @throws FileNotFoundException
 014:  * @throws BuilderException
 015:  */
 016: public static ServiceContent readXML(String filename, String pipid, String pipver, boolean isRequest) throws FileNotFoundException, BuilderException {
 017:     Reader reader = new BufferedReader(new FileReader(filename));
 018:     XMLBuilder builder = new XMLBuilder(reader, pipid, pipver, isRequest);
 019:     return builder.build();
 020: }
 021:}

**ServiceContentからXMLの抽出 [#sc2xml]
以下はServiceContentオブジェクト-->実ファイルへの変換例です。
 001: import com.ados.hestia.parser.rnbm.exchange.*;
 002: import com.ados.hestia.sdk.rnbm.access.*;
 003: import java.io.*;
 004: public class MessageUtil {
 005:    /**
 006:     * Save XML from ServiceContent
 007:     * @param filename filename to be saved
 008:     * @param sc ServiceContent Object
 009:     * @throws IOException
 010:     * @throws ReaderException
 011:     */
 012:    public static void saveXML(String filename, ServiceContent sc) throws IOException, ReaderException {
 013:        Writer writer = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(filename)));
 014:        XMLReader reader = new XMLReader(writer, sc);
 015:        reader.read();
 016:        writer.flush();
 017:        writer.close();
 018:    }
 019: }

**XPathリストからServiceContentの作成 [#xpath2sc]
以下はPIP0C1 R01.02.00のXPathリストからServiceContentを構築するサンプルです。指定するXPathはルート要素を除いた値を指定します。
 001: import com.ados.hestia.parser.rnbm.exchange.*;
 002: import com.ados.hestia.sdk.rnbm.access.*;
 003: import java.io.*;
 004: public class MessageUtil {
 005:   /**
 006:    * Construct ServiceContent from XPath sample
 007:    * @return ServiceContent instance
 008:    */
 009:   public static ServiceContent constructServiceContent() throws BuilderException, ValidateException {
 010:       String[][] values0C1 = {
 011:               {"fromRole/PartnerRoleDescription/ContactInformation/contactName/FreeFormText","FromSomeone"},
 012:               {"fromRole/PartnerRoleDescription/ContactInformation/EmailAddress","foo@bar.com"},
 013:               {"fromRole/PartnerRoleDescription/ContactInformation/facsimileNumber/CommunicationsNumber","000000"},
 014:               {"fromRole/PartnerRoleDescription/ContactInformation/telephoneNumber/CommunicationsNumber","111111"},
 015:               {"fromRole/PartnerRoleDescription/GlobalPartnerRoleClassificationCode","Initiator"},
 016:               {"fromRole/PartnerRoleDescription/PartnerDescription/BusinessDescription/GlobalBusinessIdentifier","987654321"},
 017:               {"fromRole/PartnerRoleDescription/PartnerDescription/BusinessDescription/GlobalSupplyChainCode","Information Technology"},
 018:               {"fromRole/PartnerRoleDescription/PartnerDescription/GlobalPartnerClassificationCode","Distribution Center"},
 019:               {"GlobalDocumentFunctionCode","Request"},
 020:               {"thisDocumentGenerationDateTime/DateTimeStamp","20060207T054242.786Z"},
 021:               {"thisDocumentIdentifier/ProprietaryDocumentIdentifier","01da6112.00000108b3217628.8011"},
 022:               {"toRole/PartnerRoleDescription/ContactInformation/contactName/FreeFormText","ToSomeone"},
 023:               {"toRole/PartnerRoleDescription/ContactInformation/EmailAddress","bar@baz.com"},
 024:               {"toRole/PartnerRoleDescription/ContactInformation/facsimileNumber/CommunicationsNumber","222222"},
 025:               {"toRole/PartnerRoleDescription/ContactInformation/telephoneNumber/CommunicationsNumber","333333"},
 026:               {"toRole/PartnerRoleDescription/GlobalPartnerRoleClassificationCode","Responder"},
 027:               {"toRole/PartnerRoleDescription/PartnerDescription/BusinessDescription/GlobalBusinessIdentifier","123456789"},
 028:               {"toRole/PartnerRoleDescription/PartnerDescription/BusinessDescription/GlobalSupplyChainCode","Electronic Components"},
 029:               {"toRole/PartnerRoleDescription/PartnerDescription/GlobalPartnerClassificationCode","Authorized Service Provider"},
 030:               {"AsynchronousTest/Attachment/GlobalAttachmentDescriptionCode","Assembly drawings"},
 031:               {"AsynchronousTest/Attachment/GlobalMimeTypeQualifierCode","application/pdf"},
 032:               {"AsynchronousTest/Attachment/UniversalResourceIdentifier","DUMMY"}
 033:       };
 034:       Map<String,String> pathmap = new HashMap<String,String>();
 035:       for (String[] value : values0C1) {
 036:           pathmap.put(value[0], value[1]);
 037:       }
 038:       XPathBuilder builder = new MapBuilder(pathmap, null, "0C1", "R01.02.00", true);
 039:       ServiceContent sc = builder.build();
 040:       sc.validate();
 041:       return sc;
 042:   }

**Attachmentオブジェクトから実ファイルへの保存 [#saveatt]
 001: import com.ados.hestia.parser.rnbm.exchange.*;
 002: import com.ados.hestia.sdk.rnbm.access.*;
 003: import java.io.*;
 004: import org.apache.commons.io.CopyUtils;
 005: public class MessageUtil {
 006: /**
 007:  * Retrieve Attachment
 008:  * @param filename filename to be saved
 009:  * @param att Attachment Object
 010:  * @throws IOException
 011:  */
 012: public static void saveAttachment(String filename, Attachment att) throws IOException {
 013:     InputStream in = att.openSharedStream();
 014:     OutputStream out = new BufferedOutputStream(new FileOutputStream(filename));
 015:     CopyUtils.copy(in, out);
 016:     out.flush();
 017:     out.close();
 018:     in.close();
 019: }
 020:}

トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS

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