XMLParserServiceの例1

LANSA Integrator

XMLParserServiceの例1


XMLParserServiceサービスをロードします。xmlは、ファイル、HTTP接続ホスト、FTP接続ホスト、またはPOP3ポスト・オフィス・メッセージから直接ロードします。(XML変換ウィザードで作成された)スタイル・シートを使用して、受信したxmlをFunctionXMLに変換し、LANSAファンクションのフィールドとリストにバインドします。

Windowsユーザーのメモ: XMLFileService.Properties、XMLParserService.PropertiesXMLQueueService.PropertiesのDTDエンティティ・リゾルバー・リストにすでにあるsystemid.file行の後に以下の行を追加する必要があります(LANSA INSTALLATION DIRECTORYを適切なディレクトリで置き換えます)。

systemid.file:///C:/<LANSA INSTALLATION DIRECTORY>/Integrator/JSMInstance/order.dtd=file:dtd/order.dtd

 

詳細については、「XMLエンティティ・リゾルバー」を参照してください。

 

********** Beginning of RDML commands **********                

FUNCTION   OPTIONS(*DIRECT)                                     

**********                                                      

DEFINE     FIELD(#JSMSTS) TYPE(*CHAR) LENGTH(20)                

DEFINE     FIELD(#JSMMSG) TYPE(*CHAR) LENGTH(255)               

DEFINE     FIELD(#JSMCMD) TYPE(*CHAR) LENGTH(255)

**********                                                      

DEFINE     FIELD(#ORDER) TYPE(*CHAR) LENGTH(10)                 

DEFINE     FIELD(#NAME) TYPE(*CHAR) LENGTH(50)                  

DEFINE     FIELD(#STREET) TYPE(*CHAR) LENGTH(50)                

DEFINE     FIELD(#CITY) TYPE(*CHAR) LENGTH(50)                  

DEFINE     FIELD(#STATE) TYPE(*CHAR) LENGTH(5)                  

DEFINE     FIELD(#ZIP) TYPE(*CHAR) LENGTH(5)                    

**********                                                      

DEFINE     FIELD(#LINENUM) TYPE(*DEC) LENGTH(3) DECIMALS(0)        

DEFINE     FIELD(#PARTNUM) TYPE(*DEC) LENGTH(3) DECIMALS(0)        

DEFINE     FIELD(#PARTDSC) TYPE(*CHAR) LENGTH(50)                  

DEFINE     FIELD(#PARTAMT) TYPE(*DEC) LENGTH(10) DECIMALS(2)       

DEFINE     FIELD(#PARTQTY) TYPE(*DEC) LENGTH(3) DECIMALS(0)        

**********                                                         

DEF_LIST   NAME(#WRKLST) FIELDS((#LINENUM) (#PARTNUM) (#PARTDSC) ( 

            #PARTAMT) (#PARTQTY)) TYPE(*WORKING)                    

**********                                                         

********** 'Open service'                                          

**********                                                         

USE        BUILTIN(JSM_OPEN) TO_GET(#JSMSTS #JSMMSG)               

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)          

**********                                                        

********** 'Load service'                                         

**********                                                        

USE        BUILTIN(JSM_COMMAND) WITH_ARGS('SERVICE_LOAD SERVICE(XM

           LPARSERSERVICE)') TO_GET(#JSMSTS #JSMMSG)              

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)          

**********                                                        

********** Load XML from required source.                 

********** Select required CHANGE command according to XML source.

**********  

********** Load directly from a file                      

CHANGE     FIELD(#JSMCMD) TO('LOAD METHOD(*FILE) FILE(order.xml)')

**********  

********** OR Load from an HTTP source                    

CHANGE     FIELD(#JSMCMD) TO('LOAD METHOD(*HTTP) HOST(LOCALHOST:84

           ) FILE(/order.xml)')    

********** OR Load from an FTP source

CHANGE     FIELD(#JSMCMD) TO('LOAD METHOD(*FTP) HOST(LOCALHOST) FI 

           LE(/jsm/instance/order.xml) USER(user) PASSWORD(passwor 

            d)')

********** OR Load from a POP3 mail source                

CHANGE     FIELD(#JSMCMD) TO('''LOAD METHOD(*POP3) SERVER(10.2.0.1

            2) USER(testuser) PASSWORD(testuser)''')       

**********                                                        

USE        BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS 

          #JSMMSG)                                               

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)          

**********                                                        

********** 'Transform to FunctionXML and bind to function         

**********                                                        

CHANGE     FIELD(#JSMCMD) TO('TRANSFORM XSL(ORDER) SERVICE_LIST(LI

           NENUM,PARTNUM,PARTDSC,PARTAMT,PARTQTY)')               

**********                                                        

USE        BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS 

           #JSMMSG #WRKLST)                                       

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)          

**********                                                        

********** Display XML order data                                  

**********                                                         

DISPLAY    FIELDS((#ORDER) (#NAME) (#STREET) (#CITY) (#STATE) (#ZI 

           P))                                                     

**********                                                         

SELECTLIST NAMED(#WRKLST)                                          

**********                                                         

DISPLAY    FIELDS((#LINENUM) (#PARTNUM) (#PARTDSC) (#PARTAMT) (#PA 

           RTQTY))                                                 

ENDSELECT                                                          

********** 'Unload service'                                        

**********                                                        

USE        BUILTIN(JSM_COMMAND) WITH_ARGS('SERVICE_UNLOAD') TO_GET

           (#JSMSTS #JSMMSG)                                      

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)          

**********                                                        

********** 'Close service'                                        

**********                                                        

USE        BUILTIN(JSM_CLOSE) TO_GET(#JSMSTS #JSMMSG)             

EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)          

**********                                                        

********** SUB ROUTINES                                           

**********                                                        

SUBROUTINE NAME(CHECK) PARMS((#JSMSTS *RECEIVED) (#JSMMSG *RECEIVE

           D))                                         

IF         COND('#JSMSTS *NE OK')                      

DISPLAY    FIELDS((#JSMSTS) (#JSMMSG))                 

**********                                             

USE        BUILTIN(JSM_CLOSE) TO_GET(#JSMSTS #JSMMSG)  

**********                                             

MENU       MSGTXT('Java service error has occurred')   

**********                                             

ENDIF                                                  

**********                                             

ENDROUTINE                                             

********** End of RDML commands **********