Upload
kriszyp
View
9.018
Download
2
Tags:
Embed Size (px)
DESCRIPTION
Citation preview
JSON SOA-based Client/Server Application
Development
Kris Zyp
© SitePen, Inc. 2008. All Rights Reserved
© SitePen, Inc. 2008. All Rights Reserved
Overview
SOA on the webService Method Description for defining servicesDojo based approach to SOA
© SitePen, Inc. 2008. All Rights Reserved
SOA-Based Client/Server Model
Distribution of ProcessingUser response latencyProgramming modelVector of attackState management on server vs clientOffline capabilitiesInteroperability
© SitePen, Inc. 2008. All Rights Reserved
Service Oriented Architecture on the Web
Web Service ProviderWeb Service Provider
CS Web CS Web ClientClient
Methods
Web Web ClientClient
Methods
Desktop Desktop ClientClient
Methods
© SitePen, Inc. 2008. All Rights Reserved
Service Mapping Description
JSON-based service definition structureDefines
TransportParametersExpected ResponseDescription
Clients can use an SMD to build methods to auto-connect to endpoints
© SitePen, Inc. 2008. All Rights Reserved
Service Types
RESTJSONPPlain GETFull read/write (PUT, POST, DELETE)
RPCJSON-RPC
Different URL forms/path/id?name=value
© SitePen, Inc. 2008. All Rights Reserved
Dojo Includes SMDs for major web servicesSMDs for third party services
WikipediaYahooWikipedia
Web services can advertise their services
© SitePen, Inc. 2008. All Rights Reserved
Dojo Support for SOA
© SitePen, Inc. 2008. All Rights Reserved
Services
© SitePen, Inc. 2008. All Rights Reserved
var services = new dojox.rpc.Service("/mySMD");
or
var services = new dojox.rpc.Service({
transport:”REST”,
services:{
newsService:{...}
}
});
services.newsService({query:"dojo"}.
addCallback(function(returnValue) {
alert("A news item: " + returnValue[0]);
});
var services = new dojox.rpc.Service("/mySMD");
or
var services = new dojox.rpc.Service({
transport:”REST”,
services:{
newsService:{...}
}
});
services.newsService({query:"dojo"}.
addCallback(function(returnValue) {
alert("A news item: " + returnValue[0]);
});
Example of Service Auto-Generation
© SitePen, Inc. 2008. All Rights Reserved
Dojo Data
© SitePen, Inc. 2008. All Rights Reserved
http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/grid/tests/test_yahoo_search.htmlhttp://www.sitepen.com/blog/2008/06/25/web-service-data-store/
ServiceStore
Adapts web services to dojo.data APIPlug services directly into widgetsSupports lazy loading
© SitePen, Inc. 2008. All Rights Reserved
Read/Write (Real) REST Services
Full REST Services can plugin for full read/write ORM-style functionality:
GET - query and get by idPUT - update an objectPOST - create an objectDELETE - delete an object
© SitePen, Inc. 2008. All Rights Reserved
schema:
{"description":"A person",
"type":"object",
"properties":
{"name": {"type":"string"},
"age" : {"type":"integer",
"maximum":125}}
}
instance:
{“name”:”Kris”,
"age":31}
schema:
{"description":"A person",
"type":"object",
"properties":
{"name": {"type":"string"},
"age" : {"type":"integer",
"maximum":125}}
}
instance:
{“name”:”Kris”,
"age":31}
JSON Schema
© SitePen, Inc. 2008. All Rights Reserved
JSON Referencing
• Hyperlinking appplied to JSON
• Cyclic
• Multiple references
• Cross-message references
• Cross-site references
© SitePen, Inc. 2008. All Rights Reserved
JsonRestStore
Full Read/Write APICreate, Read/Query, UpdateDelete
Standards Based (HTTP compliant)
© SitePen, Inc. 2008. All Rights Reserved
Accompanied by Demo
JsonRestStore
Lazy loadingJSON ReferencingJSON SchemaTransactionalOffline Support
© SitePen, Inc. 2008. All Rights Reserved
Push/Comet
Open Protocols for CometBayeuxXMPPREST Channels
© SitePen, Inc. 2008. All Rights Reserved
Bayeux
• Service Negotiation
• Publish/Subscribe Protocol
© SitePen, Inc. 2008. All Rights Reserved
REST Channels
• REST Based Push Protocol
• Based on HTTP standard semantics
© SitePen, Inc. 2008. All Rights Reserved
HTTP/1.1 200 OK
X-Event: PUT
Content-Location: /foo/bar
New content of /foo/bar
HTTP/1.1 200 OK
X-Event: PUT
Content-Location: /foo/bar
New content of /foo/bar
HTTP Channels (REST Channels over HTTP)
© SitePen, Inc. 2008. All Rights Reserved
Accompanied by Demo
{
“event”: “put”
“source”: “/foo/bar”
“content”: “New content of /foo/bar”
}
{
“event”: “put”
“source”: “/foo/bar”
“content”: “New content of /foo/bar”
}
REST Channels in JSON
© SitePen, Inc. 2008. All Rights Reserved
Offline + REST
• REST + Thin Server = Easy Offline
• Dojo’s support for Offline SOA Applications
© SitePen, Inc. 2008. All Rights Reserved
Security in SOA
• Security clearly distinct from UI code
• Assume users are directly accessing services
• Improved isolation of security
© SitePen, Inc. 2008. All Rights Reserved
The browser is the platform of mashups
• Neutral ground, browser acts as a deputy/mediator
• JSON is the foundation for more complex data/code integration
• Cross-site mashup techniques emerging
http://www.sitepen.com/blog/2008/09/25/security-in-ajax/
© SitePen, Inc. 2008. All Rights Reserved
Dojo Secure
Full framework for secure mashups Secure cross-site loading registry Adsafe style code validation Safe set of library functions Safe access to the DOM
http://www.sitepen.com/blog/2008/08/01/secure-mashups-with-dojoxsecure/
© SitePen, Inc. 2008. All Rights Reserved
http://www.sitepen.com/blog/2008/07/18/clientserver-model-on-the-web/
Characteristics of good client/server application
• Clean Web API
• Interchangeability
• Presentation on the client
• Business logic on the server
© SitePen, Inc. 2008. All Rights Reserved
Dojo’s SOA
• Service auto configuration
• Integration into Dojo Data model
• Full REST interaction support
• Comet and Offline capabilities
• All based on standards or emerging conventions, easy to switch to something else
© SitePen, Inc. 2008. All Rights Reserved
The Open Web is more than just licensing
© SitePen, Inc. 2008. All Rights Reserved
My other presentation
Applied JSON: REST, Ajax Databases
© SitePen, Inc. 2008. All Rights Reserved