XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ......

21
1 IBM Confidential e- business XML and Web Services in VisualAge Smalltalk Bryan Hogan IBM Confidential e- business What is XML? n eXtensible Markup Language Markup language for describing data Simpler than predecessor SGML (Standard Generalized Markup Language) More versatile than HTML (HyperText Markup Language) n Self-describing: XML documents can describe other XML documents (ie. XML schema) An open standard for defining and sharing data across diverse network topologies Mark Weitzel (VisualAge Smalltalk) IBM Confidential e- business Why use XML? n XML data representation is human-readable, application-neutral, and language-neutral enabling universal interchange of data XML protocols will soon replace languages and APIs in significance. (Microsoft keynote at XML DevCon 2000)

Transcript of XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ......

Page 1: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

1

IBM Confidential

e-business

XML and Web Services inVisualAge Smalltalk

Bryan Hogan

IBM Confidential

e-business

What is XML?

n eXtensible Markup LanguageØMarkup language for describing dataØSimpler than predecessor SGML (Standard Generalized Markup

Language)

ØMore versatile than HTML (HyperText Markup Language)

n Self-describing: XML documents can describeother XML documents (ie. XML schema)

An open standard for defining and sharing data acrossdiverse network topologies Mark Weitzel (VisualAge Smalltalk)

IBM Confidential

e-business

Why use XML?

n XML data representation is human-readable,application-neutral, and language-neutralenabling universal interchange of data

XML protocols will soon replace languages and APIs in

significance. (Microsoft keynote at XML DevCon 2000)

Page 2: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

2

IBM Confidential

e-business

HTML and XML side by side

<table border cellspacing=0cellpadding=5><tr>

<th>Team name</th><th>Score</th>

</tr><tr>

<td>FSU</td><td>28</td>

</tr><tr>

<td>NCSU</td><td>34</td>

</tr></table>

<football_game><home><school>FSU</school><score>28</score></home>

<visitor><school>NCSU</school><score>34</score></visitor>

</football_game>

IBM Confidential

e-business

Terminology

n World Wide Web Consortium (W3C)Ø develops interoperable technologies (specifications, guidelines, software, and

tools) to lead the Web to its full potential as a forum for information,commerce, communication, and collective understanding. (www.w3.org)

n Document Object Model (DOM)Ø a W3C standard which describes mechanisms for software developers and

Web script authors to access and manipulate parsed XML (and HTML)content. The DOM is both platform-neutral and language-neutral

n Document Type Definition (DTD)Ø a specification of the elements and attributes that are permitted in an XML

document

n XML SchemaØ a specification of the elements and attributes that are permitted in an XML

document along with the datatypes for these artifacts

IBM Confidential

e-business

Terminology (continued)

n Well-formed XML documentØ an XML document that conforms to basic XML rules

n Valid XML documentØ a well-formed XML document that conforms to the rules specified in a

DTD

n Simple API for XML (SAX)Ø a standard interface for event-based XML parsing

n Simple Object Access Protocol (SOAP)Ø A lightweight, XML based protocol for exchange of information in a

decentralized, distributed environment.

Page 3: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

3

IBM Confidential

e-business

Terminology (continued)

n Extensible Stylesheet LanguageTransformations (XSLT)Ø A language for transforming XML documents via the application of

stylesheets

n Mapping specificationsØ Instances of the VisualAge class AbtXmlMappingSpec which contain

rules for mapping XML elements and attributes into Smalltalk objects

n Interface specificationsØ Instances of the VisualAge class AbtInterfaceSpec which describe the

attributes, actions, and events supported by an object

IBM Confidential

e-business

