Making SOAP calls from SAS! Integrating with web services

This post was kindly contributed by AFHood Analytics Group - Blogs » SAS - go there to comment and to read the full post.

One of the issues with SAS for many IT departments is the lack of integration with service oriented architecture (SOA). The good news is with many new features coming online with versions 9.X+ are service oriented.

Lets look quickly at the Proc SOAP procedure now available.

For those SAS programmers out there that aren’t familiar with SOAP or services, get your basis here: SOAPUser-Basics

In a nutshell, SOAP is transporting XML data via a HTTP Post. In order to make a successful SOAP call from SAS you need a couple of things.

1. a request XML file

2. a repsonse XML file

3. a webservice URL and WSDL (Web Service Definition Language) -Think webservice users manual

Here is a simple example of a SOAP call we use on a daily job.

filename rqst_xml ‘some file system reference’;

* Create the XML;

data _null_;

set input_dataset;

file rqst_xml;

if first.records=1 then do;

put ‘<?xml version=”1.0″?>
<soap:Envelope
xmlns:soap=”http://www.w3.org/2001/12/soap-envelope”
soap:encodingStyle=”http://www.w3.org/2001/12/soap-encoding”>

<soap:Header>
<requestingSystem>SAS</requestingSystem>

<requestingFunction>DemoSasScript</requestingFunction>
</soap:Header>

<soap:Body>
<requestedData>’;

end;

datasetData;

if last.records=1 then do;

put ‘<requestedData>
</soap:Body>

</soap:Envelope>’;

end;

run;

filename rspns_xml ‘some file system reference’;

%let URL=http://webservice_url/service;

proc soap in=rqst_xml

out=rspns_xml

url=&url;

run;

 

Upon executing the call, you can read in the rspns_xml data with the SAS XML engine.

This is meant to be a simple example with very limited scope. Service architecture can quickly get complicated with error and condition handling. Please let us know if you need help with your SAS architecture or coding.

Delicious Digg Email Evernote Facebook LinkedIn StumbleUpon Share

This post was kindly contributed by AFHood Analytics Group - Blogs » SAS - go there to comment and to read the full post.