Web Services

From sheep
Jump to navigation Jump to search

Web Services

References

Jboss users guide to web services http://www.jboss.org/jbossws/docs/jaxws_userguide-2.0/index.html

Definitions

URI - uniform resource identifier both below are URIs URN - uniform resource name e.g. urn:luminoussheep URL - uniform resource locater - resolvable address e.g. http://luminousheep.net

Components

  1. service provider - WSDL
  2. consumer
  3. service broker - UDDI
  • WSDL describes service
    • what operations
    • where to find it, how to communicate - protocol (portType)
    • format,encoding of messages (binding)
  • UDDI advertises service
    • tModel (technical model) - describes abstract resource - points to WSDL
    • Categorises by service type
  • SOAP communication mechanism

Separating the what from the how and where allows different service providers to be used with ease

UDDI

  1. supplier specific information such as company, address
  2. categorisation information
  3. technical service implementation information - binding template

uses

  • connects disparate systems - different platforms - OS and language
    • use in heterogeneous environments supports all languages, all platforms
    • useful where no control over clients
  • useful for supporting different display interfaces - web/mobile/desktop
  • dynamic conditions - easy to update
  • aggregating information - portals, customer care, collaboration
    • multi channel - rich clients - IVR (interactive voice response)
  • reduce redundancy - can be used to centralise services


  • no component model - no framework
  • overhead - performance - can introduce scaling issues
  • not a replacement in itself for ESB (extract, aggregate, transform, route)
  • better off using native communication for local apps

Reference http://www.oracle.com/technology/sample_code/tech/java/j2ee/jintdemo/tutorials/webservices.html


SOAP

  • Envelope wrapping a Header and Body
  • Header - system level information such as security, transaction context, message correlation, session id - optional
  • Body - payload - required

Can be routed though intermediaries that operate transparently performing logging/authentication/decryption

RPC

  • provides name of procedure to invoke
  • encoding can be defined by xsd or SOAP Encoding - SOAP Encoding definition is lacking - may have interoperability issues
  • tightly coupled - WSDL defines sending and return parameters
  • synchronous

Document-style

  • literal encoding - format specified by xsd
  • loosely coupled - document driven - parameters sent as a document (instead of a set of parameters)
  • contents of message determine how to process
  • may be synchronous or asynchronous

Static invocation

  • stubs generated from WSDL
  • WSDL doesn't need to be parsed each time

Dynamic invocation

  • clients generated at runtime
    • dynamic proxy - dynamic binding
  • changes to WSDL do not break the client

MTOM

Message Transmission Optimization Mechanism http://en.wikipedia.org/wiki/MTOM method of efficiently sending binary data to and from web services. It uses XOP (XML-binary Optimized Packaging) Replaces MIME and DIME

  • WSDL interface now contains the binary definition
  • MTOM may be used in a document literal wrapped WSDL
  • MTOM doesn't force attachments as Soap with attachments does

RESTful Web Services

JAX-WS support REST but REST isn't good for tooling Sun's WADL technical report https://wadl.dev.java.net/ Web Application Description Language (WADL)] is an attempt to solve the tooling problem. jax-ws and REST intro to REST

  • everything (object you want to expose should have an id)
  • HATEOAS Hypermedia as the engine of application state
    • use of links to move an application from one state to another
    • deliver the representation as a (resource graph) tree of links that enable access/state changes to the resource - enable discovery from an initial point
  • GET
    • retrieve - idempotent (same result when repeated)
  • PUT
    • update - idempotent
  • DELETE
    • destroy - idempotent
  • POST
    • create - not idempotent
  • create urls for operations to allow more object methods to map to these four HTTP methods

Triangle representing how urls can be constructed

       Data Types
       /        \
Operations -- Instances

State should not need to be part of a conversation. i.e. each request should be stateless in the context of the previous request.

No service definition for RESTful service i.e. no WSDL equivalent exists

Can use jaxb or jaxp see jaxb REST blog

Example: Suns cloud REST interface

EBXML

  • Not widely adopted
  • Uses attachments for payload, not defined in the same self describing way as wsdl
    • requires endpoints know and understand the ebMS SOAP extensions
  • Adds security, reliability
  • includes a repository unlike uddi