Techniques to Invoke Web Services from SAS Leveraging Web Services within your SAS Programs
Greg Ludwinski, Statistics Canada Agenda Introduction to Web Services SOAP WSDL Using Services Techniques to Invoke Web Services What SAS offers Benefits and Limitations An alternative Approach Demonstration Thursday, May-30-19 Greg Ludwinski, Statistics Canada
Greg Ludwinski, Statistics Canada What is a Web Service? A software application identified by a URI Defined, described and discovered as xml artifacts (WSDL). Supports direct interactions with other software agents using XML-based messages (SOAP) exchanged via standard network protocols (HTTP). Thursday, May-30-19 Greg Ludwinski, Statistics Canada
Greg Ludwinski, Statistics Canada Web Services Stack UDDI Discovery & publication WSDL Service description Management QOS Security SOAP Messaging HTTP, TCP Transportation Thursday, May-30-19 Greg Ludwinski, Statistics Canada
Greg Ludwinski, Statistics Canada SOAP SOAP is an XML based markup language for messaging between applications. Web Services expose functionality to users through SOAP. Transport protocol neutral Thursday, May-30-19 Greg Ludwinski, Statistics Canada
SOAP Message Structure SOAP Message (an XML document) SOAP Envelope WS-Security WS-Addressing SOAP Header (optional) Header Header Request/ Response Data SOAP Body (payload) Error handling XML content SOAP Fault (optional) Allows for different encoding Attachment (optional) Thursday, May-30-19 Greg Ludwinski, Statistics Canada
WSDL (Web Service Description Language) A contract between the Web service and the client who uses it. An XML document that describes the Web Service and defines the functions that are exposed. It also defines where the service is available and what communication protocol is used to talk to the service. Thursday, May-30-19 Greg Ludwinski, Statistics Canada
WSDL Structure Service Port Port Binding Binding Port Type Operations Where is it and how to use it. Port (e.g. http://...) Port (eg. ftp://...) Binding (e.g. SOAP) Binding (e.g. ebXML) Interface for service operations 1 or more service operations Port Type Operations Description of inputs and outputs using types and schemas Input message Output message Abstract Interface Thursday, May-30-19 Greg Ludwinski, Statistics Canada
First & last name Company name RESTful Web Services A lightweight alternative to SOAP based web services Plain XML and JSON are popular message protocols Standards are not as well defined HTTP header is used for security Thursday, May-30-19 First & last name Company name
Calling Web Services from SAS RESTful Web Services Proc Http URL file reference SOAP based Web Services Proc SOAP Functions SOAPWEB, SOAPWS, . . . . The WSDL markup type dropped in 9.3 Custom Java Objects Thursday, May-30-19 Greg Ludwinski, Statistics Canada
Greg Ludwinski, Statistics Canada Proc Http proc http method=<post|get> in=<fileref for request parameters(post)> out=<fileref for response> url=“<Path to service endpoint>” ..... ; run; Thursday, May-30-19 Greg Ludwinski, Statistics Canada
Greg Ludwinski, Statistics Canada Proc SOAP proc soap in=<fileref for request> out=<fileref for response> url=“<Path to service endpoint>” soapaction=“<Path to service operation>” ..... ; run; Thursday, May-30-19 Greg Ludwinski, Statistics Canada
Preparing for Proc SOAP Use a tool such as SOAPUI to create a service request template Invoke the web service to get a sample response Create an XMLMap to convert the response Determine additional requirements (Security, Timeout Settings, Timestamp) Thursday, May-30-19 Greg Ludwinski, Statistics Canada
Using Custom Java Objects Why use Java? SAS uses Java (Proc SOAP) Rich class libraries available (Web Service Frameworks, Security . .. ) How? Develop a class and put it in a JAR file Update your SAS Configuration file: Add the JAR file to the Classpath Set any required JREOptions Java objects will be available in your SAS session Thursday, May-30-19 Greg Ludwinski, Statistics Canada
First & last name Company name Java objects in SAS Created within a data step SAS provides methods to; Call static & non-static methods (9 types) Get/Set static & non-static fields (9 types) Detect & Clear exceptions Flush output Delete objects Thursday, May-30-19 First & last name Company name
First & last name Company name Using Java Objects Data _null_; /* Declared and instantiate */ declare javaobj myJavaObject; myJavaObject = _new_ javaobj("<classname>"); /* Call static/non static methods */ myJavaObject.callVoidMethod("<methodname>", <parm1>); myJavaObject.callStringMethod("<methodname>", <parm1>, <outstringVar>); /* Object clean up */ myJavaObject.delete(); run; Thursday, May-30-19 First & last name Company name
First & last name Company name Demonstration Thursday, May-30-19 First & last name Company name
Greg Ludwinski Statistics Canada Comments / Questions Statistics Statistique Canada Canada Greg Ludwinski Project Leader - SAS Technology Centre System Engineering Division R.H. Coats Building, 14th Floor, Section Q Ottawa, Ontario, Canada K1A 0T6 (613) 951-2768 Fax (613) 951-0607 Gregory.Ludwinski@statcan.gc.ca Canada Thursday, May-30-19 Greg Ludwinski Statistics Canada