paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS...

43
Paul Fremantle [email protected] http://bloglines.com/blog/paulfremantle Apache Synapse

Transcript of paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS...

Page 1: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Paul Fremantle

[email protected]

http://bloglines.com/blog/paulfremantle

Apache Synapse

Page 2: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

About me

• EX IBM STSM

• developed the IBM Web Services Gateway

• Apache WSIF

• Apache Axis C/C++

• JWSDL/WSDL4J – now Woden

• Co-founded WSO2

• Committer on Apache Synapse

• Member of the ASF

Page 3: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Apache Synapse

Synapse is an effort undergoing incubation at the Apache Software Foundation (ASF), sponsored by the Web Services PMC. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.

The Small Print

In other words … an incubator project for the moment

Page 4: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Contents

• What is an ESB – and what is our mindset

• Connect, Manage, Transform

• Synapse structure and model

• Deployment

• Configuration

• Programming model

Page 5: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

What is an ESB?

Page 6: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

A common ESB definition“Any to any data connectivity and

transformation (including Web Services)

built on an advanced, proven, reliable

middleware infrastructure”

Page 7: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

ESB definition“Any to any data connectivity and

transformation (including Web Services)

built on an advanced, proven, reliable

middleware infrastructure”

which means

• Our existing middleware re-branded as an

SOA platform, with some new web

services adapters at the edges

Page 8: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Confusion

• “Lots of people use the ESB word these days to talk about lots ofdifferent kinds of technology, so its a pretty meaningless term. (e.g.Some Synapse folks claim its an ESB too while others claim its anAxis2 mediation framework).”

James Strachan

Page 9: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

So what is an

Enterprise Service Bus?

Page 10: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

A bus bus

Page 11: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Busbar

Page 12: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Bus

Page 13: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

“The original ESB”

Page 14: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Service Oriented Architecture

ESBESB

ProcessProcessManagementManagement PortalPortal Call CenterCall Center

ServiceService

ContractContract

ServiceService

ContractContract

ServiceService

ContractContract

Page 15: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

The ESB pattern?

Java

EJB

JMSJCA

JAX-RPC

JAX-WS

JAX-RPC

Page 16: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

The problem space

Java

EJB

JMSJCA

JAX-RPC

JAX-WS

JAX-RPC

SAPOracle

FinancialsCICS IMS DB2

B2B

Partner

Demerged

Systems

Merged

Systems

Page 17: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

The only common data model

Java

EJB

JMSJCA

JAX-RPC

JAX-WS

JAX-RPC

SAPOracle

FinancialsCICS IMS DB2

B2B

Partner

Demerged

Systems

Merged

Systems

<xml/>

Page 18: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Common interaction models

Java

EJB

JMSJCA

JAX-RPC

JAX-WS

JAX-RPC

SAPOracle

FinancialsCICS IMS DB2

B2B

Partner

Demerged

Systems

Merged

Systems

<soap:Envelope/><soap:Envelope/>

HTTP

Page 19: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Web Services model

• Connectivity – SOAP, MTOM, REST

• Routing

- WS-Addressing

• Description – WSDL, WS-Policy

• Security

- WS-Sec, WS-Trust, WS-SecureConversation

• Guaranteed delivery

- WS-Reliable Messaging

Page 20: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

JMSJ2EEJava

The Synapse pattern of an SOA

LegacySynapse

Boundary

Partner

Axis/C

SOAP

WSSec

WSRM

S S

.net

CICS

POX XML REST SOAP MTOM JSON

Axis2/Java JAXWSS Axis2/J

management

routing

transformation

validation

security

policy

DB2

SAP

IMS

Page 21: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Two approaches

Rul

es

<endpoint>

<sequence>

Page 22: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

What do you need to do?

• Connect

• Manage

• Transform

Page 23: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

A Web services mediation engine…

manage

JMX

route

transform

XSLT, E4X

POJOxpath regex

perf log

SOAP/HTTP

auth

java

validate

SOAP/JMS

MTOMRES

T/HTTP

XML/JMS

SOAP/WSS

SOAP/HTTPS

SOAP/WSS

Page 24: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

A lightweight infrastructure

Axis2

RM Addressing Security MTOM

SynapseLogging, routing, transformation, management, security

SynapseExtensions

<new xml>

SynapseExtensions

<new xml>

UserMediators

UserMediators

UserMediators

UserMediators

SynapseEnvironment API

Page 25: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Connect

• Route messages

• Based on XPath, Regex, etc

• Deal with mismatch

• Initiate/Terminate RM, WS-Sec

• Switch

• POX or REST to SOAP to JSON

• JMS to HTTP to SMTP

• Virtualisation

• Virtual URI to real URI mapping

Page 26: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Manage

