Hello,
I'm starting to figure out how to leverage stored processes exposed as web services. I'm starting to test Stored Processes with a PROC HTTP.
The code for the SP is this
%global wsRC wsValue wsMsg returnString; %let wsMsg = someDate=&someDate; %macro runCode; proc sql noprint;
select &statName( &columnName ) into :wsValue trimmed from &tableName ; quit; %if &sqlrc = 0 %then %do; %let wsrc=&sqlrc; %end; %else %do; %let wsrc=&sqlrc; %let wsMsg = ERROR: &syserrortext; %let wsValue = .; %let syscc = 0; %end; %mend; %runCode
The PROC HTTP that uses this Stored Process is this
%let hostName = 192.168.1.61; %let port = 7980; %let SASBIWS_path = /SASBIWS/rest/storedProcesses; %let stpName = /SAS Validation/SAS Stored Procedures/stp_02_ws; * * build parm list for REST XML request *; filename htin temp; data _null_; infile cards; input; file htin; put _infile_; cards4; <any> <parameters> <tableName>sashelp.cars</tableName> <columnName>invoice</columnName> <statName>MEAN</statName> <someDate>2016-01-17</someDate> </parameters> </any> ;;;; * * call STP as REST WS *; filename htout "/home/lasradm/Test/rest_test"; proc http method="POST" URL="http://&hostName:&port.&SASBIWS_path.&stpName" in=htin out=htout ct="application/xml" WEBUSERNAME="lasradm" WEBPASSWORD="sas" verbose ; run; * * display result *; data _null_; infile htout; input; putlog _infile_; run; filename htin clear; filename htout clear;
This works fine, on the log I can see the result embedded in XML code.
Now I tryed to write a similar program passing different parameters to the SP. Didn't work. I restrict the problem on the library. As long as I use SASHELP it works. If I use a library defined by me (with all the permissions) it gives this generic error
HTTP Status 500 - Request processing failed; nested exception is com. sas.web.services.WSException: SAS completed with nonzero SYSCC '1,012'. SYSMSG: ''
Can't figure out where the problem lies.
I'm using SAS 9.4
edit: I found this code on this topic https://communities.sas.com/t5/Administration-and-Deployment/REST-in-webservices-in-sas-9-4-m3/td-p/...
Hi
The error handling within the STP should return the proper error message. However it looks like you can not reset the SYSCC macro var.
Have a look here http://support.sas.com/kb/56/197.html and check whether the necessary hotfix is applied.
Bruno
SASHELP is the same for all users under all circumstances. Another library may be defined in metadata, but if the user running the STP server has no access to the directory or if there is a metadata permission problem, that library will not work.
For which user did you set permissions on the physical directory? The OS user running the STP server (usually sassrv) needs the permissions, not the user with which you call the STP. That one needs mostly metadata permissions.
Hi
The error handling within the STP should return the proper error message. However it looks like you can not reset the SYSCC macro var.
Have a look here http://support.sas.com/kb/56/197.html and check whether the necessary hotfix is applied.
Bruno
Thanks, installing the hotfix resolved the problem.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.