The document discusses how Flex applications can consume web services. It begins with an introduction to web services and the differences between SOAP/WSDL and REST approaches. It then demonstrates how to access and build applications using both SOAP and REST services from Flex at runtime and development time, including code generation. The document emphasizes that web services allow Flex to retrieve data for rich clients and provides examples consuming a SOAP video search service and REST del.icio.us API.
Generative Artificial Intelligence: How generative AI works.pdf
Flex 3 & Webservices: Building Rich Clients with SOAP and REST APIs
1. Flex 3 & Webservices
Cristian Ivascu :: Adobe
360 Flex, Milan
08 – APR - 2008
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
1
2. Agenda
Introduction to Flex and web services
Building a SOAP-based app
REST services
Building a del.icio.us based app
Q&A
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
2
3. One server, multiple, disparate clients
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
3
4. What are webservices?
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
Practice matters!
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
4
5. Web services – which one?
SOAP & WSDL
Verbose
Machine usable
Enterprise
REST
Light-weight
No encoding
popular!
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
5
6. Flex and Webservices
Flex creates rich clients;
Web services bring data to the client
Flex works with web services in an easy manner
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
6
7. WSDL sample - VideoSearch
•
Only one operation
•
Simple request parameters
•
Slightly complex response
•
Link: http://localhost/video.wsdl
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
7
8. How to access the service?
At runtime
At development time (via tool support)
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
8
9. Runtime Demo
Let’s see it in the Builder!
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
9
10. 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
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
10
12. 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
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
12
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.
13
14. Generated code – is this spaghetti?
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
14
15. How to find and fix problems
Check if the schema is there
Breakpoints in call() and processResult()
Check type mappings & wsdl type
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
15
16. 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
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
16
17. REST
Can use multiple output formats – XML, JSON, etc
Is very light-weight
Pro: performance
Con: there is no typing info!
Is very popular
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
17
18. 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
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
18
19. 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-an
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
19
20. 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
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
20
22. This is (almost) the last slide
•
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() .
Copyright 2008 Adobe Systems Incorporated. All rights reserved.
22