Writing SAS BI Web Services Using XMLA |
Sample Overview |
This sample shows how to write, define, and invoke a sample stored process that can be used with SAS BI Web Services. This example is for an XMLA Web service. You can access other sample Web services in the samples database at support.sas.com.
Write the Stored Process |
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;
Define the Metadata |
The stored process must be defined on a SAS Metadata Server that is used by SAS BI Web Services in order to determine how and where to run the stored process. Stored process metadata is defined by using SAS Management Console. The tables in this section show the values for each field in the New Stored Process Wizard in SAS Management Console.
Note: If you have previously installed the SAS Stored Process sample metadata as part of the SAS Deployment Wizard or the Web Infrastructure Platform installation, then 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 /Products/SAS Intelligence Platform/Samples folder. If you do not have the sample metadata, you can define the metadata for the stored process on your SAS Metadata Server by performing the following steps.
Open SAS Management Console and connect to the appropriate metadata server.
From the SAS Management Console navigation tree, select the folder under which you would like to create the new stored process. (If you would like to create a new folder, you can select the location in the navigation tree in which you want to add the new folder, and then select Actions New Folder from the menu bar to open the New Folder Wizard. Follow the wizard instructions to create the new folder.)
After you select the folder in which you want to add a new stored process, select Actions New Stored Process from the menu bar. The New Stored Process Wizard displays.
On the first page of the New Stored Process Wizard, enter the following values in their corresponding fields for the sample Web service:
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. Adding a description and roles for the stored process are optional.
Click Next.
Enter the following values in their corresponding fields for the sample Web service:
Field | Value |
---|---|
SAS server | SASApp - Logical Stored Process Server |
Source code repository | C:\Program Files\SAS\SASFoundation\9.2\inttech\sample |
Source code file | stpwsmea.sas |
Results | Stream |
Click Next.
Click New Prompt to add an input parameter to the stored process.
On the General tab, enter the following values in their corresponding fields for the sample Web service:
Field | Value |
---|---|
Name | tablename |
Displayed text | tablename |
Select the Requires a non-blank value check box. Entering a description is optional.
On the Prompt Type and Values tab, enter the following values in their corresponding fields for the sample Web service:
Field | Value |
---|---|
Prompt type | Text |
Method for populating prompt | User-entered value |
Number of values | Single value |
Text type | Single line |
Default value | InData |
Click Next.
Click New to open the New Data Source dialog box, where you must define the data source.
Enter the following values in their corresponding fields for the sample Web service:
Field | Value |
---|---|
Type | XML Stream |
Label | instream |
Fileref | instream |
Expected content type | text/xml |
You must also select the Allow rewinding stream check box in the New Data Source dialog box. Otherwise, an XMLMap would need to be specified on the XML LIBNAME statement to define the XML schema for instream .
Click OK to save the data source definition.
Review your stored process information, and click Finish to define the metadata for the stored process.
Invoke the Stored Process |
The stored process that 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>
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.