XOBWLIB ;ALB/MJK - HWSC :: Utilities Library ; 09/13/10 4:00pm
;;1.0;HwscWebServiceClient;;September 13, 2010;Build 31
;
QUIT
;
;----------------------------- Public APIs ----------------------------
;
;. . . . . . . . . . . . Web Service Proxy APIs . . . . . . . . . . . .
;
GETFAC(XOBWSN) ; -- get web service proxy factory
; Input:
; XOBWSN - web service name
QUIT ##class(xobw.WebServiceProxyFactory).%New(XOBWSN)
;
GETPROXY(XOBWSN,XOBSRVR) ; -- get web service proxy
; Input:
; XOBWSN - web service name
; XOBSRVR - web server name
QUIT ##class(xobw.WebServiceProxyFactory).getWebServiceProxy(XOBWSN,XOBSRVR)
;
GENPORT(XOBY) ; -- generate http port class from WSDL during install
QUIT $$GENPORT^XOBWD(.XOBY)
;
REGSOAP(XOBWSN,XOBCXT,XOBCLASS,XOBWSDL,XOBCAURL) ; -- register SOAP service
; Input:
; XOBWSN - SOAP web service name
; XOBCXT - web service context root
; XOBCLASS - full class name, including package
; XOBWSDL - file path containing WSDL document [optional]
; XOBCAURL - 'check availability' url portion to follow context root [optional]
DO REGISTER^XOBWD(XOBWSN,1,XOBCXT,XOBCLASS,.XOBWSDL,.XOBCAURL)
QUIT
;
ATTACHDR(XOBPROXY) ; -- add VistaInfoHeader to proxy object
; Input:
; XOBPROXY - web service proxy object
DO ATTACHDR^XOBWLIB1(.XOBPROXY)
QUIT
;
UNREG(XOBWSN) ; unregister/delete REST *or* SOAP web service
; Input:
; XOBWSN - web service name
DO UNREG^XOBWD(XOBWSN)
QUIT
;
;. . . . . . . . . . . . REST Service Request APIs . . . . . . . . . . . .
;
GETRESTF(XOBWSN) ; -- get REST service request factory
; Input:
; XOBWSN - web service name
QUIT ##class(xobw.RestRequestFactory).%New(XOBWSN)
;
GETREST(XOBWSN,XOBSRVR) ; -- get REST service request
; Input:
; XOBWSN - web service name
; XOBSRVR - web server name
QUIT ##class(xobw.RestRequestFactory).getRestRequest(XOBWSN,XOBSRVR)
;
REGREST(XOBWSN,XOBCXT,XOBCAURL) ; -- register REST service
; Input:
; XOBWSN - REST web service name
; XOBCXT - web service context root
; XOBCAURL - 'check availability' url portion to follow context root [optional]
DO REGISTER^XOBWD(XOBWSN,2,XOBCXT,"","",.XOBCAURL)
QUIT
;
GET(XOBREST,XOBRSCE,XOBERR,XOBFERR) ; -- do HTTP GET method and force M/Cache error if problem encountered
; Executes STATCHK and HTTPCHK calls.
; input:
; XOBREST = instance of xobw.RestRequest class
; XOBRSCE = resource for HTTP GET method
; XOBERR = where to store HWSC error object if problem encountered
; XOBFERR = if error object created, force M/Cache error [1], otherwise return to caller [0]
; [optional ; default = 1]
NEW XOBOK
SET XOBOK=$$STATCHK(XOBREST.Get(XOBRSCE),.XOBERR,$GET(XOBFERR,1))
IF XOBOK SET XOBOK=$$HTTPCHK(XOBREST,.XOBERR,$GET(XOBFERR,1))
QUIT XOBOK
;
POST(XOBREST,XOBRSCE,XOBERR,XOBFERR) ; -- do HTTP POST method and force M/Cache error if problem encountered
; Executes STATCHK and HTTPCHK calls.
; input:
; XOBREST = instance of xobw.RestRequest class
; XOBRSCE = resource for HTTP GET method
; XOBERR = where to store HWSC error object if problem encountered
; XOBFERR = if error object created, force M/Cache error [1], otherwise return to caller [0]
; [optional ; default = 1]
NEW XOBOK
SET XOBOK=$$STATCHK(XOBREST.Post(XOBRSCE),.XOBERR,$GET(XOBFERR,1))
IF XOBOK SET XOBOK=$$HTTPCHK(XOBREST,.XOBERR,$GET(XOBFERR,1))
QUIT XOBOK
;
HTTPCHK(XOBREST,XOBERR,XOBFERR) ; -- check HTTP response status code
; input:
; XOBREST = instance of xobw.RestRequest class
; XOBERR = where to store HWSC error object if problem encountered
; XOBFERR = if error object created, force M/Cache error [1], otherwise return to caller [0]
; [optional ; default = 1]
NEW XOBOK
SET XOBOK=$$HTTPOK(XOBREST.HttpResponse.StatusCode)
IF 'XOBOK DO
. ; -- create http error from %Net.HttpResponse object
. SET XOBERR=$$EOHTTP(XOBREST.HttpResponse)
. ; -- force error if requested to by caller
. IF $GET(XOBFERR,1) SET $ECODE=",UXOBWHTTP,"
QUIT XOBOK
;
HTTPOK(XOBSCODE) ; -- is HTTP response status code an 'OK' code
; -- Future: Should we add more 200 series codes to the check?
QUIT $GET(XOBSCODE)=200
;
;. . . . . . . . . . . Error Processing Helper API . . . . . . . . . . .
;
EOFAC(XOBPROXY) ; -- Error Object FACtory
; > finds and parses errors in partition
; > builds and returns error object for easier processing
;
; input: XOBPROXY = SOAP proxy object reference [optional]
; output: XOBERR = error object
;
QUIT $$EOFAC^XOBWLIB1(.XOBPROXY)
;
EOSTAT(XOBSO) ; -- create object error from status error object
NEW $ETRAP
SET $ETRAP="D ^%ZTER HALT"
QUIT ##class(xobw.error.ObjectError).%New(XOBSO)
;
EOHTTP(XOBHRO) ; -- create object error from %Net.HttpResponse object
NEW $ETRAP
SET $ETRAP="D ^%ZTER HALT"
QUIT ##class(xobw.error.HttpError).%New(XOBHRO)
;
ERRDISP(XOBEO) ; -- do simple error display
IF $GET(XOBEO)]"",XOBEO.%IsA("xobw.error.AbstractError") DO
. DO XOBEO.display()
QUIT
;
ERR2ARR(XOBEO,XOBERR) ; -- decompose error for traditional M processing
IF $GET(XOBEO)]"",XOBEO.%IsA("xobw.error.AbstractError") DO
. DO XOBEO.decompose(.XOBERR)
QUIT
;
ZTER(XOBEO) ; -- build error object array and call error trap
NEW $ETRAP,XOBEOARR
SET $ETRAP="D ^%ZTER HALT"
IF $GET(XOBEO)]"" DO ERR2ARR(.XOBEO,.XOBEOARR)
DO ^%ZTER
QUIT
;
STATCHK(XOBSO,XOBERR,XOBFERR) ; -- check Cache Status Object
; input:
; XOBSO = Cache status object
; XOBERR = where to store HWSC error object if problem encountered
; XOBFERR = if error object created, force M/Cache error [1], otherwise return to caller [0]
; [optional ; default = 1]
NEW XOBOK
SET XOBOK=$system.Status.IsOK(XOBSO)
IF 'XOBOK DO
. ; -- create object error from status error object
. SET XOBERR=$$EOSTAT(XOBSO)
. ; -- force error if requested to by caller
. IF $GET(XOBFERR,1) SET $ECODE=",UXOBWSTATUS,"
QUIT XOBOK
;
;. . . . . . . . . . . . . . Server Lookup APIs . . . . . . . . . .
SKEYADD(XOBWKEY,XOBWDESC,XOBERR) ; add or edit a server key name/desc (no prompting)
; input parameters:
; XOBWKEY: name for key
; XOBWDESC: (optional) brief description
; XOBERR: (optional) textual error description as array node(s) starting
; at XOBERR(1) / passed by reference
; returns:
; >0: success (value = IEN of new or existing entry)
; 0: failure (did not add/edit key)
Q $$SKEYADD^XOBWLIB1(.XOBWKEY,.XOBWDESC,.XOBERR)
;
SNAME4KY(XOBWKEY,XOBWSNM,XOBERR) ; get server name based on key
; input parameters:
; XOBWKEY: name of key to lookup
; XOBWSNM: where web server name is returned / passed by reference
; XOBERR: (optional) where any error is returned / passed by reference
; format: <error #>^<error text>
; errors possible:
; 186008^description (key does not exist)
; 186009^description (server association missing)
; returns:
; 1 - successful lookup
; 0 - unsuccessful lookup
;
Q $$SNAME4KY^XOBWLIB1(.XOBWKEY,.XOBWSNM,.XOBERR)
;
;. . . . . . . . . . . . . . Developer Testing APIs . . . . . . . . .
;
SELSRV() ; -- interactive display and selection of an server
; Input: None
; Output:
; Function Value - server name
; -- display servers
DO DISPSRVS
; -- select server
QUIT $$GETSRV()
;
GETSRV() ; -- PUBLIC API: return interactive-user-selected server name
; User selects a server entry in the WEB SERVER file (#18.12)
; Input:
; None
; Output:
; Function Value - server name (#.01 field of file 18.12)
;
QUIT $$GETSRV^XOBWLIB1()
;
DISPSRVS ; -- display servers
; Input:
; None
; Output:
; Screen formatted display of app servers and associated fields from file 18.12
;
DO DISPSRVS^XOBWLIB1
QUIT
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HXOBWLIB 8235 printed Oct 16, 2024@18:46:32 Page 2
XOBWLIB ;ALB/MJK - HWSC :: Utilities Library ; 09/13/10 4:00pm
+1 ;;1.0;HwscWebServiceClient;;September 13, 2010;Build 31
+2 ;
+3 QUIT
+4 ;
+5 ;----------------------------- Public APIs ----------------------------
+6 ;
+7 ;. . . . . . . . . . . . Web Service Proxy APIs . . . . . . . . . . . .
+8 ;
GETFAC(XOBWSN) ; -- get web service proxy factory
+1 ; Input:
+2 ; XOBWSN - web service name
+3 QUIT ##class(xobw.WebServiceProxyFactory).%New(XOBWSN)
+4 ;
GETPROXY(XOBWSN,XOBSRVR) ; -- get web service proxy
+1 ; Input:
+2 ; XOBWSN - web service name
+3 ; XOBSRVR - web server name
+4 QUIT ##class(xobw.WebServiceProxyFactory).getWebServiceProxy(XOBWSN,XOBSRVR)
+5 ;
GENPORT(XOBY) ; -- generate http port class from WSDL during install
+1 QUIT $$GENPORT^XOBWD(.XOBY)
+2 ;
REGSOAP(XOBWSN,XOBCXT,XOBCLASS,XOBWSDL,XOBCAURL) ; -- register SOAP service
+1 ; Input:
+2 ; XOBWSN - SOAP web service name
+3 ; XOBCXT - web service context root
+4 ; XOBCLASS - full class name, including package
+5 ; XOBWSDL - file path containing WSDL document [optional]
+6 ; XOBCAURL - 'check availability' url portion to follow context root [optional]
+7 DO REGISTER^XOBWD(XOBWSN,1,XOBCXT,XOBCLASS,.XOBWSDL,.XOBCAURL)
+8 QUIT
+9 ;
ATTACHDR(XOBPROXY) ; -- add VistaInfoHeader to proxy object
+1 ; Input:
+2 ; XOBPROXY - web service proxy object
+3 DO ATTACHDR^XOBWLIB1(.XOBPROXY)
+4 QUIT
+5 ;
UNREG(XOBWSN) ; unregister/delete REST *or* SOAP web service
+1 ; Input:
+2 ; XOBWSN - web service name
+3 DO UNREG^XOBWD(XOBWSN)
+4 QUIT
+5 ;
+6 ;. . . . . . . . . . . . REST Service Request APIs . . . . . . . . . . . .
+7 ;
GETRESTF(XOBWSN) ; -- get REST service request factory
+1 ; Input:
+2 ; XOBWSN - web service name
+3 QUIT ##class(xobw.RestRequestFactory).%New(XOBWSN)
+4 ;
GETREST(XOBWSN,XOBSRVR) ; -- get REST service request
+1 ; Input:
+2 ; XOBWSN - web service name
+3 ; XOBSRVR - web server name
+4 QUIT ##class(xobw.RestRequestFactory).getRestRequest(XOBWSN,XOBSRVR)
+5 ;
REGREST(XOBWSN,XOBCXT,XOBCAURL) ; -- register REST service
+1 ; Input:
+2 ; XOBWSN - REST web service name
+3 ; XOBCXT - web service context root
+4 ; XOBCAURL - 'check availability' url portion to follow context root [optional]
+5 DO REGISTER^XOBWD(XOBWSN,2,XOBCXT,"","",.XOBCAURL)
+6 QUIT
+7 ;
GET(XOBREST,XOBRSCE,XOBERR,XOBFERR) ; -- do HTTP GET method and force M/Cache error if problem encountered
+1 ; Executes STATCHK and HTTPCHK calls.
+2 ; input:
+3 ; XOBREST = instance of xobw.RestRequest class
+4 ; XOBRSCE = resource for HTTP GET method
+5 ; XOBERR = where to store HWSC error object if problem encountered
+6 ; XOBFERR = if error object created, force M/Cache error [1], otherwise return to caller [0]
+7 ; [optional ; default = 1]
+8 NEW XOBOK
+9 SET XOBOK=$$STATCHK(XOBREST.Get(XOBRSCE),.XOBERR,$GET(XOBFERR,1))
+10 IF XOBOK
SET XOBOK=$$HTTPCHK(XOBREST,.XOBERR,$GET(XOBFERR,1))
+11 QUIT XOBOK
+12 ;
POST(XOBREST,XOBRSCE,XOBERR,XOBFERR) ; -- do HTTP POST method and force M/Cache error if problem encountered
+1 ; Executes STATCHK and HTTPCHK calls.
+2 ; input:
+3 ; XOBREST = instance of xobw.RestRequest class
+4 ; XOBRSCE = resource for HTTP GET method
+5 ; XOBERR = where to store HWSC error object if problem encountered
+6 ; XOBFERR = if error object created, force M/Cache error [1], otherwise return to caller [0]
+7 ; [optional ; default = 1]
+8 NEW XOBOK
+9 SET XOBOK=$$STATCHK(XOBREST.Post(XOBRSCE),.XOBERR,$GET(XOBFERR,1))
+10 IF XOBOK
SET XOBOK=$$HTTPCHK(XOBREST,.XOBERR,$GET(XOBFERR,1))
+11 QUIT XOBOK
+12 ;
HTTPCHK(XOBREST,XOBERR,XOBFERR) ; -- check HTTP response status code
+1 ; input:
+2 ; XOBREST = instance of xobw.RestRequest class
+3 ; XOBERR = where to store HWSC error object if problem encountered
+4 ; XOBFERR = if error object created, force M/Cache error [1], otherwise return to caller [0]
+5 ; [optional ; default = 1]
+6 NEW XOBOK
+7 SET XOBOK=$$HTTPOK(XOBREST.HttpResponse.StatusCode)
+8 IF 'XOBOK
Begin DoDot:1
+9 ; -- create http error from %Net.HttpResponse object
+10 SET XOBERR=$$EOHTTP(XOBREST.HttpResponse)
+11 ; -- force error if requested to by caller
+12 IF $GET(XOBFERR,1)
SET $ECODE=",UXOBWHTTP,"
End DoDot:1
+13 QUIT XOBOK
+14 ;
HTTPOK(XOBSCODE) ; -- is HTTP response status code an 'OK' code
+1 ; -- Future: Should we add more 200 series codes to the check?
+2 QUIT $GET(XOBSCODE)=200
+3 ;
+4 ;. . . . . . . . . . . Error Processing Helper API . . . . . . . . . . .
+5 ;
EOFAC(XOBPROXY) ; -- Error Object FACtory
+1 ; > finds and parses errors in partition
+2 ; > builds and returns error object for easier processing
+3 ;
+4 ; input: XOBPROXY = SOAP proxy object reference [optional]
+5 ; output: XOBERR = error object
+6 ;
+7 QUIT $$EOFAC^XOBWLIB1(.XOBPROXY)
+8 ;
EOSTAT(XOBSO) ; -- create object error from status error object
+1 NEW $ETRAP
+2 SET $ETRAP="D ^%ZTER HALT"
+3 QUIT ##class(xobw.error.ObjectError).%New(XOBSO)
+4 ;
EOHTTP(XOBHRO) ; -- create object error from %Net.HttpResponse object
+1 NEW $ETRAP
+2 SET $ETRAP="D ^%ZTER HALT"
+3 QUIT ##class(xobw.error.HttpError).%New(XOBHRO)
+4 ;
ERRDISP(XOBEO) ; -- do simple error display
+1 IF $GET(XOBEO)]""
IF XOBEO.%IsA("xobw.error.AbstractError")
Begin DoDot:1
+2 DO XOBEO.display()
End DoDot:1
+3 QUIT
+4 ;
ERR2ARR(XOBEO,XOBERR) ; -- decompose error for traditional M processing
+1 IF $GET(XOBEO)]""
IF XOBEO.%IsA("xobw.error.AbstractError")
Begin DoDot:1
+2 DO XOBEO.decompose(.XOBERR)
End DoDot:1
+3 QUIT
+4 ;
ZTER(XOBEO) ; -- build error object array and call error trap
+1 NEW $ETRAP,XOBEOARR
+2 SET $ETRAP="D ^%ZTER HALT"
+3 IF $GET(XOBEO)]""
DO ERR2ARR(.XOBEO,.XOBEOARR)
+4 DO ^%ZTER
+5 QUIT
+6 ;
STATCHK(XOBSO,XOBERR,XOBFERR) ; -- check Cache Status Object
+1 ; input:
+2 ; XOBSO = Cache status object
+3 ; XOBERR = where to store HWSC error object if problem encountered
+4 ; XOBFERR = if error object created, force M/Cache error [1], otherwise return to caller [0]
+5 ; [optional ; default = 1]
+6 NEW XOBOK
+7
*** ERROR ***
SET XOBOK=$system.Status.IsOK(XOBSO)
+8 IF 'XOBOK
Begin DoDot:1
+9 ; -- create object error from status error object
+10 SET XOBERR=$$EOSTAT(XOBSO)
+11 ; -- force error if requested to by caller
+12 IF $GET(XOBFERR,1)
SET $ECODE=",UXOBWSTATUS,"
End DoDot:1
+13 QUIT XOBOK
+14 ;
+15 ;. . . . . . . . . . . . . . Server Lookup APIs . . . . . . . . . .
SKEYADD(XOBWKEY,XOBWDESC,XOBERR) ; add or edit a server key name/desc (no prompting)
+1 ; input parameters:
+2 ; XOBWKEY: name for key
+3 ; XOBWDESC: (optional) brief description
+4 ; XOBERR: (optional) textual error description as array node(s) starting
+5 ; at XOBERR(1) / passed by reference
+6 ; returns:
+7 ; >0: success (value = IEN of new or existing entry)
+8 ; 0: failure (did not add/edit key)
+9 QUIT $$SKEYADD^XOBWLIB1(.XOBWKEY,.XOBWDESC,.XOBERR)
+10 ;
SNAME4KY(XOBWKEY,XOBWSNM,XOBERR) ; get server name based on key
+1 ; input parameters:
+2 ; XOBWKEY: name of key to lookup
+3 ; XOBWSNM: where web server name is returned / passed by reference
+4 ; XOBERR: (optional) where any error is returned / passed by reference
+5 ; format: <error #>^<error text>
+6 ; errors possible:
+7 ; 186008^description (key does not exist)
+8 ; 186009^description (server association missing)
+9 ; returns:
+10 ; 1 - successful lookup
+11 ; 0 - unsuccessful lookup
+12 ;
+13 QUIT $$SNAME4KY^XOBWLIB1(.XOBWKEY,.XOBWSNM,.XOBERR)
+14 ;
+15 ;. . . . . . . . . . . . . . Developer Testing APIs . . . . . . . . .
+16 ;
SELSRV() ; -- interactive display and selection of an server
+1 ; Input: None
+2 ; Output:
+3 ; Function Value - server name
+4 ; -- display servers
+5 DO DISPSRVS
+6 ; -- select server
+7 QUIT $$GETSRV()
+8 ;
GETSRV() ; -- PUBLIC API: return interactive-user-selected server name
+1 ; User selects a server entry in the WEB SERVER file (#18.12)
+2 ; Input:
+3 ; None
+4 ; Output:
+5 ; Function Value - server name (#.01 field of file 18.12)
+6 ;
+7 QUIT $$GETSRV^XOBWLIB1()
+8 ;
DISPSRVS ; -- display servers
+1 ; Input:
+2 ; None
+3 ; Output:
+4 ; Screen formatted display of app servers and associated fields from file 18.12
+5 ;
+6 DO DISPSRVS^XOBWLIB1
+7 QUIT
+8 ;