slides2b - Personal Web Pages

Download Report

Transcript slides2b - Personal Web Pages

Grid Computing Software
Infrastructure
Background information
• History, remote procedure calls
• Service-Oriented Architecture
• Web services
• Implementation
ITCS 4146/5146, UNC-Charlotte, B. Wilkinson, 2007 Feb 2, 2007
2b.1
Distributed computing
Adopted for grid
infrastructure
components
Software Techniques:
Object oriented approaches
CORBA (Common Request Broker Architecture)
Java Remote Method Invocation (RMI)
Web services
Remote Procedure calls (RPC)
Concept of service registry
Beginnings of service oriented architecture
Sockets
XML
Client-server model
Mark-up languages, HTML
Networks
1985
Internet
1990
WWW
1995
2000
2005
2b.2
Distributed Computing Concepts
One of the underlying concepts is the client-server
model.
Network
Client
Request service
Server
Example
Database
Server response
2b.3
Remote Procedure Call
Early “client-server” system introduced in 1980’s.
Allows a local program to execute a procedure on
a remote computer and get back results from the
procedure.
Basis of certain remote operations such as
mounting remote files in a shared file system.
2b.4
Remote Procedure Call
Fundamental issues
We need to know how and where to make the
call.
Basic RPC requires calling program to know
details about how to make the call (meaning and
types augments and return value)
Calling program also needs to know where to
send request.
2b.5
Service Registry
RPC introduced concept of a service registry, a
third party used to identify location of “service”
(procedure).
Using a service registry is now part of what is
now called a Service-Oriented Architecture.
2b.6
Service-Oriented Architecture
Service registry
1. Publish
2. Find
3. Bind
Service requester
Service provider
2b.7
Service-Oriented Architecture
Steps:
• Services “published” in a Service registry.
• Service requestor asks Service Registry to
locate service.
• Service requestor “binds” with service
provider to invoke service.
2b.8
Later “RPC” systems
(1990’s)
Later forms of remote procedure calls in
1990’s introduced distributed objects:
Examples
• CORBA (Common Request Broker Architecture)
• Java RMI (Remote Method Invocation)
2b.9
Some aspects for a better system
Need:
• Universally agreed standardized
interfaces
• Inter-operability
• Flexibility
• Internet standards (using Internet as
network communication).
Enter Web services
and XML
2b.10
Web Services
• Introduced in the 2000.
• Software components designed to provide
specific operations (“services”) accessible
using standard Internet technologies and
standardized protocols.
The specific standards and protocols will be
described shortly.
• For machine interaction over a network.
2b.11
Key aspects
Has similarities with RMI and other
distributed object technologies
(CORBA etc.) but:
• Web Services are platform
independent
– They use XML
– They use standardized packaging and
Internet network protocols.
2b.12
Service Description
• Need a way of formally describing a
service, what is does, how it is accessed,
etc.
• Concept of an Interface Description
Language (IDL) developed previously.
2b.13
XML-based Web Services
• XML provides a flexible basis for storing and
retrieving service information on web
services.
• In web services, the IDL is an XML language.
• Called Web Service Definition Language
(WSDL)
2b.14
Web Service Definition Language
(WSDL)
A W3C standard XML document that
describes three fundamental properties of a
service:
• What it is - operations (methods) it provides.
• How it is accessed - data format, protocols.
• Where it is located - protocol specific
network address.
W3C -- The World Wide Web Consortium (W3C), www.w3c.org
2b.15
Simple Object Access Protocol (SOAP)
Communication protocol for passing XML documents.
W3C specification describes SOAP as:
“SOAP is a lightweight protocol for exchange of
information in a decentralized, distributed environment. It
is an XML based protocol that consists of three parts: an
envelope that defines a framework for describing what is
in a message and how to process it, a set of encoding
rules for expressing instances of application-defined
datatypes, and a convention for representing remote
procedure calls and responses.”
SOAP originally abbreviation of Simple Object Access Protocol, but
now simply SOAP.
2b.16
Simple Object Access Protocol
(SOAP)
Provides mechanisms for:
– Defining communication unit - a SOAP
message
– Error handling
– Extensions
– Data representation
– Remote Procedure Calls (RPC’s)
– Document-centric approach for business
transactions
– Binding to HTTP
2b.17
Web Service Protocols
• Usually a HTTP transport protocol carries SOAP
(Simple Object Access Protocol) messages
holding XML documents.
HTTP envelope
XML document
SOAP message
2b.18
SOAP Envelope
<SOAP-ENV:Envelope
xmlns=“http://schemas.xmlsoap.org/soap/
envelope/”>
<SOAP-ENV:header>
.
.
namespace
</SOAP-ENV:Header>
.
.
<SOAP-ENV:Body>
.
.
.
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
2b.19
What goes down the Wire
HTTP packet containing:
– Stuff about context, transactions, routing,
reliability, security
– SOAP message
– Attachments
XML/SOAP standardization body, World
Wide Web Consortium (W3C) covers SOAP
and attachments.
2b.20
Service registries
2b.21
Universal Description Discovery, and Integration
(UDDI) Registry
Web service registries can be based upon UDDI
registries introduced in 2001.
UDDI specification standardized by OASIS
(Organization for the Advancement of Structured Information Standards)
See: http://www.oasis-open.org
2b.22
Notes
• UDDI registry is a web service itself.
• UDDI registry itself has to be known to both
client(s) and service.
• Usually some form of service registration and
locator needed.
• In grid computing, basic locator service is
called an index service.
2b.23
Steps to access a web service
in a Service-Oriented Architecture
UDDI Service
registry
UDDI Service
definition
Find
Publish
Location of
service
Give me your WSDL
WSDL Service definition
WSDL
Request service operation
Result
Client
(Service requester)
Server
(Service provider)
2b.24
Question
Could the WDSL document be provided
by the registry, and if so, is that better?
Answer
2b.25
Web Services “Stack”
• HTTP transport
• SOAP message carrying XML documents
• WSDL (Web Services Description
Language used to describe message
syntax for invoking a service and its
response.
• UDDI (Universal Description, Discovery and
Integration) used as web service discovery
mechanism.
2b.26
Web Services Stack
Activity
Protocol/Language
Service discovery
Service description
Service invocation
Service message transport
UDDI
WSDL
SOAP + XML
HTTP
2b.27
Web Service Implementation
WSDL, containers, stubs, SOAP
…
2b.28
Web Service Container
• Web Services generally “hosted” in
a web service container
– software environment that provides
communication mechanisms to and
from the web services and clients.
2b.29
Several possible software environments designed
for web services:
•
Apache Axis
(Apache eXtensible Interaction System)
•
IBM Websphere
•
Microsoft .NET
•
J2EE (Java 2 Enterprise Edition) server
container
• Candidate for hosting web services especially in
enterprise (business) applications.
2b.30
Apache Axis available for free down (Windows
or Linux):
http://ws.apache.org/axis
Used for a web service assignment in Fall
2004/Fall 2005 grid course, see home page.
Apache Axis requires an application server.
– Can be installed on top of a servlet engine such as
Apache Jakarta Tomcat.
– However, could be installed on top of a fullyfleldged J2EE server.
2b.31
Web service environment
Web service container
SOAP messages
carried with HTTP transport
(e.g. Apache Axis)
Web services
Client
Network
Will use an Application server (servlet engine)
(e.g. Apache Jakara Tomcat)
2b.32
Client-Service Implementation
• In the implementation, it is convenient to use
client and service stubs - java classes for
interfacing to the web service SOAP
messaging.
2b.33
Client Stub
• Between client code and the network is a client
stub, sometimes called client proxy.
• Client stub responsible for taking request from
client and converting request into a SOAP
request on network - marshalling.
• Also responsible for receiving SOAP responses
on network and converting to a suitable form for
client.
2b.34
Server Stub
• Between service and network is a server stub,
sometimes called a skeleton.
• Responsible for receiving SOAP request from
client stub and converting it into a suitable form
for the service - unmarshalling.
• Also converts response from service into a SOAP
message for client stub.
2b.35
Web Service Application
SOAP
request
Call client stub
Request
service
Result
returned
SOAP
response
Client receives result
2b.36
Steps
• Client calls client stub.
• SOAP request sent across network
• Server stub receives request and sends
request to service
• Service send result to serve stub
• Server stub sends result across network
to client stub.
• Client stub sends result to client.
2b.37
Math Web service
For concreteness, let us consider web service used
in Fall 2004/2005 assignment 1. A simple version is:
public class MyMath
{
public int squared(int x)
{
return x * x;
}
}
2b.38
Question
What does this service do?
Answer
2b.39
Web Service Description
• Recall use an Interface Description
language (IDL) called WSDL to formally
describe a service, what is does, how it
is accessed, etc.
2b.40
Parts of a WSDL Document
• Root definitions - namespaces
• portType definitions - abstract definition of
service
• Message definitions - parameters in method
signature
• Type definitions - data types
• Binding definitions - to protocols i.e. SOAP
over HTTP
• Service definitions - where service is, ports
2b.41
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://DefaultNamespace"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://DefaultNamespace"
xmlns:intf="http://DefaultNamespace"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:message name="squaredRequest">
<wsdl:part name="in0" type="xsd:int"/>
</wsdl:message>
<wsdl:message name="squaredResponse">
<wsdl:part name="squaredReturn" type="xsd:int"/>
</wsdl:message>
<wsdl:portType name="MyMath">
<wsdl:operation name="squared" parameterOrder="in0">
<wsdl:input message="impl:squaredRequest" name="squaredRequest"/>
<wsdl:output message="impl:squaredResponse" name="squaredResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MyMathSoapBinding" type="impl:MyMath">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/ soap/http"/>
<wsdl:operation name="squared">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="squaredRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/"
namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:input>
<wsdl:output name="squaredResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/"
namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MyMathService">
<wsdl:port binding="impl:MyMathSoapBinding" name="MyMath">
<wsdlsoap:address location="http://localhost:8080/axis/testaccount/ MyMath"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Namespaces
Message definitions
portType
Bindings
Service definitions
WSDL file for math web service
2b.42
Root Definitions
Namespaces
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
targetNamespace="http://DefaultNamespace"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://DefaultNamespace"
xmlns:intf="http://DefaultNamespace"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
2b.43
portType
Describes “What” - an abstract definition of
service operation.
Uses the elements:
• message definitions - a set of parameters
referred to by method signature, decomposed
into parts
• type definitions - defines all data types used
2b.44
portType Definitions
<wsdl:portType name="MyMath">
<wsdl:operation name="squared" parameterOrder="in0">
<wsdl:input message="impl:squaredRequest“
name="squaredRequest"/>
<wsdl:output message="impl:squaredResponse“
name="squaredResponse"/>
</wsdl:operation>
</wsdl:portType>
2b.45
Message Definitions
<wsdl:message name="squaredRequest">
<wsdl:part name="in0" type="xsd:int"/>
</wsdl:message>
<wsdl:message name="squaredResponse">
<wsdl:part name="squaredReturn" type="xsd:int"/>
</wsdl:message>
Standard XML integer type –
no special types in this example
2b.46
Binding
Describes “how” the elements in
abstract interface (portType) are
converted in actual data representations
and protocols e.g. SOAP over HTTP.
2b.47
Binding definitions
<wsdl:binding name="MyMathSoapBinding" type="impl:MyMath">
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/ soap/http"/>
<wsdl:operation name="squared">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="squaredRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/"
namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:input>
<wsdl:output name="squaredResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/"
namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
2b.48
port and service
Describe “where” service is.
• port - describes how a binding is
deployed at the endpoint of a network
• service - a named collection of ports
2b.49
Port/Service Definitions
<wsdl:service name="MyMathService">
<wsdl:port binding="impl:MyMathSoapBinding“
name="MyMath">
<wsdlsoap:address
location="http://localhost:8080/axis/myaccount/MyMath"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Where math service is
2b.50
Build and deploy a web service
Several ways to create web service within a
container and have accessible by clients.
Fundamental service components to build:
• Web service code
• WDSL service description file
• Web service stub
and client components:
• Client stub
• Client code
2b.51
What to create to deploy and test a service
Client Applications
Client
Client
stub
Container
Server Service
stub
WSDL
service
description
Web service stub
Client stub
Client code
Web service code
WDSL service description file
2b.52
In the following, will assume that we are using
Apache Axis, which has several tools for
building and deploying a web service.
2b.53
Java Web Service (JWS) deployment facility
Absolute simplest way in Axis to deplore a web
service:
• First, web service class file with methods created.
• Then file simply renamed as .jws and dropped into a specific
directory that axis expects .jws services to be.
Service code with .jws extension interpreted as a web
service. .jws file automatically compiled if necessary when
service called. All public methods in service code available
and accessible as service operations.
• Simple but has restrictions/limitations.
2b.54
jws facility
Could actually use web service after
deployment with JWS without using a WSDL file
nor stubs.
One could just use service URL, which would
have a .jws extension. Client and service need
code to make SOAP calls.
However, one would normally create a WSDL
file and stubs, and get stubs to handle SOAP.
2b.55
Creating WSDL file
Several ways this can be approached:
• Create service code first and use as basis for
WSDL file
or
• Create WSDL file first and use this as basis
for the service code
Second method probably better from a
Software Engineering perspective, but will
look at both.
2b.56
WSDL from Service Code
Java2WSDL Tool
Axis Java2WSDL program generates WSDL file
(and its schema) from service code.
Program has number of flags including to
specify:
• Name of the output WSDL file (-o flag)
• Location (URL) of the service (-l flag)
• Namespace of WSDL file (-n flag)
• Mapping from package to namespace (-p flag)
2b.57
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://DefaultNamespace"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://DefaultNamespace"
xmlns:intf="http://DefaultNamespace"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.2
Built on May 03, 2005 (02:20:24 EDT)-->
<wsdl:message name="squaredRequest">
<wsdl:part name="in0" type="xsd:int"/>
</wsdl:message>
<wsdl:message name="squaredResponse">
<wsdl:part name="squaredReturn" type="xsd:int"/>
</wsdl:message>
<wsdl:portType name="MyMath">
<wsdl:operation name="squared" parameterOrder="in0">
<wsdl:input message="impl:squaredRequest" name="squaredRequest"/>
<wsdl:output message="impl:squaredResponse" name="squaredResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MyMathSoapBinding" type="impl:MyMath">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/ soap/http"/>
<wsdl:operation name="squared">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="squaredRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/
encoding/"
namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:input>
<wsdl:output name="squaredResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/
encoding/"
namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MyMathService">
<wsdl:port binding="impl:MyMathSoapBinding" name="MyMath">
<wsdlsoap:address location="http://localhost:8080/axis/testaccount/ MyMath"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
2b.58
WSDL file
created
Stubs from WSDL
• If we have WSDL document for service,
can use tools to generate client and
server stubs.
– Axis WSDL2Java program generates stubs
for use on client and server.
2b.59
Web Service Deployment
Descriptor (WSDD)
• WSDD is an XML language used to
describe how to deploy a service.
• Provides for greater flexibility than with
jws “instant” deployment facility.
2b.60
WSDD file for MyService
<deployment xmlns="http://xml.apache.org/axis/wsdd/
xmlns:java=
"http://xml.apache.org/axis/wsdd/providers/java">
<service name="MyService" provider="java:RPC">
<parameter name="className" value="... MyService"/>
<parameter name="allowedMethods" value="*"/>
</service>
</deployment>
2b.61
Deployment with WSDD file
Once WSDD file say called service.wsdd created,
can deploy service with Axis tool, AdminClient:
java org.apache.axis.client.AdminClient service.wsdd
(WSDD was not used in assignment 1 in Fall 2004/5)
2b.62
Client side programming
Once deployed service, want to use it or allow others to use
it. Depending upon details of deployed service and web
service environment, a simple Java program can be used to
access service such as:
import localhost.axis.yourusername.MyMath_jws.MyMathServiceLocator;
import localhost.axis.yourusername.MyMath_jws.MyMathService;
import localhost.axis.yourusername.MyMath_jws.MyMath;
public class MyMathClient {
public static void main(String args[]) throws
Exception {
MyMathService service = new MyMathServiceLocator();
MyMath myMath = service.getMyMath();
int x = (new Integer(args[0])).intValue();
System.out.println("The square of " + args[0] + " is "
+ myMath.squared(x));
}
}
2b.63
More information
Assignment 1 in Fall 2004/Fall 2005 grid computing
required one to write and deploy a web service into
tomcat container using axis tools, and test it with a
simple client, see:
http://www.cs.uncc.edu/~abw/ITCS4010F05/assign1.doc
This assignment dropped from Spring 2007 to allow
us to other new true grid computing assignments.
2b.64
Quiz
(Multiple Choice)
2b.65
What is a WSDL document?
(a) One that describes how to access a service
and use it
(b) One that describes the data of a service
(c) One that describes how to use the client code
(d) None of the other answers
2b.66
What is SOAP?
(a) Something you use to clean yourself
(b) A protocol for passing XML
documents
(c) A protocol for passing object-oriented
programs
(d) None of the other answers
2b.67
What can UDDI be used for?
(a) To transmit data between computers
(b) As a universal data description interface
(c) As a web services registry
(d) To encode the characters of the world
2b.68
What is Apache Axis?
(a) A tool used by American Indians
(b) A hosting environment for web services
(c) A compiler
(d) A type of make tool
2b.69
Which of the following contains all the
services that have been deployed?
(a) Class
(b) Shell
(c) Container
(d) Object
2b.70
What is a client stub?
(a) A way of offending a customer
(b) Code between the client code and the
network
(c) A document that explains the client code
(d) None of the other answers
2b.71
More information on Axis
http://xml.apache.org/axis
2b.72
Questions
2b.73