SOA using Java Web Services and Ajax - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

SOA using Java Web Services and Ajax

Description:

... and eBay eBay WSDL Ant Task to Compile eBay WSDL Using the Generated eBay API A Client Binding Example public List offerSearch( String keywords, ... – PowerPoint PPT presentation

Number of Views:85
Avg rating:3.0/5.0
Slides: 25
Provided by: soabookCo
Category:
Tags: soa | ajax | java | services | using | web

less

Transcript and Presenter's Notes

Title: SOA using Java Web Services and Ajax


1
SOA using Java Web Services and Ajax
  • Mark D. Hansen
  • Author of SOA Using Java Web Services
  • http//soabook.com

2
Mark Hansens Background
  • Consultant, Entrepreneur, MIT PhD
  • Book and code examples at http//soabook.com
  • SOA-J open source project at http//soa-j.org

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 34 - 37
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
  • _at_WebService
  • public class Hello
  • public String sayHello(String s)
  • return "Hello " s
  • ltdefinitions ... targetNamespace"http//samples/"
    name"HelloService"gt
  • lttypesgt ... lt/typesgt
  • ltmessage name"sayHello"gt ... lt/messagegt
  • ltportType name"Hello"gt
  • ltoperation name"sayHello"gt
  • ltinput message"tnssayHello"/gt
  • ltoutput message"tnssayHelloResponse"/gt
  • lt/operationgt
  • lt/portTypegt
  • ltbinding name"HelloPortBinding"
    type"tnsHello"gt
  • ltsoapbinding ... /gt
  • ltoperation name"sayHello"gt ... lt/operationgt
  • lt/bindinggt
  • ltservice name"HelloService"gt
  • ltport name"HelloPort ...
  • lt/portgt
  • lt/servicegt
  • lt/definitionsgt

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
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 ListltOffergt offerSearch(
  • String keywords, Category category,
  • Price lowprice, Price highprice)
  • ShopperImp binding
  • BindingService.getBinding(
  • ShopperImp.class, EBayAPIInterface.clas
    s)
  • return
  • binding.offerSearch(keywords,
  • category, lowprice, highprice)

19
Implementing a Binding Service
  • public abstract class BindingService
  • public static ltCgt C getBinding(
  • ClassltCgt client, Classlt?gt service)
  • ...

20
Flash Demo
21
Using the Dojo Table Widget
  • lttable dojoType"filteringTable"
    id"fromSOAShopperData" multiple"true"
  • alternateRows"true" cellpadding"0"
    cellspacing"0" border"0"
  • style"margin-bottom24px"gt
  • lttheadgt
  • lttrgt
  • ltth field"source" dataType"String"gtSourcelt
    /thgt
  • ltth field"thumbnail" dataType"html"
    align"center"gtImagelt/thgt
  • ltth field"price" dataType"String"gtPricelt/t
    hgt
  • ltth field"summary" dataType"String"gtSummar
    ylt/thgt
  • ltth field"url" dataType"html"gtLinklt/thgt
  • lt/trgt
  • lt/theadgt
  • lt/tablegt

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 Erls SOA Book http//www.thomaserl.com/boo
    ks.asp
  • Ajax In Action http//www.manning.com/crane/
  • SOA-J open source project http//soa-j.org
Write a Comment
User Comments (0)
About PowerShow.com