flex360 milan 2008 - flex & webservices
DESCRIPTION
The presentation on Flex Builder's integration with SOAP webservices. Presented in 2008 at Flex360 MilanTRANSCRIPT
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Flex 3 & Webservices
Cristian Ivascu :: Adobe360 Flex, Milan08 – APR - 2008
1
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Agenda
Introduction to Flex and web services Building a SOAP-based app REST services Building a del.icio.us based app Q&A
2
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
One server, multiple, disparate clients
3
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
What are webservices?
Practice matters!
4
W3C says: “a software system designed to support interoperable Machine to Machine interaction over a network” (W3C)
In practice:web apis that are accessed remotely
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Web services – which one?
SOAP & WSDL Machine usable Verbose Enterprise
REST Light-weight No encoding popular!
5
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Flex and Webservices
Flex creates rich clients; Web services bring data to the client Flex works with web services in an easy
manner
6
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
WSDL sample - VideoSearch
• Only one operation• Simple request parameters• Slightly complex response
• Link: http://localhost/video.wsdl
7
Copyright 2008 Adobe Systems Incorporated. All rights reserved. 8
How to access the service?
At runtime At development time (via tool support)
Copyright 2008 Adobe Systems Incorporated. All rights reserved. 9
Runtime Demo
Let’s see it in the Builder!
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
When to use it• Dynamic scenarios• Discovery of services at run-time• Services that may change more often
Characteristics• Not tied to a particular implementation• Very flexible• Adapts easily to changes, without messing with the code
10
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
What about this?
11
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Dev-time way
Why?• For the more static scenarios – build and forget• For increased productivity• To make it easier
How?• Added classes to model the wsdl contents• Added a way to link types in wsdl to AS classes• Tool support & code generation
12
Copyright 2008 Adobe Systems Incorporated. All rights reserved. 13
Video Search Demo redone
The same Video Searching app re-done to take advantage of the new features.,
Let’s see how it’s made.
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Generated code – is this spaghetti?
14
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
How to find and fix problems
Check if the schema is there Breakpoints in call() and processResult() Check type mappings & wsdl type
15
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Known issues with the generated code
We don’t support everything – only WS-I 1.0 profile; wsdl 1.0 & soap 1.1
Known issues – there are a few Have one? Report it @ bugs.adobe.com/flex
16
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
REST
Can use multiple output formats – XML, JSON, etc
Is very light-weight Pro: performance Con: there is no typing info!
Is very popular
17
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Flex & Rest services
They haven’t change much AS allows manipulation of XML and binding to objects But there’s a catch – httpservice.xmlDecode() + a custom
model
18
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
DEMO – del.icio.us API usage
xmlDecode to convert raw xml into an array of “Post.as” instances
There is also a more generic approach – using SimpleXMLDecoder & ObjectTranslator
http://booleanbetrayal.com/2007/05/18/httpservice-xmldecode-objecttranslator-and-rabidsquirrels/
19
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Flex | Final words of wisdom
Web services are a way of getting data into your Flex app; When building rich clients you need to use them Web services in Flex can be better; for suggestions or bugs
visit: bugs.adobe.com/flex
20
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Q & A
21
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
• Flex can cope with both dynamic and strong-typed web service usage.• The wizard only generates some code for you. Tweak it!• Strong types are not for WSDL only. Use XMLDecode() .
This is (almost) the last slide
22
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
Go play!
http://adobe.com/go/flex
…and off to lunch! Buon appetito!
23