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 9.3 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 Service 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, 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, type 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 will contain one operation for each stored process that you selected.
    3. Upon successful deployment, a message displays 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 will use a Web Service 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.