Title: The Enterprise Web Services Bus Routable, Reliable and Publish/Subscribe Web Services
1The Enterprise Web Services BusRoutable,
Reliable and Publish/Subscribe Web Services
INFOSYS 290, Section 3Web Services Concepts,
Design and Implementation
Adam Blum ablum_at_good.com
2Agenda
- Bus-style integration versus point to point
integration - WS-Addressing
- WS-ReliableMessaging
- WS-Eventing
3The Problem with Point to Point
- Web services enable ad hoc integration without
negotiating transports - And potentially not even payload formats
- But connectivity is still built point to point
- Origin and destination of messages are determined
by the underlying protocol - Many business events are of interest to many
parties - It would be more efficient to send messages once
to a bus and have it transmitted to all
participants which are interested
4Whats Needed for Bus-Style Integration over Web
Services
- Remove destinations and routing from the
transport - Allow applications to subscribe to business
events of interest - Insure reliable delivery of messages in
standardized way
5Routable Web Services
- The Problem
- Web service destinations are today expressed in
the physical transport - E.g. the http destination address
- The Solution
- Use a SOAP header to reflect the address
6Sample WS-Addressing Message
7Endpoint References Consist Of
- Address
- URI for the endpoint
- Reference Properties
- Optional properties which fully qualify endpoint
reference - Opaque to consuming app
- Reference Parameters
- Optional parameters supplied to endpoint for
particular interaction - Opaque to consuming app
- PortType
- Optional reference to the interface supported
- ServiceName
- Optional WSDL service reference
- ServiceName/_at_PortName
- Optional WSDL port
- Policy
- Optional WS-Policy
8Sample Endpoint Reference
- ltwsaEndpointReference xmlnswsa"..."
xmlnsfabrikam"..."gt - ltwsaAddressgt
- http//www.fabrikam123.example/acct
- lt/wsaAddressgt
- ltwsaPortTypegt
- fabrikamInventoryPortType
- lt/wsaPortTypegt
- lt/wsaEndpointReferencegt
9Binding to SOAP
- Copy address property to destination header field
of SOAP message - Each ReferenceProperty and ReferenceParameter
becomes SOAP header
10SOAP Binding Sample - EndpointReference
- ltwsaEndpointReference xmlnswsa"..."
xmlnsfabrikam"..."gt ltwsaAddressgthttp//www.fabr
ikam123.example/acctlt/wsaAddressgt - ltwsaReferencePropertiesgt
- ltfabrikamCustomerKeygt
- 123456789
- lt/fabrikamCustomerKeygt
- lt/wsaReferencePropertiesgt ltwsaReferenceParamete
rsgt ltfabrikamShoppingCartgtABCDEFGlt/fabrikamShop
pingCartgt - lt/wsaReferenceParametersgt
- lt/wsaEndpointReferencegt
11SOAP Binding SampleSOAP Header
- ltSEnvelope xmlnsS"http//www.w3.org/2003/05/soa
p-envelope" xmlnswsa"..." xmlnsfabrikam"...
"gt ltSHeadergt ... - ltwsaTogt
- http//www.fabrikam123.example/acct
- lt/wsaTogt
- ltfabrikamCustomerKeygt
- 123456789
- lt/fabrikamCustomerKeygt
- ltfabrikamShoppingCartgt
- ABCDEFG
- lt/fabrikamShoppingCartgt ...
- lt/SHeadergt
- ltSBodygt ... lt/SBodygt
- lt/SEnvelopegt
12Message Information Header
- To - destination
- The address (URI) of intended receiver
Mandatory - Action
- URI identifying uniquely semantics of message -
Mandatory - From
- Endpoint reference of the origin
- ReplyTo
- Endpoint reference of intended receiver of
replies - FaultTo
- Endpoint reference of where to send faults
- MessageID
- URI which uniquely identifies message in time and
space - RelatesTo
- Pair of values which indicates how one message is
related to another message
13Sample Message Information Headers
- ltSEnvelope xmlnsS"http//www.w3.org/2003/05/soa
p-envelope" xmlnswsa"http//schemas.xmlsoap.org/
ws/2004/08/addressing" xmlnsf123"http//www.fabr
ikam123.example/svc53"gt - ltSHeadergt
- ltwsaMessageIDgtuuidaaaabbbb-cccc-dddd-eeee-fffff
fffffff lt/wsaMessageIDgt - ltwsaReplyTogt ltwsaAddressgthttp//business456.ex
ample/client1 - lt/wsaAddressgt
- lt/wsaReplyTogt
- ltwsaTo SmustUnderstand"1"gtmailtojoe_at_fabrikam1
23.example - lt/wsaTogt
- ltwsaActiongthttp//fabrikam123.example/mail/Delet
e - lt/wsaActiongt
- lt/SHeadergt
- ltSBodygt
- ltf123Deletegt ltmaxCountgt42lt/maxCountgt
lt/f123Deletegt lt/SBodygt - lt/SEnvelopegt
14A Reply to that Message
- ltSEnvelope xmlnsS"http//www.w3.org/2003/05/soa
p-envelope" xmlnswsa"http//schemas.xmlsoap.org/
ws/2004/08/addressing" xmlnsf123"http//www.fabr
ikam123.example/svc53"gt - ltSHeadergt
- ltwsaMessageIDgt uuidaaaabbbb-cccc-dddd-eeee-www
wwwwwwww lt/wsaMessageIDgt - ltwsaRelatesTogtuuidaaaabbbb-cccc-dddd-eeee- fff
fffffffff - lt/wsaRelatesTogt
- ltwsaTo SmustUnderstand"1"gt
http//business456.example/client1 - lt/wsaTogt ltwsaActiongthttp//fabrikam123.exampl
e/mail/DeleteAck - lt/wsaActiongt
- lt/SHeadergt
- ltSBodygtltf123DeleteAck/gtlt/SBodygt
- lt/SEnvelopegt
15Sample WSE Code
- SoapEnvelope env new SoapEnvelope()
- env.Context.Addressing.Action String.Format("urn
chatmessage") - EndpointReference epr new EndpointReference("soa
p.tcp//theirowntoys.com/adam")) - env.Context.Addressing.ReplyTo new
ReplyTo(epr) - env.CreateBody() // must create body before
setting it - env.Body.InnerXml String.Format(
- "ltxmessagexmlnsx'urnchat'gtltusergt0lt/usergtltms
ggt1lt/msggt lt/xmessagegt", user, msg) - ...
- EndpointReference epr new EndpointReference(
new Uri("soap.tcp//theirowntoys.com/lauren")) - SoapSender ss new SoapSender(epr) // this
fills in the To - ss.Send(env)
16.Creates Following Message
- ltsoapEnvelope xmlnswsa"http//schemas.xmlsoap.o
rg/ws/2003/03/addressing" xmlnswsse"http//schem
as.xmlsoap.org/ws/2003/06/secext"
xmlnssoap"http//schemas.xmlsoap.org/soap/envelo
pe/"gt ltsoapHeadergt - ltwsaActiongturnchatmessagelt/wsaActiongt
- ltwsaReplyTogt
- ltwsaAddressgtsoap.tcp//theirowntoys.com/adam
lt/wsaAddressgt - lt/wsaReplyTogt
- ltwsaMessageIDgtuuid59bc1ebb-40aa-4508-9a69-5b14
8d04d697 lt/wsaMessageIDgt - ltwsaTogtsoap.tcp//theirowntoys.com/lauren
- lt/wsaTogt ...
- lt/soapHeadergt
- ltsoapBodygt
- ltxmessage xmlnsx"urnchat"gt
- ltusergtadamlt/usergt
- ltmsggthilt/msggt
- lt/xmessagegt
- lt/soapBodygt
- lt/soapEnvelopegt
17Routing with WS-Referral
- lt?xml version"1.0" ?gt
- ltrreferrals xmlnsr"http//schemas.xmlsoap.org/w
s/2001/10/referral"gt - ltrrefgt
- ltrforgt
- ltrexactgthttp//localhost/RouterService/St
ockService.asmxlt/rexactgt - lt/rforgt
- ltrif /gt
- ltrgogt
- ltrviagthttp//localhost/StockService/Stoc
kService.asmxlt/rviagt - lt/rgogt
- ltrrefIdgtuuidfa469956-0057-4e77-962a-81c5e292
f2aelt/rrefIdgt - lt/rrefgt
- lt/rreferralsgt
18Implementations of WS-Addressing
- Microsoft WSE 2.0
- Apache Axis!
- http//ws.apache.org/ws-fx/addressing/ (Davanum
Srinivas at CA) - Part of WS-FX
- http//ws.apache.org/ws-fx/
- See WSS4J for WS-Security!
- Systinet
19WS-Addressing References
- WS-Addressing Specification
- http//www.w3.org/Submission/2004/SUBM-ws-addressi
ng-20040810/ - MSDN Article on Moving from WS-Routing to
WS-Addressing - http//msdn.microsoft.com/library/default.asp?url
/library/en-us/dnwebsrv/html/wsroutetowsadd.asp
20WS-ReliableMessaging
21Why a Reliable Messaging Standard?
- Base Web services standards (particularly SOAP
over http) do not address guaranteed delivery of
messages Applications build reliable messages
into their business logic - Each in their own, possibly inconsistent way
- Standards-based interoperability requires a
reliable messaging method of communication - Routing and publish/subscribe exacerbates the
problem - Since there is no direction connection to the
other system - If there are multiple recipients (e.g. bus) we
cannot program to each of their unique business
logic programmed for reliable messaging
22Requirements for Reliable Messaging
- AtLeastOnce delivery
- AtMostOnce delivery
- ExactlyOnce delivery
- InOrder message sequencing
23Reliable Messaging Model
24(No Transcript)
25(No Transcript)
26Sequence
27Sequence Responses
28RM Client Code (IBM ETTK)
- import com.ibm.ws.rm.client.Context
- Context wsrContext new Context()
- wsrContext.setMessageNumber(1)
- wsrContext.setLastMessage(true)
- wsrContext.setSendAckRequested(true)
- wsrContext.setSendCreate(true)
- wsrContext.setSendTerminate(true)
- call.setProperty(Context.RM_CONTEXT_PROPERTY_NAME,
wsrContext) - System.out.println("Sending the PO...")
- call.setOperationName( new QName("http//po.demo.w
srm.ibm.com", "submitPO")) - call.invoke( new Object "12345", "12345445",
new Integer(1), new Float(12.10)) - System.out.println("Message was delivered.")
- (Source code in c/ettk/services/demos/wsrm/client
)
29Three Messages
- Context wsrContext new Context()
- wsrContext.setSequenceIdentifier(groupId)
- wsrContext.setMessageNumber(1)
- Call call (Call)service.createCall(portQName)
- call.setTargetEndpointAddress(url)
- call.setProperty(Context.RM_CONTEXT_PROPERTY_NAME,
wsrContext) - call.setOperationName( new QName("http//po.demo.w
srm.ibm.com", "submitPO")) - EndpointReference epr UtilsWSA.createEndpointRef
erence(url) - // sets To
- WSAddressingOutboundContext context
WSAddressingContextFactory.createWSAddressingOutbo
undContext(epr) - context.setFrom( UtilsWSA.createEndpointReference(
"http//" ETTKConstants.SERVER_HOSTNAME ""
listenerPort "/wstk/services/rm")) - UtilsWSA.associateContextWithCall(context, call)
- System.out.println("Delivering message number
1.") - call.invokeOneWay( new Object "11111A",
"11111111", new Integer(1), new Float(11.11))
30.More Messages
- groupId wsrContext.getSequenceIdentifier()
- wsrContext new Context()
- wsrContext.setSequenceIdentifier(groupId)
- wsrContext.setMessageNumber(3)
- wsrContext.setLastMessage(true)
- Call call3 (Call)service.createCall(portQName)
- call3.setTargetEndpointAddress(url)
- call3.setProperty(Context.RM_CONTEXT_PROPERTY_NAM
E, wsrContext) - call3.setOperationName( new QName("http//po.demo.
wsrm.ibm.com", "submitPO")) - UtilsWSA.associateContextWithCall(context,
call3) - Runnable r3 new Runnable() // async
- public void run()
- System.out.println("Delivering message number
3.") - call3.invokeOneWay( new Object "33333C",
"33333333", new Integer(1), new Float(33.33))
-
-
- wsrContext new Context()
- wsrContext.setSequenceIdentifier(groupId)
31Output
- Running the client code...
- Starting the response listener...
- Delivering message number 1.
- Delivering message number 3.
- Delivering message number 2.
- Server-side output (server.out)
- Received PO with OrderID 11111A
- Received PO with Part ID 11111111
- Received PO with Quantity 1
- Received PO with Amount 11.11
- Received PO with OrderID 22222B
- Received PO with Part ID 22222222
- Received PO with Quantity 1
- Received PO with Amount 22.22
- Received PO with OrderID 33333C
- Received PO with Part ID 33333333
- Received PO with Quantity 1
- Received PO with Amount 33.33
32Systinet Hello World
- import org.systinet.wasp.webservice.ServiceClient
- import org.systinet.wasp.sequence.Sequence
- public static void main(String args) throws
Exception - String serverURL System.getProperty("sys
tinet.demo.server.url", "http//localhost6060") - // lookup of HelloService
- ServiceClient client ServiceClient.creat
e(serviceWSDLURL) - client.setServiceURL(serverURL
servicePath) - // create new sequence for one request
- Sequence seq Sequence.createOutputSequen
ce(client) - seq.setLength(1)
- // call HelloService and print out a
response message - Call call client.createCall("hello")
- System.out.println("Sending 'world' and
waiting for the ACK and response...") - System.out.println(call.invoke(new
Object"world"))
33Systinet Multiple Messages
- private static final String servicePath
"/demo/reliability/OneWayService" - private static final String serviceWSDLURL
"resource/demo/reliability/OneWayService.wsdl" - private static final String sequencePrefix
"http//systinet.com/demo/reliability/oneway/" - private static final long sequenceLength
3 - String serverURL System.getProperty("systin
et.demo.server.url", "http//localhost6060") - // create a service client
- ServiceClient client ServiceClient.create(se
rviceWSDLURL) - client.setServiceURL(serverURL
servicePath) - // register the sequence listener to the
ServiceClient - SequenceListener listener new
OutSequencesListener() - Sequence.addSequenceListener(listener,
client)
34Systinet Multiple Messages
- // load all my previous sequences
- // this causes that all messages which are not
acknowledged are delivering to the destination
again - Sequence seqs Sequence.loadOutputSequences(se
quencePrefix, client) - for(int i 0 seqs ! null i lt seqs.length
i) - System.out.println("Delivering loaded sequence
" seqsi.getID()) - // if the sequence is incomplete we
will continue with next invocations the length
is 'sequenceLength' but - // the current length is equaled to
number of already queued messages in the sequence - // before making invocations the
loaded sequence must be activated for used
processing (client) - if(seqsi.getCurrentLength() !
seqsi.getLength()) - System.out.println("Continuing in
sequence " seqsi.getID()) - seqsi.setActive(true)
- sendMessages(client,
seqsi.getCurrentLength() 1) -
-
- // create a new sequence with length of
'sequenceLength' - // new created sequence is automatically
activated for used processing (client) - Sequence seq Sequence.createOutputSequence(seque
ncePrefix, true, client)
35Systinet Server Side
- public void send(String message)
- // is the incoming message in a sequence?
- Sequence seq Sequence.getActiveInputSe
quence() - if(seq ! null)
- System.out.println("Reliable message "
message " (seq " seq.getID() - ", number " seq.getCurrentMessageNumber()
")") - else
- System.out.println("Non-reliable
message " message) -
36Sandesha Mods to Axis
37Implementations
- IBM Emerging Technologies Toolkit
- http//www.alphaworks.ibm.com/tech/ettk
- Systinet
- http//www.systinet.com/products/wasp_jserver/over
view - Apache Sandesha
- http//ws.apache.org/ws-fx/sandesha/
38WS-ReliableMessaging References
- Spec
- http//msdn.microsoft.com/library/default.asp?url
/library/en-us/dnglobspec/html/ws-reliablemessagin
g.asp - Article
- http//www-106.ibm.com/developerworks/webservices/
library/ws-rmimp/ - IBM Page
- http//www-106.ibm.com/developerworks/webservices/
library/ws-rm/
39WS-Eventing
40WS-Eventing Specification
- Sponsored by Microsoft, Tibco, BEA, Sun
- Four main request messages
- Subscribe
- Renew
- GetStatus
- Unsubscribe
41Point to Point Integration
42Content-Based Routing Topology
43Subscribe Grammar
44Subscribe Message
- lts12Envelopexmlns12'http//www.w3.org/2003/05/s
oap-envelope'xmlnswsa'http//schemas.xmlsoap.or
g/ws/2003/03/addressing'xmlnswse'http//
schemas.xmlsoap.org/ws/2004/01/eventing'xmlnseri
'http//electronicsretailer.com/inventory'gtlts12
Headergt ltwsaActiongt http//schemas.xmlsoap.or
g/ws/2004/01/eventing/Subscribe lt/wsaActiongt lt
wsaTogthttp//electronicsretailer.com/CBRServicelt/
wsaTogt ltwsaReplyTogt ltwsaAddressgt http//el
ectronicsretailer.com/inventory lt/wsaAddressgt
lt/wsaReplyTogt ltwsaMessageIDgt uuidd7c5276b-de
29-4313-b4d4-b3425b200840 lt/wsaMessageIDgt lt/s1
2Headergtlts12Bodygt ltwseSubscribegt - ltwseDeliverygt ltwseNotifyTogt ltwseAddressgt
- http//electronicsretailer.com/inventory/H
andleNewProduct.asp lt/wseAddressgt ltwsaRef
erencePropertiesgt lteriMySubscriptionIDgt1234lt/e
riMySubscriptionIDgt lt/wsaReferencePropertiesgt
lt/wseNotifyTogt - lt/wseDeliverygt ltwseExpiresgt2004-06-26T21070
0.000-0800lt/wseExpiresgt - ltwseFilter xmlnser'http//electronicsretailer
.com/schemas'gt /s12Envelope/s12Body/erNewProd
uct lt/wseFiltergt lt/wseSubscribegtlt/s12Bodygt - lt/s12Envelopegt
45Subscribe Response Grammar
46SubscribeResponse
- lts12Envelopexmlns12'http//www.w3.org/2003/05/s
oap-envelope'xmlnswsa'http//schemas.xmlsoap.or
g/ws/2003/03/addressing'xmlnswse'http//
schemas.xmlsoap.org/ws/2004/01/eventing'xmlnseri
'http//electronicsretailer.com/inventory'gt lts12
Headergt ltwsaActiongt http//schemas.xmlsoap.or
g/ws/2004/01/eventing/SubscribeResponse lt/wsaAc
tiongt ltwsaTogthttp//electronicsretailer.com/inve
ntorylt/wsaTogt ltwsaRelatesTogt uuidd7c5276b-de2
9-4313-b4d4-b3425b200840 lt/wsaRelatesTogt lt/s12
Headergtlts12Bodygt ltwseSubscribeResponsegt ltws
eSubscriptionManagergt - ltwsaAddressgthttp//electronicretailer.com/cbr
servicelt/wsaAddressgt - ltwseReferenceParametersgt
- ltwseIdentifiergt
- uuid5005cfe6-c2c6-4296-9c3a-80b9ad111813
- lt/wseIdentifiergt
- lt/wseReferenceParametersgt
- lt/wseSubscriptionManagergt ltwseExpiresgt200
4-08-01T000000-000-0000lt/wseExpiresgt lt/wseSu
bscribeResponsegtlt/s12Bodygt - lt/s12Envelopegt
47A Notification (any matching message)
- lts12Envelopexmlns12'http//www.w3.org/2003/05/s
oap-envelope'xmlnswsa'http//schemas.xmlsoap.or
g/ws/2003/03/addressing'xmlnswse'http//schemas
.xmlsoap.org/ws/2004/01/eventing'xmlnseri'http
//electronicsretailer.com/inventory'xmlnser'htt
p//electronicsretailer.com/schemas'gtlts12Headergt
ltwsaActiongt http//electronicsretailer.com/sc
hemas/NewProduct lt/wsaActiongt ltwsaTogthttp//el
ectronicsretailer.com/inventorylt/wsaTogt lteriMyS
ubscriptionIDgt1234lt/eriMySubscriptionIDgtlt/s12He
adergtlts12Bodygt lteriNewProductgt lteriProductID
gtAC-MP471lt/eriProductIDgt lteriProductNamegt Acme
128MB Portable MP3 Player lt/eriProductNamegt lte
riProductCategorygtMP3 Playerslt/eriProductCategor
ygt lteriPricegt47.56lt/eriPricegt lt/eriNewProduct
gtlt/s12Bodygt - lt/s12Envelopegt
48Sample Subscription Client Code
- bool resulttrue
-
- CBRSubscribe.CBRService.Subscribe
subscriptionnew CBRSubscribe.CBRService.Subscribe
() - subscription.NotifyTonew CBRSubscribe.CBRService.
EndpointReferenceType() - subscription.NotifyTo.Addressnew
CBRSubscribe.CBRService.AttributedURI() - subscription.NotifyTo.Address.ValuenotifyAddress
- if (subscriptionFilter.Lengthgt0)
- subscription.Filternew CBRSubscribe.CBRService.M
essagePredicateAssertion() - subscription.Filter.ValuesubscriptionFilter
-
- subscription.ExpiresexpireDate
- CBRSubscribe.CBRService.Eventing objEventingnew
CBRSubscribe.CBRService.Eventing(cbrServiceURL) - CBRSubscribe.CBRService.SubscribeResponse
subscribeResponsenew CBRSubscribe.CBRService.Subs
cribeResponse() - try
- subscribeResponseobjEventing.SubscribeOp(subscri
ption) -
- catch
- resultfalse
49Changes over First Draft
- No requirements for WS-Addressing delivery
- GetStatus message
- SubscriptionManager abstraction
50WS-Eventing Implementations
- My WS-Eventing general purpose client
- http//adamblum.com/cbrsubscribe.zip
- Needs to be updated to August 2004 spec!
- Systinets Content-Based Router
- http//www.systinet.com/contentbasedrouting
51Competitors to WS-Eventing
- WS-Notification
- IBM et al
- Used in WSDM
- JMS
- Sonic
- Fiorano
- Message queueing/bus providers
- Tibco (behind WS-Eventing)
- MQSeries
52WS-Notification Differences
- Topic abstraction
- Necessary?
- Notification brokers
- Necessary?
- Subscription Manager?
- Yes!
- http//blum.typepad.com/coarsegrained/2004/02/wsno
tification_.html
53WS-Eventing References
- The Spec
- http//msdn.microsoft.com/webservices/understandin
g/specs/default.aspx?pull/library/en-us/dnglobspe
c/html/ws-eventing.asp - WSDL http//schemas.xmlsoap.org/ws/2004/08/eventi
ng/eventing.wsdl - My Web Services Journal article
- http//www.sys-con.com/story/?storyid44362DE1
- Interesting Survey of CBR methods
- Covers WSE via WS-Referral (shown in this deck),
Indigo via rules manager and Systinet WASP - http//www.c-sharpcorner.com/Code/2004/June/Conten
tBasedWS.asp
54Putting It All TogetherA Web Services Bus
- WS-Addressing for removing reliance on physical
direct connections - WS-ReliableMessaging to insure multiple
disconnected recipients all receive message - WS-Eventing to ease communications with multiple
recipients - http//blum.typepad.com/coarsegrained/2003/11/inde
x.html