Example document typedefinition<!-- Describes the structure of the objects required for the VA Stock tradingdemo --><!ELEMENT Portfolios (Portfolio*)><!ELEMENT Portfolio ( portfolioId, availableCash, Holdings)><!ELEMENT Holdings (Holding)*><!ELEMENT Holding (symbol,TransactionRecord* )><!ELEMENT TransactionRecords (TransactionRecord)* ><!ELEMENT TransactionRecord ( numShares, price, timestamp,id ) > <!ELEMENT symbol (#PCDATA) ><!ELEMENT numShares (#PCDATA) ><!ELEMENT purchaseCost (#PCDATA) ><!ELEMENT purchaseTimestamp (#PCDATA) > ....

IBM Confidential

e-business

XML schema example<xsd:schema

xmlns:tns="http://www.vast.com/VAStock"

xmlns:xsd="http://www.w3.org/2001/XMLSchema"

targetNamespace="http://www.vast.com/VAStock">

<xsd:complexType name="Portfolio">

<xsd:sequence>

<xsd:element minOccurs="1" maxOccurs="1" name="portfolioId" type="xsd:string"/>

<xsd:element minOccurs="1" maxOccurs="1" name="availableCash" type="xsd:decimal"/>

<xsd:element minOccurs="0" maxOccurs="unbounded" name="Holding"type="tns:Holding"/>

</xsd:sequence>

</xsd:complexType>

<xsd:complexType name="TransactionRecord">

<xsd:sequence>

<xsd:element minOccurs="1" maxOccurs="1" name="numShares" type="xsd:int"/>

<xsd:element minOccurs="1" maxOccurs="1" name="price" type="xsd:decimal"/>

</xsd:sequence>

</xsd:complexType>

Page 4: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

4

IBM Confidential

e-business

Example XML document

<?xml version="1.0"?><!DOCTYPE Portfolios SYSTEM "vaportfolio.dtd" ><Portfolios><Portfolio >

<portfolioId>000001</portfolioId><availableCash>10000</availableCash><Holdings>

<Holding><symbol>YHOO</symbol><TransactionRecord>

<numShares>100</numShares><price>100.01</price><timestamp>2000-07-13-17.24.25.000000</timestamp><id>999</id>

</TransactionRecord></Holdings>

</Portfolio></Portfolios>

IBM Confidential

e-business

VisualAge XML support: Parser

n XML 1.0 specificationè http://www.w3.org/TR/1998/REC-xml-19980210

n DOM level-2 core interfacesè http://www.w3.org/TR/DOM-Level-2-Core/

n SAX 2.0è http://www.megginson.com/SAX/index.html

IBM Confidential

e-business

Example: Using the DOM parser

" Validating parser used to read well-formed XML and verify that thecontents conform to the DTD referenced in the XML."| domDocument domElement |domDocument := AbtXmlDOMParser newValidatingParser parseURI:‘..\ss2001\common\wedding1.xml’.domElement := domDocument getElementById: ‘Planner_1’.

" Non-validating parser used to read well-formed XML data. "| domDocument domElements |domDocument := AbtXmlDOMParser newNonValidatingParserparseURI:‘..\ss2001\common\wedding1.xml’.domElements := domDocument getElementsByTagName: ‘Address’.

Page 5: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

5

IBM Confidential

e-business

Converting XML to objects

n Create SAX handler to automaticallycreate desired object from parsed XML

n Use VisualAge XML mapping support

IBM Confidential

e-business

VisualAge XML support:Serialization

n Create instances of Smalltalk objects from parsed XML documentsn Create XML documents from Smalltalk objectsn Mapping layer to reconcile XML named elements to Smalltalk classes

Ø Leverages the defined public interface for existing partsØ Mapping layer and interface specification can be defined in XML

SmalltalkObjects

XML Parser Engine

Custom SAXEvent Handler

DOMHandler

ObjectSerialization

SAX Event Handlers

DTD

DTD

DTD

DTD

IS

DTD

IS

DTD

ResourceCache

MS

MS

IBM Confidential

e-business

Creating custom SAX handlers

n Create subclass of AbtXmlSaxDefaultHandler

n Override SAX interfaces to customize behaviorØContentHandlerØDTDHandlerØEntityResolverØErrorHandlerØVAST (contains protocol required by VA parser but not present in SAX-2 specification)

n Set overridden interfaces in SAX parserinstance prior to parsing

NOTE: SAX interfaces are identifiable in the Smalltalk image using methodcategories. Each supported SAX interface is categorized with the namingconvention:

'AbtSax-<interface name>'.

Page 6: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

6

IBM Confidential

e-business

Converting XML to objects

n Write code to extract contents from DOMand create objects (see AbtClassElementMapping>>#fromDOMElement:inSet: )

n Create DOM “wrapper” classes (seeAbtDOMElementWrapper)

n Create SAX handler to automatically createdesired object from parsed XML

n Use VisualAge XML mapping support

IBM Confidential

e-business

XML mapping specifications

n AbtXmlMappingSpec - a collection ofclass/element mappings that define rules forconverting to/from XML

n AbtClassElementMapping - rules thatdescribe how an XML element and its childelements and attributes can be mapped to/froma Smalltalk object instance

n AbtAttributeMapping - rules to determine howa simple XML element/attribute is mappedto/from a Smalltalk attribute

IBM Confidential

e-business

Class/element Mapping

§ A rule for mapping an XML element to a Smalltalkclass

<ClassElementMapping ElementTagName="Address"ClassName="STSolutionsAddress" >

<!-- … Attribute mappings go here … ->

</ClassElementMapping>

<Address>

<Street>29 Oak St.</Street>

<City>Raleigh</City>

<State>NC</State>

<Zip>99999</Zip>

</Address>

Page 7: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

7

IBM Confidential

e-business

Attribute Mapping

§ A rule for mapping an XML attribute or text-onlysubelement into a Smalltalk attribute.

<AttributeMapping classAttribute="street">

<Attribute>Street</Attribute>

</AttributeMapping>

<Address>

<Street>29 Oak St.</Street>

<City>Raleigh</City>

<State>NC</State>

<Zip>99999</Zip>

</Address>

IBM Confidential

e-business

Subelement Mapping

§ A rule for mapping a complex XML subelement into anattribute of a Smalltalk object

<ClassElementMapping ElementTagName="CeremonyLocation"ClassName="STSolutionsEventLocation" >

<AttributeMapping ClassAttribute="address">

<SubElement>Address</SubElement>

</AttributeMapping>

</ClassElementMapping>

<CeremonyLocation>

<FacilityName>The Vatican</FacilityName>

<Address>

<!– … Subelements for Address go here … àà

</Address>

</CeremonyLocation>

IBM Confidential

e-business

Subelement Attribute Mapping

§ A rule for mapping an attribute from an XML subelementinto an attribute of a Smalltalk object

<ClassElementMapping ElementTagName=“CeremonyLocation"ClassName="STSolutionsSimpleLocation" >

<AttributeMapping ClassAttribute=“street">

<SubElement>Address</SubElement>

<Attribute>Street</Attribute>

</AttributeMapping>

</ClassElementMapping>

Page 8: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

8

IBM Confidential

e-business

XML mapping specificationexample

<?xml version="1.0"?><!DOCTYPE XmlMappingSpec SYSTEM "..\..\xml\abtxmap.dtd" ><XmlMappingSpec Name="AddressMapping">

<ClassElementMapping ElementTagName="Address"ClassName="STSolutionsAddress" ><AttributeMapping ClassAttribute="street">

<Attribute>Street</Attribute></AttributeMapping>....</ClassElementMapping>

<ClassElementMapping ElementTagName="CeremonyLocation"ClassName="STSolutionsEventLocation" ><AttributeMapping ClassAttribute="name">

<Attribute>FacilityName</Attribute></AttributeMapping><AttributeMapping ClassAttribute="address">

<SubElement>Address</SubElement></AttributeMapping></ClassElementMapping>

</XmlMappingSpec>

IBM Confidential

e-business

Example: Mapping DOM objectsto business objects

| mappingSpec dom |

mappingSpec := AbtXmlMappingSpec fromFile:'..\ss2001\common\wedding.map'.

" Parse the wedding.xml file and map it to a Smalltalk object "dom := AbtXmlDOMParser newValidatingParser parseURI:'..\ss2001\common\wedding1.xml'.

dom mapUsing: mappingSpec

NOTE: Special packaging instructions are required for classes andmethods that are mapped from XML but contain no direct referencesin the execution path for the application.

IBM Confidential

e-business

AbtXmlMappingParser(in VAST 6.0)

§Uses mapping specification during parsing to mapdirectly into objects

§Uses schemas to validate XML structure and convertsimple types

§Uses pluggable configurations to enable custom SAXhandlers for tags that require special processing

Page 9: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

9

IBM Confidential

e-business

AbtXmlMappingParser (Example)

| mappingSpec mappedObject |mappingSpec := AbtXmlMappingSpec fromFile:

'..\ss2001\common\wedding.map'

" Parse the wedding.xml file and map it to a Smalltalk object "mappedObject := AbtXmlMappingParser newNonValidatingParser

mappingSpec: mappingSpecparseURI: '..\ss2001\common\wedding1.xml'

IBM Confidential

e-business

Mapping objects to XML

n #abtXmlPrintString default behavior creates an XMLstring based upon the class name and instancevariables. Protocol in Object can be overridden tocustomize default behavior.

Ø abtXmlCacheKey - an object used to identify XML artifacts inthe XML object cache. Used to resolve defaults for itemslisted below.

Ø abtXmlDtd - a DTD used to determine whether Smalltalkattributes should be rendered as XML attributes or elements

Ø abtXmlMappingSpecification - an AbtXmlMappingSpec usedto map Smalltalk names into XML names

Ø abtXmlOutputSerializer - Specify a custom serializer toconvert the object to XML

IBM Confidential

e-business

Mapping objects to XML(continued)

n Serialization behavior can be overridden byimplementing the instance method #abtXmlPrintOn:

n #abtXmlPrintOn: follows the same pattern as the#printOn: base method

Tip: Check out the new class AbtXmlStream to simplify creation of XML tagsand attributes.

Page 10: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

10

IBM Confidential

e-business

What we learned...

n VisualAge Smalltalk offers various techniques forparsing XML and manipulating XML data.ØDOM level-2ØSAX-2ØMapping support

n Enhanced parser is in the works to parse directly intoobjects by applying mapping rules

e-business

IBM Confidential

e-business

“Innovate…

Integrate…

or Die…”

Page 11: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

11

IBM Confidential

e-business

Typical client/server environment

Customer

Application

Application

Application

Application

Application

Customer Others…

My Company

IBM Confidential

e-business

e-business Drivers...

v 1-to-1 aa Many-to-Many Collaborations

v Packaged Software Applications aaSelf-contained, Interoperable, modularcomponents

v Rigid, point-to-point App Integration aa JIT Sourcing and “Software Assemblies”

v Software as a product aaSoftware as service (utility)

v ASP + e-Marketplace aa P2P Networks

Networked economy drivingevolution of e-business

IBM Confidential

e-business

What is a Web Service?

v Web Services are self-contained,modular application that can be:

● Described

● Published

● Found

● Bound

● Invoked

● Composed

Page 12: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

12

IBM Confidential

e-business

What is a Web Service for?

v A web service is about integration● Application integration

● Independent of platform, programminglanguages, etc…

v Allows “just in time” integration of● Business process

● Dynamic e-business

IBM Confidential

e-business

Who will use Web Services?

v Businesses will start with integratinginternal applications

● E.g. inter-divisional systems efficiency

v Over time (1-3 years), evolutiontowards supply-chain integration

● As more standards are established

v Expose to the transactional web keybusiness processes that yourpartners/suppliers/customers will wantto interact with

IBM Confidential

e-business

Web Services

v How’s it work?

ServiceProvider

ServiceRequester

ServiceBroker

Publ

ish

Find

Bind

Page 13: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

13

IBM Confidential

e-business

Service Oriented Architecture

v Web Service Definition Language: an XML basedinterface definition language for network based services

v Universal Description Discovery & Integration: astandards based architecture specification for servicedescription and discovery. (www.uddi.org)

v Simple Object Access Protocol: a lightweight XML basedprotocol for the exchange of information in adecentralized, distributed environment.

ServiceProvider

ServiceRequester

ServiceBroker

Publ

ish

Find

Bind

WSD

L

UDDI

SOA

P

IBM Confidential

e-business

What is SOAP?

v Simple Object Access Protocol● Supported by Microsoft, IBM, and others

v XML based messaging protocol● Specification submitted to W3C

v Can be bound to multiple transports● HTTP

● MQ

● SMTP

v Goal is to provide a standard objectinvocation protocol

IBM Confidential

e-business

Alternatives to SOAP?

v CORBA, RMI, DCOM, etc…● Makes too many assumptions about

requestor and provider

v XML RPC (SOAP predecessor)

v W3C XP (SOAP successor)

Page 14: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

14

IBM Confidential

e-business

Why is SOAP so great?

v XML● XML interfaces to everything

v Simple

v Standard● Why reinvent?

v Lots and lots of activity from lots andlots of vendors

IBM Confidential

e-business

How does a Web Service know whatmessage to send?

v Web Services Definition Languagev WSDL is an XML format for describing

network services as a set of endpointsoperating on messages containing eitherdocument-oriented or procedure-orientedinformation

v Operations and messages describedabstractly, then bound to a concretenetwork protocol and message format todefine an endpoint

v Related concrete endpoints are combinedinto abstract endpoints (services).

IBM Confidential

e-business

What is WSDL?

v WSDL Describes● Types

● Messages

● Port Types (groups of operations)

● Bindings (port type associated withprotocol)

● Ports (associations of bindings with networkaddress)

● Services (groups of ports)

Page 15: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

15

IBM Confidential

e-business

Smalltalk and WSDL

v WSDL addresses the same issue that weface with CORBA and RMI: StrongTyping

v Separates the interface fromimplementation (a principal very familiar to

Smalltalkers!)

v Multiple implementations of the same(agreed upon) interface

IBM Confidential

e-business

Why is WSDL so great?

v Emerging standard

v Nice fit with SOAP● but not tied to SOAP

v Very flexible, well layered

v Eventually… industry standardWSDL definitions for key webservice types

IBM Confidential

e-business

How do you know what kind ofservice someone provides?

v Answer: the service description was foundin a UDDI registry

<Envelope xmlns="http://sch …">

<Body>

<find_business generic="1.0" xmlns="urn:uddi-org:api">

<name>seller.com</name>

</find_business>

</Body>

</Envelope >

Page 16: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

16

IBM Confidential

e-business

What is UDDI?

v Provides a business registry forservices

v ‘Napster’ for Web Services

v Defines the API to publish anddiscover services

v Uses standard business taxonomies● Industry: NAICS (Industry codes - US

Govt.)

● Product/Services: UN/SPSC (ECMA)

IBM Confidential

e-business

What is UDDI?

•White pages:List of businesses

•Yellow pages:Businesses organized bytaxonomy•Green pages:Businesses publish their services

UDDI Contains lots of information…

IBM Confidential

e-business

Universal Business Registry

Businessespopulatethe registrywithdescriptions of theservicestheysupport

ServiceRegistrations

BusinessRegistrations

2. UBR assigns a programmaticallyunique identifier to each serviceand business registration

Marketplaces, searchengines, and businessapps query theregistry to discoverservices at othercompanies

How UDDI v1 Works

Page 17: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

17

IBM Confidential

e-business

The UDDI Registries

IBM

Ariba

Microsoftother

other

• Peer nodes (websites)• Companies register

with any node• Registrations replicated

on a daily basis• Complete set of

“registered” recordsavailable at all nodes

• Common set ofSOAP APIs supportedby all nodes

• Compliance enforced bybusiness contract

UDDI.org

queries

IBM Confidential

e-business

Why is UDDI so great?

v Standard

v Lots of companies involved

v Fits nicely with SOAP & WSDL

v Very flexible, supports all kinds ofapproaches to web services

IBM Confidential

e-business

Application environment…The Future

Customer

Application

Application

Application

Application

Application

Customer Others…

UniversalBusinessRegistry

ServiceInterface

My Company

Page 18: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

18

IBM Confidential

e-business

Application environment…The Future

Application

Application

Application

Application

Application

EnterpriseBusinessRegistry

ServiceInterface

Customer

Customer Others…

My Company

IBM Confidential

e-business

Open Issues

v Distributed computing is still hard!

v Security

v System Management

v Reliable Messaging

v Quality of Service

v Logging/Tracing/Auditing

v Performance

v Private/Local UDDI Registry

IBM Confidential

e-business

So, What is a Web Service?

v Web Services are self-contained,modular applications that can be:

● Described aa Using WSDL

● Published aa To UDDI

● Found aa In UDDI

● Invoked aa Using SOAP

● Composed aa Orchestration

Page 19: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

19

IBM Confidential

e-business

IBM’s Accomplishments

v Created UDDI with Microsoft and Ariba

v Co-author of SOAP (1.1) with Microsoft,Ariba, + 11 more

v Chair XML protocol working group onW3C

v Co-author of WSDL with Microsoft, Ariba

IBM’s goal is simple: Be the leader in definingthe standards that will power the next generationof e-business

IBM Confidential

e-business

Why we (the Smalltalk Team) likeWeb Services

v Promotes interoperability byminimizing the requirements forshared understanding

v Language implementation neutralv Built on industry standardsv Great integration story!v Wrap ‘legacy’ applicationsv Just in time integration: Late binding

comes to the web!

IBM Confidential

e-business

Learning more: IBM developerWorks

www.ibm.com/developer/

Page 20: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

20

IBM Confidential

e-business

Learning more: UDDI.org

www.uddi.org

IBM Confidential

e-business

Learning more: IBM alphaWorks

www.alphaworks.ibm.com

IBM Confidential

e-business

Learning more:

xml.apache.org/axis

Page 21: XML and Web Services in VisualAge Smalltalk · XML and Web Services in VisualAge Smalltalk ... enabling universal interchange of data XML protocols will soon replace languages and

21

IBM Confidential

e-business

Web Services building blocks

v XML = data neutral

v HTTP = transport protocol neutral

v SOAP = message neutral