XMLParserService 1

Loads XMLParserService service. Loads xml directly from a file or from an HTTP connected host or from an FTP connected host or from a POP3 post office message. Transforms the received xml to FunctionXML using a stylesheet (created using the XML Transformation Wizard) and binds to the LANSA function fields and list.

Windows Users Note:
You will need to add the following line (replacing the LANSA INSTALLATION DIRECTORY with the appropriate directory) following the existing systemid.file line in the DTD Entity Resolver list in the XMLFileService.Properties, XMLParserService.Properties and XMLQueueService.Properties:

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

For further information, refer to XML Entity Resolver.

********** 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 **********