These examples illustrate how to create a simple stored process and execute it as a RESTful SAS BI Web service.
EXAMPLE 1: JSON Output
In this example, JSON output is sent back to the client application.
Note: You can also execute the stored process web service by submitting the following request using your web browser:
http://hostname:port/SASBIWS/rest/storedProcesses/Examples/web_service_test/dataTargets/_WEBOUT
EXAMPLE 2: HTML Output
In this example, HTML output is sent back to the client application.
3. Execute the stored process web service using PROC HTTP by submitting the following code:
EXAMPLE 3: Data Target Output
In this example, the output is sent back to the client application using an output Data Target that you define.
2. On the Execution tab in the stored process Properties window, select Stream (instead of Package) for Result Capabilities.
3. Select the Properties for the stored process. Then, click the Data tab, and create a new Target.
4. For the Target, specify the following:
Type: Generic Data Target
Label: OUTSTR
Fileref: OUTSTR
Expected content type: application/json
5. Execute the stored process web service using PROC HTTP by submitting the following code:
In the code above, you must provide the values for hostname and port as well as the correct path to the web_service_test3 stored process.
Notice dataTargets/OUTSTR at the end of the URL. The OUTSTR value corresponds to the proc json out=OUTSTR specification in the stored process code and to the OUTSTR that was specified for the FILEREF for the target on the Data tab.
EXAMPLE 4: Parameters to Stored Process and JSON Output
In this example, two parameters are passed to the stored process web service and JSON output is returned to the client.
2. On the Execution tab in the stored process Properties window, select Stream (instead of Package) for Result Capabilities.
3. Select the Properties for the stored process. Then, click the Parameters tab.
4. Create the following parameters for the stored process:
name: num1 prompt type: text
name: num2 prompt type: text
5. Execute the stored process web service using PROC HTTP by submitting the following code:
In the code above, you must provide the values for hostname and port as well as the correct path to the web_service_test stored process.
In this example, the parameters num1 (which has a value of 11) and num2 (which has a value of 22) are passed to the stored process.
More Information
For more information, see the following:
SAS® 9.4 BI Web Services: Developer's Guide
SAS Sample Note 63405, "Creating a SAS® stored process and executing it as a RESTful SAS® BI web service: Part 2"
SAS Sample Note 63438, "Creating a SAS® stored process and executing it as a RESTful SAS® BI web service: Part 3"
SAS Sample Note 63463, "Creating a SAS® stored process and executing it as a RESTful SAS® BI web service: Part 4"