The following sample shows how to write, define, and invoke a sample stored process that can be used with SAS BI Web Services.
The following SAS code is a sample stored process called stpwsmea.sas
. This program is installed with SAS Integration Technologies; by default it is located in C:\Program Files\SAS\SAS 9.1\inttech\sample
.
%put &tablename; libname _WEBOUT xml xmlmeta = &_XMLSCHEMA; libname instream xml; proc means data=instream.&tablename; output out=_WEBOUT.mean; run; libname _WEBOUT clear; libname instream clear;
The stored process must be defined in a SAS Metadata Repository that is used by SAS BI Web Services to determine how and where to run the stored process. Stored process metadata is defined using BI Manager. The tables in this section show the values for each field in BI Manager.
Note: If you have previously installed the SAS Stored Process sample metadata as part of the SAS Configuration Wizard or the Web Infrastructure Kit installation, you might not need to re-create the metadata for the "Sample: MEANS Procedure Web Service" sample stored process. The sample metadata should already be available from the Samples\Stored Processes
folder in BI Manager. If you do not have the sample metadata, you can define the metadata for the stored process on your SAS Metadata Server using the following steps.
Field | Value |
---|---|
Name | Sample: MEANS Procedure Web Service |
Keywords | XMLA Web Service |
Note: To add the keyword, click Add to open the Add Keyword dialog box, then enter the name of the keyword. Click OK to return to the Name window.
Using the Name window to add a description for the stored process is optional.
Field | Value |
---|---|
SAS server | Main - Logical Stored Process Server |
Source code repository | C:\Program Files\SAS\SAS 9.1\inttech\sample |
Source code file | stpwsmea.sas |
Output | Streaming |
instream
. Click OK to save the input stream definition.
Note: You must also select the Supports multi-pass reads check box in the Add Input Stream dialog box. Otherwise, an XMLMap would need to be specified on the XML LIBNAME statement to define the XML schema for instream
.
Field | Value |
---|---|
Label | tablename |
SAS variable name | tablename |
Boolean properties | Modifiable, Visible, and Required (are selected) |
Type | String |
Default value | InData |
The stored process we just created can be invoked by SAS BI Web Services for Java and .NET middle-tier clients. A Web service client invokes the middle-tier Web service with an Execute() command. The SOAP request body, or client code, follows:
<soap-env:Body> <Execute> <Command> <StoredProcess name="/Samples/Stored Processes/Sample: MEANS Procedure Web Service"> <Parameter name="tablename">InData</Parameter> <Stream name="instream"> <Table> <InData> <Column1>1</Column1> <Column2>20</Column2> <Column3>99</Column3> </InData> <InData> <Column1>50</Column1> <Column2>200</Column2> <Column3>9999</Column3> </InData> <InData> <Column1>100</Column1> <Column2>2000</Column2> <Column3>1000000</Column3> </InData> </Table> </Stream> </StoredProcess> </Command> <Properties> <PropertyList> <DataSourceInfo>Provider=SASSPS;</DataSourceInfo> </PropertyList> </Properties> </Execute> </soap-env:Body>
After you run the client code, the resulting SOAP response body is as follows:
<soap-env:Body> <ExecuteResponse> <return> <root> <TABLE> <MEAN> <_TYPE_> 0 </_TYPE_> <_FREQ_> 3 </_FREQ_> <_STAT_> N </_STAT_> <COLUMN3> 3 </COLUMN3> <COLUMN2> 3 </COLUMN2> <COLUMN1> 3 </COLUMN1> </MEAN> <MEAN> <_TYPE_> 0 </_TYPE_> <_FREQ_> 3 </_FREQ_> <_STAT_> MIN </_STAT_> <COLUMN3> 99 </COLUMN3> <COLUMN2> 20 </COLUMN2> <COLUMN1> 1 </COLUMN1> </MEAN> <MEAN> <_TYPE_> 0 </_TYPE_> <_FREQ_> 3 </_FREQ_> <_STAT_> MAX </_STAT_> <COLUMN3> 1000000 </COLUMN3> <COLUMN2> 2000 </COLUMN2> <COLUMN1> 100 </COLUMN1> </MEAN> <MEAN> <_TYPE_> 0 </_TYPE_> <_FREQ_> 3 </_FREQ_> <_STAT_> MEAN </_STAT_> <COLUMN3> 336699.333 </COLUMN3> <COLUMN2> 740 </COLUMN2> <COLUMN1> 50.3333333 </COLUMN1> </MEAN> <MEAN> <_TYPE_> 0 </_TYPE_> <_FREQ_> 3 </_FREQ_> <_STAT_> STD </_STAT_> <COLUMN3> 574456.555 </COLUMN3> <COLUMN2> 1094.89726 </COLUMN2> <COLUMN1> 49.5008417 </COLUMN1> </MEAN> </TABLE> </root> </return> </ExecuteResponse> </soap-env>