Accessing RESTful JSON and XML Web Service Endpoints

In SAS 9.3, all structured SAS BI Web Services expose a JSON, XML, and SOAP endpoint. This is true whether the Web service represents a single stored process or is a generated Web service. The URL for each of these endpoints depends on the location and type of Web service. For more information about accessing SOAP endpoints, see Accessing SOAP Endpoints for Stored Processes and Generated Web Services.

Accessing RESTful Web Service Endpoints

RESTful plain XML endpoints are available from the server resource /SASBIWS/rest/. When accessing endpoints for stored processes, append the SAS folder path for the stored process to the resource /SASBIWS/rest/storedProcesses/ (for example, /SASBIWS/rest/storedProcesses/stored/process/path). Generated Web services have a unique name and contain either a single or multiple named stored processes. To access the RESTful plain XML endpoint for generated Web services, append the generated Web service name to the resource /SASBIWS/rest/ (for example, /SASBIWS/rest/generatedServiceName). Because generated Web services can contain multiple stored processes, you need to identify which stored process that you want to invoke. You can do this in one of two ways:
  • Use the stored process name as the payload root in your request message (assuming that the message is an HTTP POST). In this case, the input XML is very similar to the SOAP input XML.
  • Append the stored process name (omitting any spaces) to the resource /SASBIWS/rest/generatedServiceName (for example, /SASBIWS/rest/generatedServiceName/storedProcessName).
For both generated and stored process Web services, you can tell SAS BI Web Services that you are interested only in a single specific aspect of the stored process output. You can do this by accessing the Web service at a specific URL. When you do this, the Web service returns only that specific output resource. Output parameters, output streams (also called data targets), and packages are all supported output resources.
To access a specific output parameter, append the resource /parameters/parameterName to the RESTful URL for your Web service, replacing parameterName with the name of the actual parameter. When you access the /parameters/ resource of a RESTful Web service, the HTTP response body contains only the string value of that parameter and no additional XML.
To access a specific output stream, append the resource /streams/streamName to the RESTful URL for your Web service, replacing streamName with the name of the actual stream. When you access the /streams/ resource of a RESTful Web service, the HTTP response is the exact output that your stored process sends to that stream and the HTTP response headers include an appropriate content type if it is available.
A stored process can produce an output package during execution that can contain any number of entries. You can access an individual entry within a package by appending the resource /packages/entryNum to the RESTful URL for your Web service, replacing entryNum with the index of the package entry. Entries in packages are not always named, so you must use the package entry index. The index starts at 0 for the first entry in the package.
You cannot access more than one output resource at a time by appending multiple /parameters/, /streams/, and /packages/ resources. You can use only one at a time. You use this URL resource form whether invoking a service with an HTTP GET (when no input parameters or streams are required) or HTTP POST (when sending input prompt values or stream values). See Invoking RESTful Web Services for examples that use various output parameter resources.

Accessing RESTful JSON Web Service Endpoints

JSON Web service endpoints are available from the server resource /SASBIWS/json/. When accessing endpoints for stored processes, append the SAS folder path for the stored process to the resource /SASBIWS/json/storedProcesses/ (for example, /SASBIWS/json/storedProcesses/stored/process/path). Generated Web services have a unique name and contain either a single or multiple named stored processes. To access the JSON endpoint for a generated Web service, append the generated Web service name and the stored process name to the resource /SASBIWS/json/ (for example, /SASBIWS/json/generatedServiceName/storedProcessName). JSON endpoints do not support output resource specifications, so the response is always JSON data.