Creating SAS BI Web Services

Prerequisites

Before you can use web services, you need to perform the following steps:
  1. Install SAS Integration Technologies, which includes SAS BI Web Services and the SAS Metadata Server.
    Note: When you install SAS BI Web Services, you are actually installing several web services: the XMLA web service, the WebServiceMaker web service that is used to create generated web services, and a web service that is responsible for handling non-generated, JSON, and REST invocations.
  2. Write a SAS program to use as a stored process with web services. See Writing SAS Programs for XMLA Web Services. See Writing SAS Programs for Structured Web Services.
  3. Define a stored process server or workspace server, if one is not already defined.
  4. Define a stored process by using SAS Management Console.

Creating XMLA Web Services

If you want to invoke a stored process using the XMLA web service, you must use XMLA web Service as a keyword and Stream as the stored process output type when defining the stored process. On the client side, perform the following steps to use XMLA web services:
  1. Locate the Web Services Description Language (WSDL) file. You can access the WSDL for a SAS BI Web Service by appending '?WSDL' onto the service endpoint.
  2. Write the code for the client application that uses either the Discover method or the Execute method to call the web service.
  3. Run the code.
For XMLA web services, the SAS code that implements the web service, the metadata, and the client code that calls the web service must all be synchronized. The following table shows how to synchronize these items:
Items to Synchronize
Item
SAS Program
Metadata
Client Code
Name
The name of the file that contains the SAS code.
Associates a SAS Stored Process with the name of the file containing the SAS program. Alternatively, starting in SAS 9.3, the SAS program can be included directly in metadata.
<StoredProcess
name=
'MyStoredProcess'>
Input Data
Reads XML from the fileref.
libname instream
xml;
The name of the fileref, which must match the name of the data source. In this case, the name of the fileref is instream.
<Stream
name='instream'
XML input stream 
   provided by client...
</Stream>
Input Parameters
Macros.
&tablename
The parameter name is specified in the metadata. Parameters are validated for proper typing, but they are treated as strings on the server regardless of the type that is specified in the metadata.
<Parameter
name='tablename'>
value</Parameter>
Output Data
Writes output to the _WEBOUT fileref as XML.
libname _WEBOUT
xml xmlmeta=
&_XMLSCHEMA;
Designates the output as 'Streaming'.
Uses the XML that is returned.

Creating Generated Web Services

Follow these steps to use generated web services:
  1. Generate a new web service:
    1. In SAS Management Console, select a set of stored processes and then select Actionsthen selectDeploy As Web Service to generate a new web service that can be used to call the selected stored processes.
    2. In the Web Service Maker URL field of the Deploy as Web Service wizard, enter the endpoint URL or select an existing URL. The user who performs this action should belong to the SAS BI Web Services Users metadata group so that the new web service can be stored in metadata. The new web service contains one operation for each stored process that you selected.
    3. Upon successful deployment, a message is displayed that tells you the endpoint URL for the newly deployed web service.
      Tip
      You can use your operating system's keyboard shortcut to copy the URL (for example, on Windows, press control + C).
  2. Create clients to call the web service. Many web service programming frameworks have utilities to generate client code that can invoke your SAS web services. Typically, these frameworks use a Web Services Description Language (WSDL) file to generate these client files. You can access the WSDL of a SAS web service by appending ?WSDL or .wsdl to the URL of your SAS web service.
A web service can be created with multiple operations in it. Each operation corresponds to a stored process, and has the same name as the stored process, unless there is a naming conflict. If the name of the stored process conflicts with another name, then a new operation name is created.

Accessing the Web Service Endpoint for a Stored Process

Any SAS Stored Process that exists in your SAS Metadata Server can be invoked using SAS BI Web Services. This is a convenient alternative to generating web services when you need to invoke a single stored process. The endpoint URLs for stored processes are not stored anywhere. You can compute the endpoint URL easily by using the type of transport desired and the path of the stored process. See Accessing SOAP Endpoints for Stored Processes and Generated Web Services for more information about accessing SOAP endpoints for stored processes. See Accessing RESTful JSON and XML Web Service Endpoints for more information about accessing REST endpoints for stored processes.