Hi All,
How do i create REST webservices? what is the requirement? How do i check if it has been installed in my system.
Thank you
For a non SAS user to call the Web Service
The Proc HTTP code, is a way to call a web service from a SAS program, so this can be used to test your web service, as well as calling non SAS web services.
Bruno
hi
Have a look at this documentation Invoking RESTful Web Services.
If you have the corresponding web application (/SASBIWS), you are good to go.
You create a Stored Process with the necessary parameters.
Then use one of the endpoints to call the web service and pass parameters
Here is a sample code to test a web service from SAS. The STP has four parameters that have the same name as you see in the XML with the code (tableName, columnName, statName, someDate)
*
* for Windows use port = 80
*;
%let hostName = &systcpiphostname;
%let port = 7980;
%let SASBIWS_path = /SASBIWS/rest/storedProcesses;
%let stpName = /yourfolder/yourSTP;
*
* 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 temp;
proc http
method="POST"
URL="http://&hostName:&port.&SASBIWS_path.&stpName"
in=htin
out=htout
ct="application/xml"
verbose
;
run;
*
* display result
*;
data _null_;
infile htout;
input;
putlog _infile_;
run;
filename htin clear;
filename htout clear;
As attachment, there is a SAS package file with the Stored Process, that fits the SAS code above. Take away the .ZIP extension, so that the file can be imported in the SAS Management Console.
Bruno
Hi,
Thank you for the sample. Could you please give me the steps on how to create it. i am writing a stored process with the parameters. Then do i have to use SMC to create the REST? in SMC i can see the option to create Webservices but not REST or JSON.
Thank you
Lakshmi
Just import the STP provided in the SAS Package file I added as an attachment. Then you have a STP that fits the code to test.
With SAS9.4 (maybe SAS9.2) there is no longer a need to create a WebService from a Stored Process, you just need to use the right URL to call the STP as a WebService, as per the documentation I referenced.
Bruno
HI, so, if a non-sas user to run the stp, all i have to do is create a stp using sas EG and write the proc http block and give the URL to the non-sas user?
Thank you
For a non SAS user to call the Web Service
The Proc HTTP code, is a way to call a web service from a SAS program, so this can be used to test your web service, as well as calling non SAS web services.
Bruno
Thank you Bruno
Hi,
Do you know if there is a way through the REST webservices interface in sas 9.4 to query what are the parameters that a stored process takes as input?
Previously in the 9.2 foundation services one is able to query what are the parameter names and types that a specific stored process takes as input. I believe this was done using RMI to the Metadata Server. I can't find anywhere in the documentation where we can query a stored process through the BI services for the parameters it uses.
Thanks
Please create a new discussion for this topic.
Makes it easier for everyone
Bruno
Hi,
Sorry about that. I have created a new discussion here:
Thanks
Bruno,
I created an STP and can access through SAS stored process web application by specifying a long URL when I try to use the url for restful web service of type http://host:port/SASBIWS I get an error that url is incorrect. I tried both 7980 and 8080 as port and even tried without port.
What is the "host" in this url? Which server it refers to?
Thanks
Hello
Using Bruno_SAS code (given on 09-01-2016 ) I created a request and got the response which is a long xml string
<ResultA><Resultset><var1>someval</var1>........<varn>some val</valn></ResultA></Resultset>
Is there a way to convert to SAS data set.
Hi @thesasuser
Yes there is, have a look at the SAS XML libname engine:
http://support.sas.com/documentation/cdl//en/engxml/64990/HTML/default/viewer.htm#titlepage.htm
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.
Find more tutorials on the SAS Users YouTube channel.