SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects....

31
SOA Today with

Transcript of SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects....

Page 1: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

SOA Today with

Page 2: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Agenda

• SOA defined• Introduction to XFire• A JSR 181 Service• Other “stuff”• Questions

Page 3: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Service Oriented

1. to orient around services2. buzzword3. ...

Page 4: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Service oriented is NOT(but can be)

NEW

XML

Web Services

ESBs

[insert cool product here]

Page 5: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Service oriented is an architectual style

Page 6: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Loosely Coupled

NOT

Page 7: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Highly Interoperable

Built on standards Crosses boundaries

Page 8: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Service oriented is business oriented

Page 9: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

XFire

• Web Services for Java• Standards based: XML, SOAP, WSDL,

WS-*• Open Source (MIT license)• Easy to use:

– JSR181 – Spring support– Code->WSDL– WSDL->code

Page 10: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Architecture

• Streaming xml (StAX) • Pluggable bindings – POJOs, JAXB,

XMLBeans, Castor, Custom types• Multiple transports – HTTP, XMPP, JMS,

In-JVM transports – (and write your own easily via our Transport API!)

• Embeddable

Page 11: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Performance

• Traditional Web Services

Build Objects

Build DOM

Invoke Service

Build DOM

Write DOM

• Requires building two object representations– Document Object Model– Business domain objects

Page 12: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

XFire Performance

• Streaming Model

Invoke Service

Build objects from stream

Write objects to stream

• Builds domain objects directly from the XML stream

• Low latency and high throughput model• 2-5+x the throughput of Axis and 1/2-1/5

the latency

Page 13: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

XFire and JSR 181

• Easy code first deployment• Model service via annotations• Java 5 and Java 1.4 through commons-

attributes or Retroweaver

Page 14: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

The OrderService

@WebService

public interface OrderService

{

}

Page 15: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Our Operations

@WebMethodpublic Collection<Order> getOrders();

@WebMethodpublic long addOrder(Order o);

@WebMethodpublic void removeOrder(long id);

Page 16: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Our Operations Take 2

@WebMethod

@WebParam(name=“OrderId”)

public long addOrder(

@WebParam(name=“Order”) Order o);

Page 17: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Service Implementation

@WebService(

endpointInterface=“OrderService”,

serviceName=“OrderService”)

public class OrderServiceImpl

{

// implement operations here

}

Page 18: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Configure the Service

• A ServiceFactory creates a Service• A Service is registered in the

ServiceRegistry• XFireHttpServer creates a Jetty instance

configured for XFire• An XFireProxyFactory creates a proxied

Client

Page 19: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Create the Service

XFire xfire = XFireFactory.newInstance().getXFire();

AnnotationServiceFactory factory = new AnnotationServiceFactory( new Jsr181WebAnnotations(), xfire.getTransportManager());

Service service = factory.create(OrderServiceImpl.class);xfire.getServiceRegistry().register(service);

XFireHttpServer server = new XFireHttpServer();server.start();

Page 20: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Easy client

XFireProxyFactory xpf = new XFireProxyFactory();

OrderService service = (OrderService) xpf.create(model, OrderService.class);

service.getCustomers();

Page 21: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

The services.xml version

<beans>

<service>

<serviceFactory>jsr181</serviceFactory>

<serviceClass>OrderServiceImpl</serviceClass>

</service>

</beans>

Page 22: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

A “pure” Spring version

<import resource=“/org/codehaus/xfire/spring/xfire.xml”/>

<bean id=“orderService” class=“org.codehaus.xfire.spring.ServiceBean”> <property name=“serviceClass” value=“com.acme.OrderServiceImpl”/> <property name=“serviceFactory” ref=“jsr181”/></bean>

<bean id="webAnnotations" class="org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations"/>

<bean id=“jsr181 class=“org.codehaus.xfire.anotations.AnnotationServiceFactory”> <constructor-arg ref=“webAnnotations”> <constructor-arg ref=“xfire.transportManager”/></bean>

Page 23: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

A “pure” Spring version

<import resource=“/org/codehaus/xfire/spring/xfire.xml”/>

<bean id=“orderService” class=“org.codehaus.xfire.spring.ServiceBean”> <property name=“serviceClass” value=“com.acme.OrderServiceImpl”/> <property name=“serviceFactory” ref=“jsr181”/></bean>

<bean id="webAnnotations" class="org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations"/>

<bean id=“jsr181 class=“org.codehaus.xfire.anotations.AnnotationServiceFactory”> <constructor-arg ref=“webAnnotations”> <constructor-arg ref=“xfire.transportManager”/></bean>

Page 24: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

A “pure” Spring version

<import resource=“/org/codehaus/xfire/spring/xfire.xml”/>

<bean id=“orderService” class=“org.codehaus.xfire.spring.ServiceBean”> <property name=“serviceClass” value=“com.acme.OrderServiceImpl”/> <property name=“serviceFactory” ref=“jsr181”/></bean>

<bean id="webAnnotations" class="org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations"/>

<bean id=“jsr181 class=“org.codehaus.xfire.anotations.AnnotationServiceFactory”> <constructor-arg ref=“webAnnotations”> <constructor-arg ref=“xfire.transportManager”/></bean>

Page 25: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

A “pure” Spring version

<import resource=“/org/codehaus/xfire/spring/xfire.xml”/>

<bean id=“orderService” class=“org.codehaus.xfire.spring.ServiceBean”> <property name=“serviceClass” value=“com.acme.OrderServiceImpl”/> <property name=“serviceFactory” ref=“jsr181”/></bean>

<bean id="webAnnotations" class="org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations"/>

<bean id=“jsr181 class=“org.codehaus.xfire.anotations.AnnotationServiceFactory”> <constructor-arg ref=“webAnnotations”> <constructor-arg ref=“xfire.transportManager”/></bean>

Page 26: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Testing

• Test against your target platforms– .NET, PHP, Ruby, Perl, [fancy lang here]

• Record messages and play back• Use AbstractXFireAegisTest

– invokeService(serviceName, document)

Page 27: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Security

• Authentication – HTTP, WS-Security, Custom headers

• Authorization – Acegi, Custom code• Integrity – WS-Security• Privacy – HTTPS, JMS, WS-Security• Avoid WS-Security whenever possible. Its

dead slow.

Page 28: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Custom authentication

public void addOrder( @WebParam(header=true) AuthToken token, @WebParam Order order);

public class AuthToken { String username; String password; ….}

Page 29: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

SOA with XFire perspective

• Loosely Coupled – OrderService is independent of others

• Highly interopable – All you need is the WSDL

• Business oriented– Shares data across business boundaries

Page 30: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Where to now

• Use XFire Mapping files to control WSDL/XSD

• Do Schema/WSDL first with JAXB, XMLBeans or Castor for more control

• Hook up services to JMS or ServiceMix or Mule

• Write more services!• Investigate WS-* needs

Page 31: SOA Today with XFire - chariotsolutions.com file–Document Object Model –Business domain objects. XFire Performance •Streaming Model Invoke Service Build objects from stream Write

Questions? More Information:

• Web site: http://xfire.codehaus.org

• Mailing Lists: http://xfire.codehaus.org/Support

• My Blog: http://netzooid.com/blog• Commercial Support:

http://envoisolutions.com• Send email to [email protected] for

performance stats