Download Techniques to Invoke Web Services from SAS

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

URL redirection wikipedia , lookup

Transcript
www.OASUS.ca
Techniques to Invoke
Web Services from SAS
Leveraging Web Services within
your SAS Programs
“Come out of the desert of ignorance to the OASUS of knowledge”
www.OASUS.ca
Agenda
• Introduction to Web Services
– SOAP
– WSDL
– Using Services
• Techniques to Invoke Web Services
– What SAS offers
– Benefits and Limitations
– An alternative Approach
• Demonstration
Wednesday, May 24, 2017
Greg Ludwinski, Statistics Canada
2
www.OASUS.ca
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).
Wednesday, May 24, 2017
Greg Ludwinski, Statistics Canada
3
Wednesday, May 24, 2017
QOS
Management
www.OASUS.ca
Security
Web Services Stack
UDDI
Discovery & publication
WSDL
Service description
SOAP
Messaging
HTTP, TCP
Greg Ludwinski, Statistics Canada
Transportation
4
www.OASUS.ca
SOAP
• SOAP is an XML based markup
language for messaging between
applications.
• Web Services expose functionality to
users through SOAP.
• Transport protocol neutral
Wednesday, May 24, 2017
Greg Ludwinski, Statistics Canada
5
www.OASUS.ca
SOAP Message Structure
SOAP Message (an XML document)
SOAP Envelope
WS-Security
WS-Addressing
SOAP Header (optional)
Header
Header
SOAP Body (payload)
XML content
Request/
Response Data
Error handling
SOAP Fault (optional)
Attachment
(optional)
Wednesday, May 24, 2017
Greg Ludwinski, Statistics Canada
Allows for
different encoding
6
WSDL
www.OASUS.ca
(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.
Wednesday, May 24, 2017
Greg Ludwinski, Statistics Canada
7
WSDL Structure
www.OASUS.ca
Service
Port
Port
Where is it and how
to use it.
(eg. ftp://...)
(e.g. http://...)
Binding
Binding
(e.g. SOAP)
(e.g. ebXML)
Interface for service
operations
Port Type
Operations
Input
Output
message
message
Abstract Interface
Wednesday, May 24, 2017
Greg Ludwinski, Statistics Canada
1 or more service
operations
Description of
inputs and outputs
using types and
schemas
8
www.OASUS.ca
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
Wednesday, May 24, 2017
First & last name Company name
9
www.OASUS.ca
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
Wednesday, May 24, 2017
Greg Ludwinski, Statistics Canada
10
www.OASUS.ca
Proc Http
proc http
method=<post|get>
in=<fileref for request parameters(post)>
out=<fileref for response>
url=“<Path to service endpoint>”
.....
;
run;
Wednesday, May 24, 2017
Greg Ludwinski, Statistics Canada
11
www.OASUS.ca
Proc SOAP
proc soap
in=<fileref for request>
out=<fileref for response>
url=“<Path to service endpoint>”
soapaction=“<Path to service operation>”
.....
;
run;
Wednesday, May 24, 2017
Greg Ludwinski, Statistics Canada
12
www.OASUS.ca
Preparing for Proc SOAP
1. Use a tool such as SOAPUI to create a
service request template
2. Invoke the web service to get a sample
response
3. Create an XMLMap to convert the response
4. Determine additional requirements
(Security, Timeout Settings, Timestamp)
Wednesday, May 24, 2017
Greg Ludwinski, Statistics Canada
13
Using
Custom
Java
Objects
www.OASUS.ca
• Why use Java?
– SAS uses Java (Proc SOAP)
– Rich class libraries available (Web Service
Frameworks, Security . .. )
• How?
1. Develop a class and put it in a JAR file
2. Update your SAS Configuration file:
a) Add the JAR file to the Classpath
b) Set any required JREOptions
3. Java objects will be available in your SAS session
Wednesday, May 24, 2017
Greg Ludwinski, Statistics Canada
14
www.OASUS.ca
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
Wednesday, May 24, 2017
First & last name Company name
15
www.OASUS.ca
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;
Wednesday, May 24, 2017
First & last name Company name
16
www.OASUS.ca
Wednesday, May 24, 2017
First & last name Company name
17
www.OASUS.ca
Comments / Questions
Statistics
Canada
Statistique
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
[email protected]
Canada
Wednesday, May 24, 2017
Greg Ludwinski Statistics Canada
18