Presentation is loading. Please wait.

Presentation is loading. Please wait.

SOA using Java Web Services and Ajax

Similar presentations


Presentation on theme: "SOA using Java Web Services and Ajax"— Presentation transcript:

1 SOA using Java Web Services and Ajax
Mark D. Hansen Author of “SOA Using Java Web Services”

2 Mark Hansen’s Background
Consultant, Entrepreneur, MIT PhD Book and code examples at SOA-J open source project at

3 Outline What is SOA? What are Web Services?
What are Java Web Services (JWS)? What is AJAX? How can you implement SOA with JWS and AJAX? Demo (eBay, Amazon, Yahoo!)

4 What is SOA? Loose coupling Service contract Autonomy Abstraction
Reusability Composability Statelessness Discoverability “Service-Oriented Architecture”, Thomas Erl, Chapter 3 pg

5 What is a Web Service? A provider that enables access to the service via either: SOAP XML / HTTP A description or contract that specifies the request/response message structure. WSDL XML Schema (insufficient) WADL (new)

6 What are Java Web Services (JWS)?
The provider is written in Java and deployed using a Java container. The consumer is written in Java. Java Web Service APIs are used: JAX-WS JAXB WS-Metadata (JSR-181) WSEE (JSR-109) JAX-RPC is deprecated starting in Java EE 5

7 Client Side JWS

8 Server Side JWS

9 JAX-WS Maps WSDL to a Java API
package samples; import javax.jws.WebService; @WebService public class Hello { public String sayHello(String s) { return "Hello: " + s; } <definitions ... targetNamespace=" name="HelloService"> <types> ... </types> <message name="sayHello"> ... </message> <portType name="Hello"> <operation name="sayHello"> <input message="tns:sayHello"/> <output message="tns:sayHelloResponse"/> </operation> </portType> <binding name="HelloPortBinding" type="tns:Hello"> <soap:binding ... /> <operation name="sayHello"> ... </operation> </binding> <service name="HelloService"> <port name="HelloPort“ ... </port> </service> </definitions>

10 JAXB Maps XML Schema to Java Classes

11 What is AJAX? Asynchronous JavaScript and XML An Interaction Model
A Set of Technologies for Rich Client Development ... A Composite Application Framework for Flexible Business Process Management ??? “Ajax In Action”, Dave Crane et al., Chapter 2 pg 33

12 SOA Using JWS and Ajax

13 SOAShopper Architecture

14 SOAShopper – Integrating Yahoo!, Amazon, and eBay
Demo SOAShopper – Integrating Yahoo!, Amazon, and eBay

15 eBay WSDL

16 Ant Task to Compile eBay WSDL

17 Using the Generated eBay API

18 A Client Binding Example
public List<Offer> offerSearch( String keywords, Category category, Price lowprice, Price highprice) { ShopperImp binding = BindingService.getBinding( ShopperImp.class, EBayAPIInterface.class); return binding.offerSearch(keywords, category, lowprice, highprice); }

19 Implementing a Binding Service
public abstract class BindingService { public static <C> C getBinding( Class<C> client, Class<?> service) { ... }

20 Flash Demo

21 Using the Dojo Table Widget
<table dojoType="filteringTable" id="fromSOAShopperData" multiple="true" alternateRows="true" cellpadding="0" cellspacing="0" border="0" style="margin-bottom:24px;"> <thead> <tr> <th field="source" dataType="String">Source</th> <th field="thumbnail" dataType="html" align="center">Image</th> <th field="price" dataType="String">Price</th> <th field="summary" dataType="String">Summary</th> <th field="url" dataType="html">Link</th> </tr> </thead> </table>

22 Invoking the REST Endpoint
function retrieveURL(url) { restURL = url; showSearchingMsg(restURL); if (window.XMLHttpRequest) { // Non-IE browsers req = new XMLHttpRequest(); req.onreadystatechange = processStateChange; try { req.open("GET", url, true); req.setRequestHeader('Content-type','text/xml'); } catch (e) { alert(e); } req.send(null); } else if (window.ActiveXObject) { // IE req = new ActiveXObject("Microsoft.XMLHTTP"); ...

23 Loading the Dojo Table function populateTableFromLiveSOAShopperData() { try { var w = dojo.widget.byId("fromSOAShopperData"); w.store.setData(theSOAShopperLiveData); } catch(e) { alert(e); }

24 Resources SOA Using Java Web Services http://soabook.com
Thomas Erl’s SOA Book Ajax In Action SOA-J open source project


Download ppt "SOA using Java Web Services and Ajax"

Similar presentations


Ads by Google