| Importing XML Documents |
This example illustrates how to use the XML engine to import the Web service results that are described by a WSDL file. Specifying the WSDL markup type enables the XML engine to invoke a Web service and import the Web service results.
The following SAS program accesses the WSDL file to list the Web service descriptions, creates the necessary SAS data sets to contain the input and output parameters, and then imports the Web service results. The Web service that is invoked in this example adds the values for X and Y.
filename wsdl url "http://t2824/AddService.asmx?WSDL"; 1 libname wsdl xml92 xmltype=wsdl; 2 proc datasets library=wsdl details; 3 run; proc contents data=wsdl.Add varnum; 4 run; proc contents data=wsdl.AddResponse varnum; run; data add; 5 x=1; y=1; run; data resp; 6 set wsdl.AddResponse (parms=add); run; proc contents data=resp varnum; 7 run; proc print data=resp; 8 run;
The FILENAME statement assigns the fileref WSDL to the WSDL file.
The LIBNAME statement uses the fileref to reference the WSDL file, specifies the XML engine using the XML92 engine nickname, and specifies the WSDL markup type.
The DATASETS procedure lists, as SAS data sets, the Web service descriptions that are described in the WSDL file. The results in PROC DATASETS Output show that the Web service has input parameters and return results. The XML engine translates these as two SAS data sets: WSDL.Add for the input parameters and WSDL.AddResponse for the return results.
The DETAILS option includes information in the log about the number of observations, variables, indexes, and data set labels. The input parameters data set WSDL.Add contains two variables, and the return results data set WSDL.AddResponse contains one variable.
The two CONTENTS procedures describe the contents of the Web service input parameters and return results. The VARNUM option prints a list of the variables by their position in the data set. The input parameters data set is shown in PROC CONTENTS Output for WSDL.Add, and the return results data set is shown in PROC CONTENTS Output for WSDL.AddResponse.
The first DATA step creates a temporary SAS data set named WORK.ADD that contains the input parameters to the Web service. The data set must be created as described in the PROC CONTENTS output for WSDL.Add, which means that WORK.ADD contains the variables X and Y. The value for X and the value for Y, which is 1 for each variable, will be submitted to the Web service.
The second DATA step creates a temporary SAS data set named WORK.RESP that contains the return results from the Web service.
The SET statement causes the XML engine to read the input parameters that are contained in the SAS data set that is specified on the PARMS= data set option, which is WORK.ADD, and matches the content of WSDL.Add. In addition, the XML engine invokes the Web service.
The XML engine retrieves the response from the Web service and imports the return results into the WORK.RESP data set.
PROC CONTENTS describes the contents of WORK.RESP, which contains one variable named AddResult.
PROC PRINT prints the observations in WORK.RESP, which contains the return result of 2.
Directory
Libref WSDL
Engine XML92
Physical Name C:\AddService.wsdl
XMLType Web Services Description Language
Version .
Member Obs, Entries
# Name Type or Indexes Vars Label
1 Add DATA 0 2 WebService Add - Input parameters
2 AddResponse DATA 0 1 WebService Add - Return results
PROC CONTENTS Output for WSDL.Add
The SAS System 1
The CONTENTS Procedure
Data Set Name WSDL.Add Observations 0
Member Type DATA Variables 2
Engine XML Indexes 0
Created Friday, January 01, 1960 12:00:00 AM Observation Length 0
Last Modified Friday, January 01, 1960 12:00:00 AM Deleted Observations 0
Protection Compressed NO
Data Set Type DATA Sorted NO
Label WebService Add - Input parameters
Data Representation Default
Encoding Default
Engine/Host Dependent Information
Table Name Add
Table Path .
Variables in Creation Order
# Variable Type Len Label
1 x Num 8 datatype=integer
2 y Num 8 datatype=integer
PROC CONTENTS Output for WSDL.AddResponse
The SAS System 2
The CONTENTS Procedure
Data Set Name WSDL.AddResponse Observations 0
Member Type DATA Variables 1
Engine XML Indexes 0
Created Friday, January 01, 1960 12:00:00 AM Observation Length 0
Last Modified Friday, January 01, 1960 12:00:00 AM Deleted Observations 0
Protection Compressed NO
Data Set Type DATA Sorted NO
Label WebService Add - Return results
Data Representation Default
Encoding Default
Engine/Host Dependent Information
Table Name AddResponse
Table Path .
Variables in Creation Order
# Variable Type Len Label
1 AddResult Num 8 datatype=integer
PROC CONTENTS Output for WORK.RESP
The SAS System 3
The CONTENTS Procedure
Data Set Name WORK.RESP Observations 1
Member Type DATA Variables 1
Engine V9 Indexes 0
Created Tuesday, March 11, 2008 01:56:15 PM Observation Length 8
Last Modified Tuesday, March 11, 2008 01:56:15 PM Deleted Observations 0
Protection Compressed NO
Data Set Type Sorted NO
Label
Data Representation WINDOWS_32
Encoding wlatin1 Western (Windows)
Engine/Host Dependent Information
Data Set Page Size 4096
Number of Data Set Pages 1
First Data Page 1
Max Obs per Page 501
Obs in First Data Page 1
Number of Data Set Repairs 0
Filename C:\DOCUME~1\xxxxxx\LOCALS~1\Temp\SAS
Temporary Files\_TD316\resp.sas7bdat
Release Created 9.0202B0
Host Created XP_PRO
Variables in Creation Order
# Variable Type Len Label
1 AddResult Num 8 datatype=integer
PROC PRINT Output for WORK.RESP
The SAS System 4
Add
Obs Result
1 2
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.