XOBVLIB ;; mjk/alb - VistaLink Programmer Library ; 07/27/2002 13:00 ;;1.5;VistALink;;Sep 09, 2005 ;;Foundations Toolbox Release v1.5 [Build: 1.5.0.026] ; QUIT ; -------------------------------------------------------------- ; Application Developer Supported Calls ; -------------------------------------------------------------- ; XMLHDR() ; -- provides current XML standard header QUIT "" ; CHARCHK(STR) ; -- replace xml character limits with entities NEW A,I,X,Y,Z,NEWSTR SET (Y,Z)="" IF STR["&" SET NEWSTR=STR DO SET STR=Y_Z . FOR X=1:1 SET Y=Y_$PIECE(NEWSTR,"&",X)_"&",Z=$PIECE(STR,"&",X+1,999) QUIT:Z'["&" IF STR["<" FOR SET STR=$PIECE(STR,"<",1)_"<"_$PIECE(STR,"<",2,99) QUIT:STR'["<" IF STR[">" FOR SET STR=$PIECE(STR,">",1)_">"_$PIECE(STR,">",2,99) QUIT:STR'[">" IF STR["'" FOR SET STR=$PIECE(STR,"'",1)_"'"_$PIECE(STR,"'",2,99) QUIT:STR'["'" IF STR["""" FOR SET STR=$PIECE(STR,"""",1)_"""_$PIECE(STR,"""",2,99) QUIT:STR'["""" ; FOR I=1:1:$LENGTH(STR) DO . SET X=$EXTRACT(STR,I) . SET A=$ASCII(X) . IF A<31 SET STR=$PIECE(STR,X,1)_$PIECE(STR,X,2,99) QUIT STR ; STOP() ; -- called by application to determine if processing should stop gracefully NEW XOBFLAG ; ; -- do checks (only one now is time out) DO TOFLAG ; ; -- set 'stop' flag SET XOBFLAG=$$TOCHK() ; QUIT XOBFLAG ; GETTO() ; -- get time out value QUIT $GET(XOBDATA("XOB RPC","TIMEOUT"),300) ; SETTO(TO) ; -- set time out value on the fly SET XOBDATA("XOB RPC","TIMEOUT")=TO QUIT 1 ; ; -------------------------------------------------------------- ; Foundations Developer Calls (Unsupported) ; -------------------------------------------------------------- ; VLHDR(NUM) ; -- provides current VistaLink standard header NEW X,TYPE,SCHEMA ; ; -- get type info SET X=$PIECE($TEXT(TYPE+NUM),";;",2) SET TYPE=$PIECE(X,"^",2) SET SCHEMA=$PIECE(X,"^",3) QUIT $$ENVHDR(TYPE,SCHEMA) ; TYPE ; -- return message types [ number ^ message type ^ schema file ] ;;1^gov.va.med.foundations.rpc.response^rpcResponse.xsd ;;2^gov.va.med.foundations.rpc.fault^rpcFault.xsd ;;3^gov.va.med.foundations.vistalink.system.fault^vlFault.xsd ;;4^gov.va.med.foundations.vistalink.system.response^vlSimpleResponse.xsd ; ERROR(XOBDAT) ; -- send error type message NEW XOBI,XOBY,XOBOS SET XOBY="XOBY" ; -- build xml DO BUILD(.XOBY,.XOBDAT) ; USE XOBPORT DO OS^XOBVSKT ; -- write xml DO PRE^XOBVSKT SET XOBI=0 FOR SET XOBI=$ORDER(XOBY(XOBI)) QUIT:'XOBI DO WRITE^XOBVSKT(XOBY(XOBI)) ; -- send eot and flush buffer DO POST^XOBVSKT QUIT ; BUILD(XOBY,XOBDAT) ; -- store built xml in passed store reference (XOBY) ; -- input format ; XOBDAT("MESSAGE TYPE") = # type of message (ex. 2 = gov.va.med.foundations.vistalink.rpc.fault :: See TYPE tag) ; XOBDAT("ERRORS",,"CODE") = error code ; XOBDAT("ERRORS",,"ERROR TYPE") = type of error (system/application/security) ; XOBDAT("ERRORS",,"MESSAGE",) = error message ; ; -- SOAP related information ; XOBDAT("ERRORS",,"FAULT CODE") = high level code on where error occurred (ex. Client, Server, etc.) ; - Default: Server ; XOBDAT("ERRORS",,"FAULT STRING") = high level fault type text (ex. System Error) ; - Default: System Error ; XOBDAT("ERRORS",,"FAULT ACTOR") = RPC, routine, etc. running when error occurred ; - Default: [none] ; NEW XOBCODE,XOBI,XOBERR,XOBLINE,XOBETYPE SET XOBLINE=0 ; DO ADD($$VLHDR($GET(XOBDAT("MESSAGE TYPE")))) DO ADD("") DO ADD(""_$GET(XOBDAT("ERRORS",1,"FAULT CODE"),"Server")_"") DO ADD(""_$GET(XOBDAT("ERRORS",1,"FAULT STRING"),"System Error")_"") DO ADD(""_$GET(XOBDAT("ERRORS",1,"FAULT ACTOR"))_"") DO ADD("") SET XOBERR=0 FOR SET XOBERR=$ORDER(XOBDAT("ERRORS",XOBERR)) QUIT:'XOBERR DO . SET XOBCODE=$GET(XOBDAT("ERRORS",XOBERR,"CODE"),0) . SET XOBETYPE=$GET(XOBDAT("ERRORS",XOBERR,"ERROR TYPE"),0) . DO ADD("") . DO ADD("") . IF $GET(XOBDAT("ERRORS",XOBERR,"CDATA")) DO ADD("") . DO ADD("") . DO ADD("") DO ADD("") DO ADD("") DO ADD($$ENVFTR()) ; QUIT ; ADD(TXT) ; -- add line SET XOBLINE=XOBLINE+1 SET @XOBY@(XOBLINE)=TXT QUIT ; GETRATE() ; -- get J2SE heartbeat rate in seconds NEW X SET X=$PIECE($GET(^XOB(18.01,1,0)),"^",2) QUIT $SELECT(X:X,1:180) ; GETDELTA() ; -- get J2SE latancy delta in seconds NEW X SET X=$PIECE($GET(^XOB(18.01,1,0)),"^",3) QUIT $SELECT(X:X,1:180) ; GETASTO() ; -- get J2EE application server time out in seconds (one day = 86400) NEW X SET X=$PIECE($GET(^XOB(18.01,1,0)),"^",4) QUIT $SELECT(X:X,1:86400) ; GETRASTO() ; -- get J2EE application server reauthenticated seesion time out in seconds (ten minutes = 600) NEW X SET X=$PIECE($GET(^XOB(18.01,1,0)),"^",5) QUIT $SELECT(X:X,1:600) ; TOFLAG ; -- set timed out flag ; -- if run in non-VistALink environment never time out ; set both now & start = $h SET XOBDATA("XOB RPC","TIMED OUT")=($$HDIFF^XLFDT($HOROLOG,$GET(XOBDATA("XOB RPC","START"),$HOROLOG),2)>$$GETTO()) QUIT ; TOCHK() ; -- did RPC timeout? QUIT +$GET(XOBDATA("XOB RPC","TIMED OUT")) ; ENVHDR(TYPE,SCHEMA) ; -- vistalink beg tag (header) NEW X,VLVER SET X=$$XMLHDR() SET X=X_"" QUIT X ; ENVFTR() ; -- vistalink end tag (footer) QUIT "" ; SYSOS(XOBOS) ; -- get system operating system ; -- DBIA #3522 QUIT $SELECT(XOBOS["OpenM":$$OS^%ZOSV(),XOBOS["DSM":"VMS",1:"Unknown") ;