mirror of
https://github.com/sasjs/core.git
synced 2026-01-03 23:50:06 +00:00
Merge pull request #324 from sasjs/servertestfixes
fix: updating ms_runstp and ms_testservice macros to cater for latest…
This commit is contained in:
62
all.sas
62
all.sas
@@ -22106,8 +22106,9 @@ options &optval;
|
|||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getuniquefileref.sas
|
@li mf_getuniquefileref.sas
|
||||||
@li mf_getuniquelibref.sas
|
@li mf_getuniquename.sas
|
||||||
@li mp_abort.sas
|
@li mp_abort.sas
|
||||||
|
@li mp_chop.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@@ -22220,7 +22221,10 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
filename &outref temp lrecl=32767;
|
%local resp_path;
|
||||||
|
%let resp_path=%sysfunc(pathname(work))/%mf_getuniquename();
|
||||||
|
filename &outref "&resp_path" lrecl=32767;
|
||||||
|
|
||||||
/* prepare request*/
|
/* prepare request*/
|
||||||
proc http method='POST' headerin=&authref in=&mainref out=&outref
|
proc http method='POST' headerin=&authref in=&mainref out=&outref
|
||||||
url="&_sasjs_apiserverurl.&_sasjs_apipath?_program=&pgm%str(&)_debug=131";
|
url="&_sasjs_apiserverurl.&_sasjs_apipath?_program=&pgm%str(&)_debug=131";
|
||||||
@@ -22228,6 +22232,7 @@ proc http method='POST' headerin=&authref in=&mainref out=&outref
|
|||||||
debug level=2;
|
debug level=2;
|
||||||
%end;
|
%end;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%if (&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201)
|
%if (&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201)
|
||||||
or &mdebug=1
|
or &mdebug=1
|
||||||
%then %do;
|
%then %do;
|
||||||
@@ -22243,11 +22248,22 @@ or &mdebug=1
|
|||||||
options &optval;
|
options &optval;
|
||||||
|
|
||||||
%if &outlogds ne _null_ or &mdebug=1 %then %do;
|
%if &outlogds ne _null_ or &mdebug=1 %then %do;
|
||||||
%local dumplib;
|
%local matchstr chopout;
|
||||||
%let dumplib=%mf_getuniquelibref();
|
%let matchstr=SASJS_LOGS_SEPARATOR_163ee17b6ff24f028928972d80a26784;
|
||||||
libname &dumplib json fileref=&outref;
|
%let chopout=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop);
|
||||||
|
|
||||||
|
%mp_chop("&resp_path"
|
||||||
|
,matchvar=matchstr
|
||||||
|
,keep=LAST
|
||||||
|
,matchpoint=END
|
||||||
|
,outfile="&chopout"
|
||||||
|
,mdebug=&mdebug
|
||||||
|
)
|
||||||
|
|
||||||
data &outlogds;
|
data &outlogds;
|
||||||
set &dumplib..log;
|
infile "&chopout" lrecl=2000;
|
||||||
|
length line $2000;
|
||||||
|
line=_infile_;
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
putlog line=;
|
putlog line=;
|
||||||
%end;
|
%end;
|
||||||
@@ -22374,50 +22390,38 @@ run;
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
/* SASjs services have the _webout embedded in wrapper JSON */
|
/* chop out JSON section */
|
||||||
/* Files can also be very large - so use a dedicated macro to chop it out */
|
%local matchstr chopout;
|
||||||
%local matchstr1 matchstr2 ;
|
%let matchstr=SASJS_LOGS_SEPARATOR_163ee17b6ff24f028928972d80a26784;
|
||||||
%let matchstr1={"status":"success","_webout":{;
|
%let chopout=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop);
|
||||||
%let matchstr2=},"log":[{;
|
|
||||||
%let chopout1=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop1);
|
|
||||||
%let chopout2=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop2);
|
|
||||||
|
|
||||||
%mp_chop("%sysfunc(pathname(&fref1,F))"
|
%mp_chop("%sysfunc(pathname(&fref1,F))"
|
||||||
,matchvar=matchstr1
|
,matchvar=matchstr
|
||||||
,keep=LAST
|
|
||||||
,matchpoint=END
|
|
||||||
,offset=-1
|
|
||||||
,outfile="&chopout1"
|
|
||||||
,mdebug=&mdebug
|
|
||||||
)
|
|
||||||
|
|
||||||
%mp_chop("&chopout1"
|
|
||||||
,matchvar=matchstr2
|
|
||||||
,keep=FIRST
|
,keep=FIRST
|
||||||
,matchpoint=START
|
,matchpoint=START
|
||||||
,offset=1
|
,offset=-1
|
||||||
,outfile="&chopout2"
|
,outfile="&chopout"
|
||||||
,mdebug=&mdebug
|
,mdebug=&mdebug
|
||||||
)
|
)
|
||||||
|
|
||||||
%if &outlib ne 0 %then %do;
|
%if &outlib ne 0 %then %do;
|
||||||
libname &outlib json "&chopout2";
|
libname &outlib json "&chopout";
|
||||||
%end;
|
%end;
|
||||||
%if &outref ne 0 %then %do;
|
%if &outref ne 0 %then %do;
|
||||||
filename &outref "&chopout2";
|
filename &outref "&chopout";
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%if &mdebug=0 %then %do;
|
%if &mdebug=0 %then %do;
|
||||||
filename &webref clear;
|
filename &webref clear;
|
||||||
filename &fref1 clear;
|
filename &fref1 clear;
|
||||||
filename &fref2 clear;
|
|
||||||
%end;
|
%end;
|
||||||
%else %do;
|
%else %do;
|
||||||
%put &sysmacroname exit vars:;
|
%put &sysmacroname exit vars:;
|
||||||
%put _local_;
|
%put _local_;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%mend ms_testservice;/**
|
%mend ms_testservice;
|
||||||
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Send data to/from sasjs/server
|
@brief Send data to/from sasjs/server
|
||||||
@details This macro should be added to the start of each web service,
|
@details This macro should be added to the start of each web service,
|
||||||
|
|||||||
@@ -39,8 +39,9 @@
|
|||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getuniquefileref.sas
|
@li mf_getuniquefileref.sas
|
||||||
@li mf_getuniquelibref.sas
|
@li mf_getuniquename.sas
|
||||||
@li mp_abort.sas
|
@li mp_abort.sas
|
||||||
|
@li mp_chop.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@@ -153,7 +154,10 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
filename &outref temp lrecl=32767;
|
%local resp_path;
|
||||||
|
%let resp_path=%sysfunc(pathname(work))/%mf_getuniquename();
|
||||||
|
filename &outref "&resp_path" lrecl=32767;
|
||||||
|
|
||||||
/* prepare request*/
|
/* prepare request*/
|
||||||
proc http method='POST' headerin=&authref in=&mainref out=&outref
|
proc http method='POST' headerin=&authref in=&mainref out=&outref
|
||||||
url="&_sasjs_apiserverurl.&_sasjs_apipath?_program=&pgm%str(&)_debug=131";
|
url="&_sasjs_apiserverurl.&_sasjs_apipath?_program=&pgm%str(&)_debug=131";
|
||||||
@@ -161,6 +165,7 @@ proc http method='POST' headerin=&authref in=&mainref out=&outref
|
|||||||
debug level=2;
|
debug level=2;
|
||||||
%end;
|
%end;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
%if (&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201)
|
%if (&SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201)
|
||||||
or &mdebug=1
|
or &mdebug=1
|
||||||
%then %do;
|
%then %do;
|
||||||
@@ -176,11 +181,22 @@ or &mdebug=1
|
|||||||
options &optval;
|
options &optval;
|
||||||
|
|
||||||
%if &outlogds ne _null_ or &mdebug=1 %then %do;
|
%if &outlogds ne _null_ or &mdebug=1 %then %do;
|
||||||
%local dumplib;
|
%local matchstr chopout;
|
||||||
%let dumplib=%mf_getuniquelibref();
|
%let matchstr=SASJS_LOGS_SEPARATOR_163ee17b6ff24f028928972d80a26784;
|
||||||
libname &dumplib json fileref=&outref;
|
%let chopout=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop);
|
||||||
|
|
||||||
|
%mp_chop("&resp_path"
|
||||||
|
,matchvar=matchstr
|
||||||
|
,keep=LAST
|
||||||
|
,matchpoint=END
|
||||||
|
,outfile="&chopout"
|
||||||
|
,mdebug=&mdebug
|
||||||
|
)
|
||||||
|
|
||||||
data &outlogds;
|
data &outlogds;
|
||||||
set &dumplib..log;
|
infile "&chopout" lrecl=2000;
|
||||||
|
length line $2000;
|
||||||
|
line=_infile_;
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
putlog line=;
|
putlog line=;
|
||||||
%end;
|
%end;
|
||||||
|
|||||||
@@ -108,47 +108,34 @@ run;
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
/* SASjs services have the _webout embedded in wrapper JSON */
|
/* chop out JSON section */
|
||||||
/* Files can also be very large - so use a dedicated macro to chop it out */
|
%local matchstr chopout;
|
||||||
%local matchstr1 matchstr2 ;
|
%let matchstr=SASJS_LOGS_SEPARATOR_163ee17b6ff24f028928972d80a26784;
|
||||||
%let matchstr1={"status":"success","_webout":{;
|
%let chopout=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop);
|
||||||
%let matchstr2=},"log":[{;
|
|
||||||
%let chopout1=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop1);
|
|
||||||
%let chopout2=%sysfunc(pathname(work))/%mf_getuniquename(prefix=chop2);
|
|
||||||
|
|
||||||
%mp_chop("%sysfunc(pathname(&fref1,F))"
|
%mp_chop("%sysfunc(pathname(&fref1,F))"
|
||||||
,matchvar=matchstr1
|
,matchvar=matchstr
|
||||||
,keep=LAST
|
|
||||||
,matchpoint=END
|
|
||||||
,offset=-1
|
|
||||||
,outfile="&chopout1"
|
|
||||||
,mdebug=&mdebug
|
|
||||||
)
|
|
||||||
|
|
||||||
%mp_chop("&chopout1"
|
|
||||||
,matchvar=matchstr2
|
|
||||||
,keep=FIRST
|
,keep=FIRST
|
||||||
,matchpoint=START
|
,matchpoint=START
|
||||||
,offset=1
|
,offset=-1
|
||||||
,outfile="&chopout2"
|
,outfile="&chopout"
|
||||||
,mdebug=&mdebug
|
,mdebug=&mdebug
|
||||||
)
|
)
|
||||||
|
|
||||||
%if &outlib ne 0 %then %do;
|
%if &outlib ne 0 %then %do;
|
||||||
libname &outlib json "&chopout2";
|
libname &outlib json "&chopout";
|
||||||
%end;
|
%end;
|
||||||
%if &outref ne 0 %then %do;
|
%if &outref ne 0 %then %do;
|
||||||
filename &outref "&chopout2";
|
filename &outref "&chopout";
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%if &mdebug=0 %then %do;
|
%if &mdebug=0 %then %do;
|
||||||
filename &webref clear;
|
filename &webref clear;
|
||||||
filename &fref1 clear;
|
filename &fref1 clear;
|
||||||
filename &fref2 clear;
|
|
||||||
%end;
|
%end;
|
||||||
%else %do;
|
%else %do;
|
||||||
%put &sysmacroname exit vars:;
|
%put &sysmacroname exit vars:;
|
||||||
%put _local_;
|
%put _local_;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%mend ms_testservice;
|
%mend ms_testservice;
|
||||||
|
|||||||
Reference in New Issue
Block a user