Architecting, installing and maintaining your SAS environment

REST in webservices in sas 9.4 m3

Accepted Solution Solved
Reply
Contributor L_R
Contributor
Posts: 24
Accepted Solution

REST in webservices in sas 9.4 m3

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

 

Trix

Accepted Solutions
Solution
‎09-13-2016 12:52 PM
SAS Super FREQ
Posts: 683

Re: REST in webservices in sas 9.4 m3

For a non SAS user to call the Web Service

  • you create the Stored Process with the appropriate parameters
  • you give the caller the URL to call the STP as a web service, inclduding a description of the parameters expected and returned

 

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

View solution in original post


All Replies
SAS Super FREQ
Posts: 683

Re: REST in webservices in sas 9.4 m3

[ Edited ]

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

Attachment
Contributor L_R
Contributor
Posts: 24

Re: REST in webservices in sas 9.4 m3

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

Trix
SAS Super FREQ
Posts: 683

Re: REST in webservices in sas 9.4 m3

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

Contributor L_R
Contributor
Posts: 24

Re: REST in webservices in sas 9.4 m3

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

Trix
Solution
‎09-13-2016 12:52 PM
SAS Super FREQ
Posts: 683

Re: REST in webservices in sas 9.4 m3

For a non SAS user to call the Web Service

  • you create the Stored Process with the appropriate parameters
  • you give the caller the URL to call the STP as a web service, inclduding a description of the parameters expected and returned

 

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

Contributor L_R
Contributor
Posts: 24

Re: REST in webservices in sas 9.4 m3

Thank you Bruno

Trix
New Contributor
Posts: 4

Re: REST in webservices in sas 9.4 m3

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

 

 

SAS Super FREQ
Posts: 683

Re: REST in webservices in sas 9.4 m3

Please create a new discussion for this topic.

 

Makes it easier for everyone

 

Bruno

New Contributor
Posts: 4

Re: REST in webservices in sas 9.4 m3

Hi,

 

Sorry about that.  I have created a new discussion here:

 

https://communities.sas.com/t5/SAS-Stored-Processes/Get-stored-process-parameters-through-REST-servi...

 

Thanks

Occasional Learner
Posts: 1

Re: REST in webservices in sas 9.4 m3

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://hostSmiley Tongueort/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

Contributor L_R
Contributor
Posts: 24

Re: REST in webservices in sas 9.4 m3

Hi

If it is a http://hostname:7980(whatever the port number set during installation)/BIWebServices/rest/SASStoredProcesses/path name where you have saved the stored processes.

Thanks
Trix
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 11 replies
  • 1068 views
  • 2 likes
  • 4 in conversation