• Logging

• Tracking – adding headers

• Authentication and Authorisation

• Schema validation

• Failover, retry and load-balancing

Page 27: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Transform

• XSLT

• JavaScript/E4X

• E4X is a simple mapping of XML directly into

JavaScript

• POJO

• JSON �� XML

Page 28: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Deployment models

req prov

HTTP Proxy

Gateway

SOAP

Intermediary

SOAP

Intermediary

SOAP

Intermediary

Synapse

Page 29: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Deployment• Transparent proxy

• Configure the client to use Synapse as a proxy

• Works with or without WS-Addressing headers

• Or use a “smart client” and set <wsa:To>

• Pure rule based model

• Gateway

• New “Proxy Services”

• Hosting virtual endpoints in Synapse

• Either simply direct to an endpoint or via a sequence

• Simple config of WSRM, WSSec

• Endpoint based model

Page 30: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Synapse User Guide

http://wiki.apache.org/ws/Synapse/SynapseUserGuide

Page 31: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

First rule of the Synapse Programming Model• “Don’t use the Synapse Programming Model”

• The aim of Synapse is to build in the common functions:• Log, route, modify headers, etc

• Engage QoS: WSS, WSRM, WSA, etc

• And use XML models:• XPath, XSLT, etc

• Configure the routing and transformation using a simple XML file

Page 32: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Synapse Config Language

<synapse><definitions><sequence>…</sequence><endpoint>…</endpoint>

<property>…</property>

…<definitions><rules>mediators</rules></synapse>

Page 33: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Sequences

• A chain of actions to take on a given

message

• The actions may be conditional

• Each sequence can have a name and be re-

used

Page 34: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Example<sequence name="stockquote">

<header name="To" value="http://ws.invesbot.com/stockquotes.asmx"/>

<filter xpath="//*[wsx:symbol='MSFT']" xmlns:wsx="http://www.webserviceX.NET/"><makefault>

<code value="tns:Receiver" xmlns:tns=“…"/>

<reason value="Isn't there a Windows API

for that?"/></makefault>

</filter>

<send/></sequence>

Page 35: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Endpoints

A simple local representation of a remote

endpoint

<endpoint

name="invesbot"

address=

"http://ws.invesbot.com/stockquotes.as

mx"

/>

Page 36: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Useful mediators• send

– Send on

• drop – Ditch the message

• log – log message

• makefault– Send a fault on or back

• transform– XSLT

• header– Set a header in the message

• filter – Do this if the XPath or Regex matches

• class – Call a user mediator

• validate – XSD validation

• switch– Conditional processing

Page 37: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Synapse Extensions

• Packaged as a JAR

• Uses dynamic discovery to register new XML elements

into the configuration model

• e.g.

• <spr:springmediator…>

• Allows users to use Spring to wire up a mediator

• <synxsl:xslt xsl=“url_to_xslt”/>

• Transforms messages using XSLT

• Extensions use the same programming model as User

mediators + XML-based factory

Page 38: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

User Mediators• Simple Java class that implements the Mediator interface:

boolean mediate(MessageContext mc);

true= continue processing

false= halt processing

Page 39: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Programming model (cont)

• MessageContext

• A representation of a SOAP infoset

• Routing model

• get/setTo, From, ReplyTo, FaultTo, MessageId etc

• get/setEnvelope()

• AXIOM representation

• isResponse(), isMTOM(), isRest()

• get/setProperties()

Page 40: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Status• Incubator in Apache since August

• All Apache Contributed code, core committer team, aiming to graduate

• M1 release – January 2006

• Core function, HTTP Proxy support, XSLT, XPath

• M2 release – June 2006

• Clean up of config language

• 0.90 release – soon! (we always say that)

• Proxy services

• Repackage as a MAR

• JavaScript/E4X support

Currently looking to Graduate from incubation

Page 41: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Getting involvedHomeWiki / Home site

• http://wiki.apache.org/ws/Synapse

• http://incubator.apache.org/synapse/

SVN

• https://svn.apache.org/repos/asf/incubator/synapse/trunk/java

Try it out

• http://incubator.apache.org/synapse/download/M2/download.cgi

• Submit bug reports

• http://issues.apache.org/jira/browse/SYNAPSE

Join us

[email protected]

Page 42: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Future

• 1.0 Focus:

• Support for WS-RM, WS-Sec

• Fault handling

• Support for remote registries

• Documentation, Usability

• We need your help to try it out and tell us what works

• The core model is also amenable to a

Synapse/C implementation

Page 43: paulfremantle - WSO2 | The Open Source Technology … POX XML REST SOAP MTOM JSON Axis2/Java S JAXWS Axis2/J management routing transformation validation security policy DB2 SAP IMS

Questions