BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
L_R
Fluorite | Level 6 L_R
Fluorite | Level 6

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
1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

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

13 REPLIES 13
BrunoMueller
SAS Super FREQ

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

L_R
Fluorite | Level 6 L_R
Fluorite | Level 6

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
BrunoMueller
SAS Super FREQ

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

L_R
Fluorite | Level 6 L_R
Fluorite | Level 6

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
BrunoMueller
SAS Super FREQ

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

L_R
Fluorite | Level 6 L_R
Fluorite | Level 6

Thank you Bruno

Trix
shamdan
Calcite | Level 5

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

 

 

BrunoMueller
SAS Super FREQ

Please create a new discussion for this topic.

 

Makes it easier for everyone

 

Bruno

shamdan
Calcite | Level 5

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

SampatSaraf
Calcite | Level 5

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

L_R
Fluorite | Level 6 L_R
Fluorite | Level 6
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
thesasuser
Pyrite | Level 9

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.

 

 

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

CLI in SAS Viya

Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 13 replies
  • 7790 views
  • 2 likes
  • 6 in conversation