Title: K
1Web Services The langua franca of distributed
systems?
Developed by Larry LeFever for CS616 Software
Engineering Seminar Spring 2003, Pace University,
White Plains, NY
2A Definition of a Web Service
A functionality-set or module of computational
utility accessible via a network, whether LAN or
WAN (e.g., the Internet) by use of textual open
standard protocols such as ASCII (actually,
UTF-8), XML (especially SOAP) and HTTP,
especially in the interest of facilitating
interoperation of nodes of an heterogeneous
distributed system.
3Typical Web Services Technology-Stack UDDI WSD
L SOAP XML UTF-8 HTTP TCP/IP Ethernet/PPP/Wireless
4A Kind of Object-Oriented Remote Procedure Call
(a.k.a. RPC) Architecture With an Open standards
based Textual interface Supporting Dynamic
service-discovery
5Können Siedas lesen?
6Können Sie det lesen?
7The Problem
Just as no man is an island, no enterprise is
an island either not anymore. In the good old
days, when IBM was, as it were, Microsoft, the
enterprise was, indeed, an island it invested in
one massive comprehensive solution from the same
vendor named IBM, for instance. There was no
Internet yet, and no need, or at least no means
yet, for automated communication between
different enterprises i.e., between different
systems. UPSHOT previously, isolated
homogeneous systems
8Enterprise-islands
Not So Acquisitive, Inc.
Take-Over Target, Inc.
Acquisitive, Inc.
9Enterprise-islands
Not So Acquisitive, Inc.
Wishful Thinking, Inc.
Monopolists R Us
Almost All of It, Inc.
10Enterprise-islands
Not So Acquisitive, Inc.
Wishful Thinking, Inc.
Monopolists R Us
Almost All of It, Inc.
lt Können Sie det lesen? gt
11Character-Encodings
Cp500 -- IBM proprietary (EBCDIC, Extended
Binary Coded Decimal Interchange Code) D2 CC
95 95 85 95 40 E2 89 85 40 84 85 A3 40 93 85 A2
85 95 65
4B F6 6E 6E 65 6E 20 53 69 65 20 64 65 74 20 6C
65 73 65 6E 3F ISO-8859-1 -- ANSI (public)
standard (LATIN1, an Extended ASCII, 8-bit
ASCII)
Character codes from http//std.dkuug.dk/i18n/cha
rmaps/
12Character-Encodings
Cp500 -- IBM proprietary (EBCDIC, Extended
Binary Coded Decimal Interchange Code) D2 CC
95 95 85 95 40 E2 89 85 40 84 85 A3 40 93 85 A2
85 95 65
K ö n n e n S i e d e t l e s e n ?
4B F6 6E 6E 65 6E 20 53 69 65 20 64 65 74 20 6C
65 73 65 6E 3F ISO-8859-1 -- ANSI (public)
standard (LATIN1, an Extended ASCII, 8-bit
ASCII)
Character codes from http//std.dkuug.dk/i18n/cha
rmaps/
13Character-Encodings
Cp500 -- IBM proprietary (EBCDIC, Extended
Binary Coded Decimal Interchange Code) D2 CC
95 95 85 95 40 E2 89 85 40 84 85 A3 40 93 85 A2
85 95 65
K ö n n e n S i e d e t l e s e n ?
4B F6 6E 6E 65 6E 20 53 69 65 20 64 65 74 20 6C
65 73 65 6E 3F ISO-8859-1 -- ANSI (public)
standard (LATIN1, an Extended ASCII, 8-bit
ASCII)
Character codes from http//std.dkuug.dk/i18n/cha
rmaps/
14Character-Encodings
Cp500 -- IBM proprietary (EBCDIC, Extended
Binary Coded Decimal Interchange Code) D2 CC
95 95 85 95 40 E2 89 85 40 84 85 A3 40 93 85 A2
85 95 65
K ö n n e n S i e d e t l e s e n ?
4B F6 6E 6E 65 6E 20 53 69 65 20 64 65 74 20 6C
65 73 65 6E 3F ISO-8859-1 -- ANSI (public)
standard (LATIN1, an Extended ASCII, 8-bit
ASCII)
Character codes from http//std.dkuug.dk/i18n/cha
rmaps/
15Character-Encodings
Cp500 -- IBM proprietary (EBCDIC, Extended
Binary Coded Decimal Interchange Code) D2 CC
95 95 85 95 40 E2 89 85 40 84 85 A3 40 93 85 A2
85 95 65
K ö n n e n S i e d e t l e s e n ?
4B F6 6E 6E 65 6E 20 53 69 65 20 64 65 74 20 6C
65 73 65 6E 3F ISO-8859-1 -- ANSI (public)
standard (LATIN1, an Extended ASCII, 8-bit
ASCII)
Character codes from http//std.dkuug.dk/i18n/cha
rmaps/
16We need a common language. Nicht wahr? Or,
rather, computers need a common
character-encoding for dealing with different
natural languages -- and, for that matter, even
for one given language, such as English.
17Proprietary variants of EBCDIC, roughly one per
character-set (i.e., alphabet). 8-bit
encoding Proprietary variants of ASCII, roughly
one per character-set (i.e., alphabet). 8-bit
encoding UNICODE 16-bit encoding UTF-8 --
8-bit, if it fits, else 16-bit or more (UCS
Transformation Format) (UCS Universal
Character Set)
18 ISO/IEC 10646-1 defines a multi-octet character
set called the Universal Character Set (UCS)
which encompasses most of the world's writing
systems. Multi-octet characters, however, are not
compatible with many current applications and
protocols, and this has led to the development of
a few so-called UCS transformation formats (UTF),
each with different characteristics. UTF-8, ,
has the characteristic of preserving the full
US-ASCII range, providing compatibility with file
systems, parsers and other software that rely on
US-ASCII values but are transparent to other
values It is noteworthy that the same set of
characters is defined by the Unicode standard
UNICODE (http//www.ietf.org/rfc/rfc2279.txt
Abstract Intro.)
19Character-encodings may be thought of as part of
a systems ABI
(application binary interface) along with
its - endianness - address-alignment
20From http//www.netrino.com/Publications/Glossary
/Endianness.html
if defined(BIG_ENDIAN) !defined(LITTLE_ENDIAN)
define htons(A) (A) define htonl(A) (A)
define ntohs(A) (A) define ntohl(A) (A)
elif defined(LITTLE_ENDIAN)
!defined(BIG_ENDIAN) define htons(A)
((((uint16)(A) 0xff00) gtgt 8) \
(((uint16)(A) 0x00ff) ltlt 8)) define
htonl(A) ((((uint32)(A) 0xff000000) gtgt 24)
\ (((uint32)(A) 0x00ff0000)
gtgt 8) \ (((uint32)(A)
0x0000ff00) ltlt 8) \
(((uint32)(A) 0x000000ff) ltlt 24)) define
ntohs htons define ntohl htohl
21From http//ciips.ee.uwa.edu.au/morris/Year1/CLP
110/struct.html
struct padded char a double e / might
start on 8-byte boundary! / int x, y struct
f g printf("d\n", sizeof( struct padded )
)
22From http//ciips.ee.uwa.edu.au/morris/Year1/CLP
110/struct.html
23From http//ciips.ee.uwa.edu.au/morris/Year1/CLP
110/struct.html
By printing out sizeof (struct t_labelled_point
-- see following, ed. LL), you discovered that
your machine pads the structure to 16 bytes. By
examining the binary file, you've confirmed that
there are 7 null bytes after each character.
However, the same exercise on the target machine
shows that the struct isn't padded, i.e., it only
takes 9 bytes, so we need to do some hacking to
read the file.
24include "labelled_point.h" define BUF_LEN
16 define Z_OFFSET 8 / lt EMPHASIS ADDED
!!! / int load_point_array( labelled_point a,
int n ) / a is an array of objects
constructed by calls to the appropriate
constructor / int f, i, nb char
bufBUF_LEN f open( "dump.dat", 0 )
for(i0iltni) / Read data into a
character buffer / nb read( f, buf,
BUF_LEN ) ai-gta buf0 / First char
is the label / memcpy( (ai-gtz),
bufZ_OFFSET, sizeof(double) ) / lt EMPHASIS
ADDED !!! / .. return ..
25One might say that what we need is
an ATI (application textual interface)
a term of my own devising
26Enter XML (extensible mark-up language) A
meta-mark-up language, A mark-up language for
defining Other markup languages
27From http//javaboutique.internet.com/tutorials/S
OAP/index.html
POST /StockQuote HTTP/1.1 Host
www.stockquoteserver.com Content-Type text/xml
charset"utf-8 Content-Length
nnnn SOAPAction"Some-URI" ltSOAP-ENVEnvelope
xmlnsSOAP-ENV"http//schemas.xmlsoap.org/soap/e
nvelope/" SOAP-ENVencodingStyle"http//schema
s.xmlsoap.org/soap/encoding/"gt ltSOAP-ENVBodygt
ltmGetLastTradePrice xmlnsm"Some-URI"gt
ltsymbolgtDISlt/symbolgt
lt/mGetLastTradePricegt lt/SOAP-ENVBody
gt lt/SOAP-ENVEnvelopegt
lt simple datatype, as opposed to composite
type, like C-struct
28From http//javaboutique.internet.com/tutorials/S
OAP/index.html
HTTP/1.1 200 OK Content-Type text/xml
charset"utf-8 Content-Length
nnnn ltSOAP-ENVEnvelope xmlnsSOAP-ENV"http//
schemas.xmlsoap.org/soap/envelope/"
SOAP-ENVencodingStyle"http//schemas.xmlsoap.org
/soap/encoding/"/ gt ltSOAP-ENVBodygt
ltmGetLastTradePriceResponse xmlnsm"Some-URI"gt
ltPricegt34.5lt/Pricegt
lt/mGetLastTradePriceResponsegt
lt/SOAP-ENVBodygt lt/SOAP-ENVEnvelopegt
29Parameter-Marshalling - DCE-RPC, X/Open-RPC,
MS-DCOM, CORBA, Sun-RMI -
binary - Web Services - textual
(XML gt SOAP)
30http//www.opengroup.org/onlinepubs/009629399/chap
12.htmtagcjh_17_02
DCE Network Data Representation (NDR) (similar to
X/Opens External Data Representation (XDR))
typedef struct p_context_id_t
p_cont_id u_int8
n_transfer_syn / number of items /
u_int8 reserved
/ alignment pad, m.b.z. /
p_syntax_id_t abstract_syntax /
transfer syntax list /
p_syntax_id_t size_is(n_transfer_syn)
transfer_syntaxes
p_cont_elem_t typedef struct
u_int8 n_context_elem /
number of items / u_int8
reserved / alignment
pad, m.b.z. / u_short
reserved2 / alignment
pad, m.b.z. / p_cont_elem_t
size_is(n_cont_elem) p_cont_elem
p_cont_list_t
31http//javaboutique.internet.com/tutorials/SOAP/in
dex2.html
class Person String name int
age class Aservice public String
acceptPerson(Person p) //do something
here return a string
XML for
calling acceptPerson
ltSOAP-ENVBodygt
ltns1acceptPerson xmlnsns1urnthe urn of the
service SOAP-ENVencodingStyle
http//schemas.xmlsoap.org/soap/encoding/gt
ltserviceParam xmlnsns2some uri
xsitypens2Persongt ltage
xsitype xsdintgt22lt/agegt
ltname xsitypexsdstringgtSamudralt/namegt
lt/serviceParamgt lt/ns1acceptPersongt lt/SOAP-ENV
Bodygt
lt composite datatype
lt extremely simple Web Service
32http//javaboutique.internet.com/tutorials/SOAP/cl
ient2.html
Apache SOAP Example Web Service Invocation
public static void main(String args)
String urlString args0 String name
args1 SoapClient client new
SoapClient(urlString) Person nameObject
new Person() nameObject.setName(name)
nameObject.setAge(22) Call call new
Call() call.setTargetObjectURI("urngreetingS
ervice") call.setMethodName("sayGreeting")
call.setEncodingStyleURI(Constants.NS_URI_SOAP_
ENC) SOAPMappingRegistry smr new
SOAPMappingRegistry() BeanSerializer bsr
new BeanSerializer() lt !!! QName qn
new QName("urngreetingService",
"sam.soap.client.Person") smr.mapTypes.(Const
ants.NS_URI_SOAP_ENC, qn,
sam.soap.client.Person.class, bsr,
bsr) call.setSOAPMappingRegistry(smr)
Vector v new Vector() Parameter param1
new Parameter("name",
sam.soap.client.Person.class,
nameObject, null) v.addElement(param1)
call.setParams(v)
33http//javaboutique.internet.com/tutorials/SOAP/cl
ient2.html
Apache SOAP Example Web Service
Invocation (cont.)
Response res call.invoke(new URL(client.urlStrin
g), "") if(
res.generatedFault() false) Parameter
retValue res.getReturnValue() Object value
retValue.getValue() System.out.println(valu
e) else System.out.println("The fault
is "res.getFault().getFaultString())
34http//javaboutique.internet.com/tutorials/SOAP/in
dex3.html
Apache SOAP Custom Serialization
public class PersonSerializer extends Object
implements Serializer, Deserializer public
void marshall(String inScopeEncStyle, Class
javaType, Object src,
Object context, Writer sink, NSStack
nsStack,
XMLJavaMappingRegistry xjmr, SOAPContext ctx)
throws
IllegalArgumentException,IOException
inScopeEncStyle This represents the
encodingStyleURI as specified in the
enclosing Call or Response
object. javaType This is the
run-time type of the object that is to be
serialized. src This is
a reference to the Java object to be
serialized. context A String
denoting the accessor name It must be non-null.
sink The destination to
which the SOAP XML instance will be
written. nsStack A data
structure that implements a stack of namespace
declarations
that are currently in scope. xjmr
This is the XMLJavaMappingRegistry object.
ctx This is used to
pass in things like
javax.servlet.http.HttpServletRequest and
javax.servlet.http.HttpSession from the servlet
context.
35http//javaboutique.internet.com/tutorials/SOAP/in
dex3.html
Apache SOAP Custom Serialization (cont.)
SoapEncUtils.generateStructureHeader(inScopeEncSty
le, javaType, context,
sink,
nsStack, xjmr) sink.write(StringUtils.lineSeparat
or) Person person (Person)src String name
person.getName() int age person.getAge() if(na
me !null) xjmr.marshall(inScopeEncStyle,
String.class, name, "name", sink, nsStack, ctx)
//fill the gap for the age parameter
yourself sink.write(StringUtils.lineSeparator
) sink.write("lt/" context
'gt') The
Generated XML-instance
ltserviceParam
xmlnsns2some uri xsitypens2Persongt
ltage xsitype xsdintgt22lt/agegt ltname
xsitypexsdstringgtPaullt/namegt lt/serviceParamgt
36Apache SOAP Default Serialization
public class BeanSerializer implements
Serializer, Deserializer public void
marshall(String inScopeEncStyle, Class javaType,
Object src,
Object context, Writer sink, NSStack nsStack,
XMLJavaMappingRegistry xjmr, SOAPContext ctx)
throws IllegalArgumentException, IOException
PropertyDescriptor properties
getPropertyDescriptors(javaType) for (int i
0 i lt properties.length i) String
propName propertiesi.getName() Class
propType propertiesi.getPropertyType()
// Serialize every property except the "class"
property. if (!propType.equals(Class.class))
Method propReadMethod
propertiesi.getReadMethod() // Only
serialize readable properties. if
(propReadMethod ! null) Object
propValue null // Get the property's
value. try if (src !
null) propValue
propReadMethod.invoke(src, new Object)
catch (Exception e) //
Serialize the property. Parameter param
new Parameter(propName, propType, propValue,
null) xjmr.marshall(Constants.NS_URI_SO
AP_ENC, Parameter.class, param,
null, sink, nsStack, ctx)
37Apache SOAP Default Serialization (cont.)
private PropertyDescriptor getPropertyDescripto
rs(Class javaType) throws IllegalArgumentExcep
tion BeanInfo beanInfo null try
beanInfo Introspector.getBeanInfo(javaType)
From \soap-src-2.3\soap-2_3\src\org\apache\soap\e
ncoding\soapenc\BeanSerializer.java
38Web Services Description Language (WSDL) WSDL is
an XML format for describing network services as
a set of endpoints operating on messages
containing either document-oriented or
procedure-oriented information. The operations
and messages are described abstractly, and then
bound to a concrete network protocol and message
format to define an endpoint (from
http//www.w3.org/TR/wsdl_soap-e) Universal
Description, Discovery Integration (UDDI) The
UDDI Business Registry is the implementation of
the specification developed by uddi.org. The UDDI
Business Registry is a core element of the
infrastructure that supports web services. The
UDDI Business Registry provides a place for a
company to register its business and the services
that it offers. People or businesses that need a
service can use this registry to find a business
that provides the service. (from
http//www.uddi.org/faqs.htmlwho)
39WSDL Example (from http//www.w3.org/TR/wsdl_soa
p-e)
lt?xml version"1.0"?gt ltdefinitions
name"StockQuote"
targetNamespace"http//example.com/stockquote.wsd
l" xmlnstns"http//exampl
e.com/stockquote.wsdl"
xmlnsxsd"http//www.w3.org/2000/10/XMLSchema"
xmlnsxsd1"http//example.co
m/stockquote.xsd"
xmlnssoap"http//schemas.xmlsoap.org/wsdl/soap/"
xmlns"http//schemas.xmls
oap.org/wsdl/"gt ltmessage
name"GetTradePriceInput"gt
ltpart name"tickerSymbol" element"xsdstring"/gt
ltpart name"time"
element"xsdtimeInstant"/gt
lt/messagegt ltmessage
name"GetTradePriceOutput"gt
ltpart name"result" type"xsdfloat"/gt
lt/messagegt ltportType
name"StockQuotePortType"gt
ltoperation name"GetTradePrice"gt
ltinput message"tnsGetTradePriceInput"/gt
ltoutput message"tnsGetTra
dePriceOutput"/gt
lt/operationgt lt/portTypegt
40WSDL Example (cont.)
ltbinding name"StockQuoteSoapBind
ing" type"tnsStockQuotePortType"gt
ltsoapbinding style"rpc"
transport"http//schemas.xmlsoap.org/soap/http"/gt
ltoperation
name"GetTradePrice"gt
ltsoapoperation soapAction"http//example.com/Get
TradePrice"/gt ltinputgt
ltsoapbody use"encoded"
namespace"http//example.com/stockquote"
encodingStyle"http
//schemas.xmlsoap.org/soap/encoding/"/gt
lt/inputgt
ltoutputgt ltsoapbody
use"encoded" namespace"http//example.com/stockq
uote"
encodingStyle"http//schemas.xmlsoap.org/soap/enc
oding/"/gt lt/outputgt
lt/operationgtgt
lt/bindinggt ltservice
name"StockQuoteService"gt
ltdocumentationgtMy first servicelt/documentationgt
ltport name"StockQuotePort"
binding"tnsStockQuoteBinding"gt
ltsoapaddress location"http//example.com/
stockquote"/gt lt/portgt
lt/servicegt lt/definitionsgt
41Q How does UDDI relate to WSDL? A There is no
formal relationship between UDDI and WSDL (Web
Services Description Language), although the
technologies are complementary. WSDL can be used
to specify a web service interface. The tModel
(see following, ed. LL) entry for the service
type could point to a WSDL abstract description,
and the binding template for a specific service
could point to a WSDL concrete description. (from
http//www.uddi.org/faqs.htmlweb)
42From http//www.oasis-open.org/committees/uddi-sp
ec/doc/bp/uddi-spec-tc-bp-using-wsdl-v108-20021110
.htm
The tModel (t for Taxonomy) lttModel
authorizedName"..." operator"..."
tModelKey"..."gt ltnamegtStockQuote
Servicelt/namegt ltdescription
xmllang"en"gt WSDL description of a
standard stock quote service
interface lt/descriptiongt
ltoverviewDocgt ltdescription
xmllang"en"gt WSDL source
document. lt/descriptiongt
ltoverviewURLgt http//example.com/sto
ckquote.wsdl lt/overviewURLgt
lt/overviewDocgt ltcategoryBaggt
ltkeyedReference tModelKey"
uuidC1ACF26D-9672-4404-9D70-39B756E62AB4"
keyName"uddi-orgtypes"
keyValue"wsdlSpec"/gt lt/categoryBaggt
lt/tModelgt
43From http//www.oasis-open.org/committees/uddi-sp
ec/doc/bp/uddi-spec-tc-bp-using-wsdl-v108-20021110
.htm
The Binding Template ltbusinessService
businessKey"..." serviceKey"..."gt
ltnamegtStockQuoteServicelt/namegt
ltdescriptiongt (...) lt/descriptiongt
ltbindingTemplatesgt ltbindingTemplategt
(...) ltaccessPoint
urlType"http"gt
http//example.com/stockquote
lt/accessPointgt lttModelnstanceDetails
gt lttModelnstanceInfo
tModelKey"..."gt
lt/tModelnstanceInfogt
lttModelnstanceDetailsgt
lt/bindingTemplategt lt/bindingTemplatesgt
lt/businessServicegt
44What is Axis? Axis is essentially a SOAP
engine -- a framework for constructing SOAP
processors such as clients, servers, gateways,
etc. The current version of Axis is written in
Java .... Axis isn't just a SOAP engine
-- it also includes a simple
stand-alone server, a server which
plugs into servlet engines such as Tomcat,
extensive support for the Web
Service Description Language (WSDL),
emitter tooling that generates Java classes from
WSDL. some sample programs, and
a tool for monitoring TCP/IP packets.
(from http//ws.apache.org/axis/ -- Axis
Users Guide)
45Axis provides a utility to generate the skeletons
from the WSDL.. An example invocation
follows java org.apache.axis.wsdl
.WSDL2Java --server-side
--skeletonDeploy true MessageObject.wsdl Axis
provides a utility to generate the stubs from the
WSDL.. An example invocation follows
java org.apache.axis.wsdl.WSDL2Java
MessageObject.wsdl From http//www.cs.unc.edu/
Courses/comp190/docs/lessons/ws/ws_wsdl/
46Security (from http//216.239.57.100/search?qca
cheGyWSEczHfFQC www.oasis-open.org/presentations
/security/PMishra.pptSAMLbasicexamplehlenie
UTF-8) - various standards being developed -
for example, Security Assertions Markup Language
(SAML) ltsamlassertion Issuerexample.comgt
ltsamlConditions NotBefore NotAfter/gt
ltsamlAuthenticationStatement
AuthenticationMethod
AuthenticationInstant gt ltsamlsubject
gtJohn Doelt/samlsubjectgt lt/samlAuthenticati
onStatementgt ltsamlAttributeStatementgt
ltsamlsubject gtJohn Doelt/samlsubjectgt
ltsamlAttribute AttributeNameTitle gt
ltsamlAttributeValuegtManagerlt/AttributeV
aluegt lt/samlAttributegt
ltsamlAttribute AttributeNameSpendLimit gt
ltsamlAttributeValuegt10,000lt/Attribut
eValuegt lt/samlAttributegt
lt/samlAttributeStatementgt lt/samlAssertiongt
47WS-I (Web Services Interoperability
Organization) WS-I was formed specifically for
the creation, promotion, or support of Generic
Protocols for Interoperable exchange of messages
between services. Generic Protocols are protocols
that are independent of any specific action
indicated by the message beyond actions necessary
for the secure, reliable, or efficient delivery
of messages "Interoperable" means suitable for
and capable of being implemented in a neutral
manner on multiple operating systems and in
multiple programming languages. (from
http//www.ws-i.org/)
48What the WS-I does
- Web Services testing and implementation guidance
to accelerate customer deployments - Encourage best-practices use of "baseline" Web
Services today (XML, SOAP, WSDL, UDDI) - Deliver a set of self-administered test suites
for conformance of baseline specification
implementations aimed at improving interoperation
of infrastructure and applications.
(from http//www.ws-i.org/FAQ.aspxA01)
49A Definition of a Web Service
A functionality-set or module of computational
utility accessible via a network, whether LAN or
WAN (e.g., the Internet) by use of textual open
standard protocols such as ASCII (actually,
UTF-8), XML (especially SOAP) and HTTP,
especially in the interest of facilitating
interoperation of nodes of an heterogeneous
distributed system.
50Typical Web Services Technology-Stack UDDI WSD
L SOAP XML UTF-8 HTTP TCP/IP Ethernet/PPP/Wireless
51Haben Sie Fragen?
Can you read that? - )