SlideShare une entreprise Scribd logo
1  sur  58
Télécharger pour lire hors ligne
New	
  Flash	
  Builder	
  4	
  WSDL	
  and	
  
HTTP	
  Connectors	
  
	
  
Java	
  SDK:	
  
	
  
To	
  run	
  a	
  Tomcat	
  server,	
  you	
  must	
  download	
  a	
  Java	
  SDK	
  and	
  
setup	
  a	
  JAVA_HOME	
  environmental	
  variable.	
  
	
  
Windows:	
  
	
  
   • Right click on the My Computer icon on your desktop and select
     properties
   • Click the Advanced Tab
   • Click the Environment Variables button
   • Under System Variable, click New
   • Enter the variable name as JAVA_HOME
   • Enter the variable value as the install path for the Development Kit
     (Ex: C:j2sdk1.4.2)
   • Click OK
   • Click Apply Changes
 
	
  
MAC	
  OS	
  X	
  
	
  
  •   Open Terminal.
  •   First confirm you have JDK by typing “which java”. It should show
      something like /usr/bin/java.
  •   Check you have the needed version of Java, by typing “java -version”.
      My setup shows java version “1.5.0_13″
  •   JAVA_HOME is essentially the full path of the directory that contains
      a sub-directory named bin which in turn contains the java.
  •   For Mac OSX – it is /Library/Java/Home (There are other
      directories too, but this is the simplest!)
•   Set JAVA_HOME using this command in Terminal: export
           JAVA_HOME=/Library/Java/Home
       •   echo $JAVA_HOME on Terminal to confirm the path
       •   You should now be able to run your application

	
  
Start	
  the	
  Server:	
  
	
  
Before	
  we	
  can	
  use	
  Flash	
  Builder	
  to	
  access	
  our	
  services,	
  we	
  
need	
  to	
  start	
  up	
  the	
  Tomcat	
  server.	
  To	
  do	
  so	
  please	
  follow	
  
the	
  steps	
  below:	
  
	
  
WINDOWS:	
  
Open	
  console	
  window	
  and	
  navigate	
  to	
  your	
  BlazeDS	
  install	
  
directory:	
  
	
  
	
  cd	
  <BlazeDS	
  Root>BlazeDStomcatbin	
  
Now	
  enter	
  cataina	
  run	
  to	
  start	
  up	
  the	
  Tomcat	
  server.	
  




                                                                                                  	
  
	
  
	
  
MAC:	
  
	
  
Open	
  terminal	
  window.	
  Navigate	
  to	
  your	
  install	
  directory,	
  
in	
  my	
  case	
  it	
  is	
  located	
  in	
  my	
  Applications	
  folder:	
  
	
  
	
  cd	
  	
  <BlazeDS	
  Root>/BlazeDS/tomcat/bin	
  
Now	
  enter	
  ./startup.sh	
  to	
  start	
  up	
  the	
  Tomcat	
  server.	
  




                                                                                          	
  
	
  
TEST	
  the	
  Server:	
  
Test	
  to	
  make	
  sure	
  your	
  server	
  is	
  running	
  by	
  opening	
  a	
  
browser	
  and	
  navigating	
  to:	
  
http://localhost:8400/xml/Wines.xml	
  
http://localhost:8400/json/Wines.json	
  
http://localhost:8400/axis/MyWebService.jws?wsdl	
  
http://localhost:8400/crossdomain.xml	
  
Notice	
  the	
  last	
  of	
  the	
  URL’s	
  listed	
  above	
  is	
  titled	
  
crossdomain.xml.	
  This	
  file	
  is	
  required	
  for	
  the	
  FlashPlayer	
  to	
  
access	
  data	
  services	
  hosted	
  on	
  remote	
  domains.	
  	
  How	
  does	
  
it	
  work?	
  
When	
  a	
  Flash	
  document	
  attempts	
  to	
  access	
  data	
  from	
  another	
  
domain,	
  Flash	
  Player	
  automatically	
  attempts	
  to	
  load	
  a	
  policy	
  
file	
  from	
  that	
  domain.	
  If	
  the	
  domain	
  of	
  the	
  Flash	
  document	
  
that	
  is	
  attempting	
  to	
  access	
  the	
  data	
  is	
  included	
  in	
  the	
  policy	
  
file,	
  the	
  data	
  is	
  automatically	
  accessible.	
  
Policy	
  files	
  must	
  be	
  named	
  crossdomain.xml,	
  and	
  can	
  reside	
  
either	
  at	
  the	
  root	
  directory	
  or	
  in	
  another	
  directory	
  on	
  the	
  
server	
  that	
  is	
  serving	
  the	
  data	
  with	
  some	
  additional	
  
ActionScript.	
  Policy	
  files	
  function	
  only	
  on	
  servers	
  that	
  
communicate	
  over	
  HTTP,	
  HTTPS,	
  or	
  FTP.	
  The	
  policy	
  file	
  is	
  
specific	
  to	
  the	
  port	
  and	
  protocol	
  of	
  the	
  server	
  where	
  it	
  
resides.	
  	
  
	
  	
  	
  
A	
  very	
  simplified	
  example	
  of	
  a	
  crossdomain.xml	
  file	
  is:	
  
<cross-­‐domain-­‐policy>	
  
<allow-­‐access-­‐from	
  domain="*"/>	
  
<site-­‐control	
  	
  
        permitted-­‐cross-­‐domain-­‐policies="master-­‐only"/>	
  
</cross-­‐domain-­‐policy>	
  
For	
  more	
  information	
  on	
  crossdomain.xml	
  please	
  visit:	
  
http://www.adobe.com/devnet/articles/crossdomain_poli
cy_file_spec.html	
  
	
  
Lab	
  0:	
  Creating	
  a	
  Flash	
  Builder	
  Project	
  
	
  
We	
  will	
  be	
  creating	
  multiple	
  Flash	
  Builder	
  projects	
  within	
  
this	
  lab,	
  so	
  before	
  we	
  start	
  integrating	
  data,	
  lets	
  create	
  our	
  
first	
  Flash	
  Builder	
  project.	
  
	
  
Step	
  1:	
  Create	
  a	
  new	
  Flash	
  Builder	
  project	
  
	
  	
   Select	
  File	
  >	
  New	
  Flex	
  Project	
  from	
  the	
  main	
  menu	
  
	
  




                                                                                                   	
  
	
  
Title	
  the	
  project	
  Lab1	
  and	
  choose	
  Web	
  (runs	
  in	
  Adobe	
  
Flash	
  Player)	
  within	
  the	
  Application	
  type.	
  
	
  
Set	
  the	
  Application	
  server	
  type	
  to	
  J2EE	
  and	
  select	
  the	
  
BlazeDS	
  radio	
  button	
  and	
  click	
  Next.	
  
	
  
 
Click	
  Next	
  and	
  fill	
  in	
  the	
  necessary	
  information	
  to	
  connect	
  
to	
  your	
  BlazeDS	
  server.	
  Note	
  that	
  your	
  Root	
  folder	
  may	
  be	
  
different	
  than	
  what	
  is	
  shown	
  below.	
  	
  
	
  
In	
  my	
  case	
  the	
  Root	
  folder	
  is	
  
/Applications/BlazeDS/tomcat/webapps/blazeds	
  and	
  the	
  
Root	
  URL	
  is	
  http://localhost:8400/blazeds	
  and	
  the	
  Context	
  
root	
  is	
  /blazeds.	
  Click	
  Validate	
  Configuration.	
  
 
Now	
  click	
  Finish.	
  
	
  
	
  
	
  
	
  
	
  
Lab	
  1:	
  Code	
  View	
  	
  
(MXML	
  and	
  AS3	
  to	
  get	
  REST	
  Data)	
  
	
  
Section	
  1:	
  Connect	
  to	
  data	
  using	
  MXML	
  
	
  
Open	
  the	
  project	
  created	
  above	
  named	
  Lab1.	
  
	
  
To	
  define	
  the	
  service,	
  we	
  need	
  to	
  add	
  an	
  <fx:Declarations>	
  
block	
  to	
  wrap	
  the	
  HTTPService.	
  Note:	
  this	
  is	
  something	
  that	
  
is	
  new	
  to	
  Flex	
  4.	
  Within	
  the	
  declarations	
  nested	
  tags,	
  you	
  
will	
  notice	
  the	
  <mx:HTTPService/>	
  tag.	
  This	
  tag	
  defines	
  the	
  
service	
  operation.	
  The	
  attributes	
  define	
  the	
  id,	
  expected	
  
result	
  format,	
  URL	
  of	
  the	
  service,	
  whether	
  or	
  not	
  to	
  use	
  the	
  
proxy	
  (more	
  on	
  this	
  later),	
  and	
  the	
  callback	
  functions	
  for	
  
successful	
  or	
  failed	
  operations.	
  
	
  
<fx:Declarations>
     <mx:HTTPService
           id="wines"
           resultFormat="e4x"
           url="http://localhost:8400/xml/Wines.xml"
           useProxy="false"
           result="parseXML(event)"
           fault="trace(event.fault)"/>
</fx:Declarations>	
  
	
  
Next,	
  add	
  the	
  <fx:Script>	
  block	
  defined	
  below.	
  
	
  
<fx:Script>
     <![CDATA[
           import mx.collections.XMLListCollection;
           import mx.rpc.events.ResultEvent;
           private function parseXML(event:ResultEvent):void{
                var xml:XML = event.result as XML;
                dg.dataProvider = xml["Vintage"];
}
     ]]>
</fx:Script>
	
  
If	
  you	
  look	
  at	
  the	
  script	
  block	
  above	
  you	
  will	
  notice	
  the	
  
parseXML()	
  function.	
  This	
  is	
  the	
  callback	
  function	
  that	
  we	
  
previously	
  discussed	
  which	
  will	
  parse	
  out	
  the	
  XML	
  that	
  is	
  
returned	
  on	
  a	
  successful	
  service	
  call.	
  
	
  
Finally	
  we	
  need	
  some	
  UI	
  elements	
  to	
  trigger	
  the	
  call	
  and	
  to	
  
display	
  the	
  data.	
  Add	
  the	
  component	
  declarations	
  below	
  to	
  
your	
  application.	
  
	
  
<mx:VBox horizontalCenter="0">
     <mx:DataGrid id="dg">
               <mx:columns>
                    <mx:DataGridColumn headerText="Vintner"
                               dataField="Vintner" />
                    <mx:DataGridColumn headerText="Name"
                               dataField="Name" />
                    <mx:DataGridColumn headerText="Vintage"
                               dataField="Vintage" />
                    <mx:DataGridColumn headerText="ParkerNotation"
                               dataField="ParkerNotation" />
                    <mx:DataGridColumn headerText="Price"
                               dataField="Price" />
               </mx:columns>
     </mx:DataGrid>
     <mx:HBox>
               <s:Button click="wines.send()"
                    label="Get Wines MXML"/>
     </mx:HBox>
</mx:VBox>	
  
	
  
Examining	
  the	
  code	
  above	
  you	
  will	
  notice	
  that	
  we	
  have	
  a	
  
DataGrid	
  with	
  an	
  id	
  of	
  dg	
  that	
  contains	
  five	
  columns	
  that	
  
match	
  the	
  XML	
  nodes.	
  There	
  is	
  also	
  a	
  Button	
  that	
  is	
  used	
  to	
  
trigger	
  the	
  wines	
  service.	
  
 
Save	
  you	
  file	
  and	
  run	
  the	
  application	
  and	
  you	
  should	
  see	
  
the	
  following	
  after	
  clicking	
  the	
  Get	
  Wines	
  button.	
  
	
  




	
  	
  
Section	
  2:	
  Connect	
  to	
  data	
  using	
  AS3	
  
	
  
In	
  Section	
  1	
  of	
  Lab	
  1	
  we	
  utilized	
  MXML	
  to	
  call	
  our	
  service,	
  
we	
  can	
  also	
  call	
  the	
  service	
  using	
  ActionScript.	
  	
  
	
  
Add	
  the	
  function	
  below	
  to	
  the	
  <fx:Script>	
  block	
  of	
  Lab1.	
  
	
  
private function getWines():void{
     var service:HTTPService = new HTTPService();
     service.resultFormat = "e4x";
     service.url="http://localhost:8400/xml/Wines.xml";
     service.useProxy=false;

           service.addEventListener(ResultEvent.RESULT,parseXML);
           service.send();
}


Notice	
  that	
  we	
  have	
  many	
  of	
  the	
  same	
  properties	
  set	
  as	
  
were	
  declared	
  within	
  the	
  MXML	
  component.	
  By	
  setting	
  the	
  
event	
  listener	
  for	
  the	
  successful	
  call,	
  we	
  are	
  able	
  to	
  reuse	
  
the	
  parseXML()	
  function.	
  	
  
	
  
Now,	
  simply	
  add	
  a	
  few	
  buttons	
  below	
  the	
  Get	
  Wines	
  MXML	
  
to	
  call	
  the	
  getWines()	
  function	
  and	
  clear	
  the	
  data	
  button:	
  
<s:Button click="getWines()" label="Get Wines AS3"/>
<s:Button click="dg.dataProvider=null" label="Clear Datagrid"/>


Save	
  your	
  file,	
  run	
  the	
  project,	
  and	
  click	
  on	
  the	
  new	
  Get	
  
Wines	
  AS3	
  button	
  and	
  you	
  should	
  see	
  the	
  results	
  shown	
  
below.	
  
	
  




                                                                                                 	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
Lab	
  2:	
  Code	
  View	
  	
  
(MXML	
  and	
  AS3	
  to	
  get	
  WSDL	
  Data)	
  
	
  
Create	
  a	
  new	
  project	
  named	
  Lab2	
  (as	
  demonstrated	
  
previously	
  in	
  Lab0)	
  
	
  
Add	
  the	
  following	
  declarations	
  tag	
  to	
  define	
  the	
  connection	
  
to	
  the	
  WSDL:	
  
<fx:Declarations>
<mx:WebService
     id="myWebService"
     wsdl="http://localhost:8400/axis/MyWebService.jws?wsdl"
     useProxy="false"
     result="parseResult(event)"
     fault="trace(event.fault)"/>
</fx:Declarations>	
  
	
  
Next	
  add	
  a	
  script	
  block	
  below	
  the	
  declarations	
  block	
  to	
  
handle	
  the	
  service	
  result.	
  
	
  
<fx:Script>
     <![CDATA[
     import mx.rpc.events.ResultEvent;
     private function parseResult(event:ResultEvent):void{
           lbl.text = event.result as String;
     }
     ]]>
</fx:Script>


Finally,	
  add	
  a	
  Label	
  component	
  to	
  display	
  the	
  service	
  
results.	
  
	
  
<mx:Label id="lbl" fontSize="36"
           creationComplete="myWebService.hello()"
           horizontalCenter="0"
           verticalCenter="0"/>
 
Run	
  the	
  project	
  and	
  you	
  should	
  see	
  the	
  message	
  shown	
  
below:	
  
	
  



                                                  	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
Lab	
  3:	
  Design	
  View	
  	
  
(Using	
  Flash	
  Builder	
  to	
  get	
  REST	
  data)	
  
Now	
  that	
  we	
  have	
  looked	
  at	
  several	
  ways	
  to	
  connect	
  to	
  data	
  
services,	
  lets	
  take	
  a	
  look	
  at	
  how	
  the	
  new	
  Flash	
  Builder	
  
tooling	
  creates	
  data	
  connections.	
  	
  
	
  
Create	
  a	
  new	
  project	
  named	
  Lab3	
  (as	
  demonstrated	
  
previously	
  in	
  Lab0)	
  
	
  
Next,	
  click	
  on	
  the	
  Connect	
  to	
  Data	
  /	
  Services	
  link	
  within	
  the	
  
Data	
  /	
  Services	
  view.	
  
	
  




                                                                                          	
  
	
  
Select	
  HTTPService	
  from	
  the	
  New	
  Flex	
  Service	
  window.	
  
	
  
 
Click	
  Next	
  and	
  you	
  will	
  see	
  the	
  Configure	
  HTTP	
  Service	
  
form.	
  
	
  
Enter	
  getWines	
  for	
  the	
  Operation	
  name	
  and	
  
http://localhost:8400/xml/Wines.xml	
  for	
  the	
  URL	
  within	
  the	
  
Operations	
  Grid.	
  Then	
  enter	
  WinesService	
  for	
  the	
  Service	
  
Name	
  and	
  click	
  Finish.	
  
	
  




                                                                                       	
  
You	
  should	
  now	
  see	
  the	
  new	
  service	
  defined	
  within	
  the	
  
Data	
  /	
  Services	
  view.	
  
	
  
 
	
  
Switch	
  your	
  project	
  to	
  Design	
  View	
  and	
  drag	
  a	
  DataGrid	
  
component	
  from	
  the	
  Components	
  view	
  onto	
  the	
  stage.	
  
	
  
Right	
  click	
  on	
  the	
  DataGrid	
  component	
  and	
  select	
  Bind	
  To	
  
Data.	
  
	
  




                                                                                          	
  
	
  
The	
  Bind	
  To	
  Data	
  window	
  will	
  open.	
  
	
  
 
	
  
Before	
  you	
  can	
  select	
  the	
  service,	
  you	
  need	
  to	
  configure	
  the	
  
return	
  type.	
  Click	
  on	
  the	
  Configure	
  Return	
  Type	
  button	
  and	
  
the	
  Configure	
  Operation	
  Return	
  Type	
  window	
  will	
  open.	
  	
  
	
  
 
Leave	
  the	
  radio	
  button	
  set	
  to	
  Auto	
  detect	
  and	
  click	
  Next.	
  
	
  
In	
  Step	
  2,	
  leave	
  the	
  radio	
  button	
  set	
  to	
  Enter	
  parameter	
  
values	
  and	
  click	
  Next.	
  
	
  
 
Within	
  Step	
  3,	
  select	
  Vintage	
  from	
  the	
  Select	
  Node	
  drop	
  
down	
  menu	
  and	
  click	
  Finish.	
  
	
  
 
	
  
Now	
  click	
  OK	
  to	
  close	
  the	
  Bind	
  To	
  Data	
  window	
  and	
  you	
  
should	
  see	
  the	
  DataGrid	
  now	
  has	
  the	
  column	
  names	
  
defined.	
  
	
  
 
Run	
  the	
  project	
  and	
  you	
  will	
  see	
  your	
  data!	
  
	
  




                                                                          	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
Lab	
  4:	
  Design	
  View	
  	
  
(Using	
  Flash	
  Builder	
  to	
  get	
  WSDL	
  data)	
  
	
  
Create	
  a	
  new	
  project	
  named	
  Lab4	
  (as	
  demonstrated	
  
previously	
  in	
  Lab0)	
  
	
  
Section	
  1:	
  Connect	
  to	
  a	
  WSDL	
  within	
  Design	
  
View	
  
	
  
Next,	
  click	
  on	
  the	
  Connect	
  to	
  Data	
  /	
  Services	
  link	
  within	
  the	
  
Data	
  /	
  Services	
  view.	
  
	
  




                                                                                           	
  
	
  
Select	
  WSDL	
  from	
  the	
  New	
  Flex	
  Service	
  window.	
  
	
  
 
Click	
  Next	
  and	
  the	
  Specify	
  WSDL	
  to	
  Introspect	
  form	
  will	
  
open.	
  Enter	
  a	
  WSDL	
  URI	
  of	
  
http://localhost:8400/axis/MyWebService.jws?wsdl	
  and	
  if	
  
it	
  doesn’t	
  automatically	
  create	
  one,	
  enter	
  a	
  Service	
  Name	
  of	
  
MyWebService.	
  
	
  
 
Click	
  Next	
  and	
  the	
  Configure	
  Code	
  Generation	
  form	
  will	
  
open.	
  Click	
  Select	
  All	
  to	
  generate	
  the	
  code	
  for	
  the	
  hello()	
  
and	
  personalHello()	
  web	
  service	
  operations.	
  Now	
  click	
  
Finish.	
  
 
Switch	
  the	
  editor	
  to	
  Design	
  View	
  and	
  from	
  within	
  the	
  
Properties	
  panel,	
  change	
  the	
  applications	
  layout	
  to	
  
sparks.layouts.VerticalLayout.	
  
 
Now	
  drag	
  a	
  TextInput	
  component	
  onto	
  the	
  stage,	
  right	
  click	
  
on	
  it	
  and	
  select	
  Bind	
  To	
  Data.	
  	
  
	
  
Select	
  the	
  MyWebService	
  /	
  hello()	
  from	
  the	
  New	
  Service	
  
Call	
  combo	
  boxes	
  	
  and	
  click	
  OK.	
  
	
  
 
You	
  should	
  now	
  see	
  the	
  following:	
  
	
  



                                                  	
  
	
  
Run	
  the	
  application	
  and	
  you	
  should	
  again	
  see	
  a	
  welcome	
  
message.	
  
	
  


                                         	
  
Section	
  2:	
  Connect	
  to	
  a	
  WSDL	
  with	
  Form	
  
Generation	
  
	
  
When	
  we	
  created	
  the	
  service	
  connection	
  to	
  the	
  
MyWebService	
  WSDL,	
  there	
  were	
  two	
  operations.	
  In	
  
Section	
  1	
  above	
  we	
  connected	
  to	
  the	
  simple	
  hello()	
  method	
  
which	
  did	
  not	
  have	
  any	
  required	
  arguments.	
  
	
  
The	
  second	
  method	
  personalHello()	
  has	
  two	
  incoming	
  
String	
  arguments.	
  Flash	
  Builder	
  has	
  another	
  new	
  feature	
  
that	
  will	
  do	
  some	
  quick	
  code	
  generation	
  to	
  connect	
  to	
  this	
  
WSDL.	
  
	
  
To	
  create	
  a	
  form	
  to	
  access	
  the	
  WSDL,	
  right	
  click	
  on	
  the	
  
personalHello()	
  method	
  and	
  select	
  Generate	
  Form.	
  
	
  
 
	
  
The	
  Generate	
  Form	
  window	
  will	
  open.	
  You	
  can	
  leave	
  all	
  as	
  
is	
  and	
  just	
  click	
  Next.	
  
 
The	
  next	
  screen	
  is	
  the	
  Property	
  control	
  mapping	
  screen.	
  
Again	
  for	
  the	
  purposes	
  of	
  this	
  demo,	
  you	
  can	
  leave	
  it	
  all	
  as	
  
is	
  and	
  just	
  click	
  Finish.	
  
	
  
 
	
  
You	
  should	
  now	
  see	
  a	
  new	
  form	
  that	
  has	
  been	
  generated	
  on	
  
stage.	
  
	
  
 
Go	
  ahead	
  and	
  run	
  the	
  application,	
  fill	
  in	
  you’re	
  first	
  and	
  last	
  
name	
  and	
  click	
  the	
  PersonalHello	
  button	
  and	
  you	
  should	
  
see	
  something	
  like	
  what	
  is	
  shown	
  below.	
  
	
  




                                                                             	
  
	
  
	
  

	
  
Lab	
  5:	
  Accessing	
  a	
  Proxy	
  Defined	
  
Service	
  
 
To	
  use	
  a	
  proxy	
  configuration	
  rather	
  than	
  hard	
  coding	
  the	
  
service	
  URL	
  within	
  the	
  application,	
  we	
  will	
  need	
  to	
  make	
  
some	
  edits	
  to	
  the	
  BlazeDS	
  configuration	
  files.	
  
	
  
Navigate	
  to:	
  
	
  
Install directory/BlazeDS/tomcat/webapps/blazeds/WEB-
INF/flex

Open the proxy-config.xml file within a text editor.
(TextEdit on Mac or NotePad on Windows)

To define the web service, you will need to add the
following within the <service> node right above the last
</service> tag:

<destination id="MyWebService" adapter="soap-proxy">
    <properties>
        <wsdl>
        http://localhost:8400/axis/MyWebService.jws?wsdl
        </wsdl>
        <soap>
        http://localhost:8400/axis/MyWebService*
        </soap>
    </properties>
</destination>


You will now need to restart the BlazeDS server so that
the newly defined service is available to FlashBuilder.

Now, as we have done previously done, click on Connect
to Data/Service within the Data/Service panel.
 
	
  
Select	
  WSDL	
  from	
  the	
  New	
  Flex	
  Service	
  window.	
  
	
  
 
	
  
	
  
Next	
  select	
  the	
  Through	
  a	
  LCDS/BlazeDS	
  proxy	
  destination	
  
and	
  after	
  a	
  few	
  second	
  you	
  should	
  be	
  able	
  to	
  select	
  the	
  
MyWebService	
  destination	
  from	
  the	
  Destination	
  combo	
  
box.	
  	
  
	
  
 

Click	
  Next	
  and	
  the	
  Configure	
  Code	
  Generation	
  form	
  will	
  
open.	
  Click	
  Select	
  All	
  to	
  generate	
  the	
  code	
  for	
  the	
  hello()	
  
and	
  personalHello()	
  web	
  service	
  operations.	
  Now	
  click	
  
Finish.	
  
 
	
  

	
  

Switch	
  the	
  editor	
  to	
  Design	
  View	
  and	
  from	
  within	
  the	
  
Properties	
  panel,	
  change	
  the	
  applications	
  layout	
  to	
  
sparks.layouts.VerticalLayout.	
  
 
Now	
  drag	
  a	
  TextInput	
  component	
  onto	
  the	
  stage,	
  right	
  click	
  
on	
  it	
  and	
  select	
  Bind	
  To	
  Data.	
  	
  
	
  
Select	
  the	
  MyWebService	
  /	
  hello()	
  from	
  the	
  New	
  Service	
  
Call	
  combo	
  boxes	
  	
  and	
  click	
  OK.	
  
	
  
 
You	
  should	
  now	
  see	
  the	
  following:	
  
	
  



                                                  	
  
	
  
Run	
  the	
  application	
  and	
  you	
  should	
  again	
  see	
  a	
  welcome	
  
message.	
  
	
  


                                        	
  
Section	
  2:	
  Connect	
  to	
  a	
  WSDL	
  with	
  Form	
  
Generation	
  
	
  
When	
  we	
  created	
  the	
  service	
  connection	
  to	
  the	
  
MyWebService	
  WSDL,	
  there	
  were	
  two	
  operations.	
  In	
  
Section	
  1	
  above	
  we	
  connected	
  to	
  the	
  simple	
  hello()	
  method	
  
which	
  did	
  not	
  have	
  any	
  required	
  arguments.	
  
	
  
The	
  second	
  method	
  personalHello()	
  has	
  two	
  incoming	
  
String	
  arguments.	
  Flash	
  Builder	
  has	
  another	
  new	
  feature	
  
that	
  will	
  do	
  some	
  quick	
  code	
  generation	
  to	
  connect	
  to	
  this	
  
WSDL.	
  
	
  
To	
  create	
  a	
  form	
  to	
  access	
  the	
  WSDL,	
  right	
  click	
  on	
  the	
  
personalHello()	
  method	
  and	
  select	
  Generate	
  Form.	
  
	
  
 
	
  
The	
  Generate	
  Form	
  window	
  will	
  open.	
  You	
  can	
  leave	
  all	
  as	
  
is	
  and	
  just	
  click	
  Next.	
  
 
The	
  next	
  screen	
  is	
  the	
  Property	
  control	
  mapping	
  screen.	
  
Again	
  for	
  the	
  purposes	
  of	
  this	
  demo,	
  you	
  can	
  leave	
  it	
  all	
  as	
  
is	
  and	
  just	
  click	
  Finish.	
  
	
  
 
	
  
You	
  should	
  now	
  see	
  a	
  new	
  form	
  that	
  has	
  been	
  generated	
  on	
  
stage.	
  
	
  
 
Go	
  ahead	
  and	
  run	
  the	
  application,	
  fill	
  in	
  your	
  first	
  and	
  last	
  
name	
  and	
  click	
  the	
  PersonalHello	
  button	
  and	
  you	
  should	
  
see	
  something	
  like	
  what	
  is	
  shown	
  below.	
  
	
  




                                                                             	
  
	
  
	
  
	
  
	
  
	
  
Lab	
  6:	
  Enable	
  Paging	
  (Bonus)	
  
	
  
One of the coolest new features of Flash Builder 4 is the
Enable Paging option. We will demonstrate this by using
a Java class defined as a remote object within the
remoting-config.xml file.

Create a new project named Lab6.

Click on Connect to Data/DService




                                                      	
  
	
  
Choose BlazeDS and click Next
If prompted, check No password required
 
Check the MyService checkbox and click Finish
Right click on the getItems_paged method within the
MyService and choose Enable Paging
 
	
  
Check Index from the Enable Paging window and click
Next
Enter 20 as the Number of Items to fetch and set the
Count operation to count() and click Finish
Now switch to design view, drag a DataGridto the
workspace.

Right click on the DataGrid and choose Bind To Data
Select the MyService with the Operation
getItems_paged() and click OK
Now run the project and you will see the following. You
will also notice that as you scroll the DataGrid, your data
will be retrieved.
 
	
  
Lab	
  7:	
  JSON	
  HTTPService	
  (extra	
  credit)	
  
	
  
The	
  BlazeDS	
  server	
  also	
  included	
  a	
  JSON	
  sample	
  at	
  
http://localhost:8400/json/Wines.json.	
  
For	
  extra	
  credit,	
  attempt	
  to	
  connect	
  to	
  this	
  file	
  and	
  output	
  
the	
  contents	
  to	
  a	
  DataGrid.	
  As	
  we	
  have	
  seen	
  throughout	
  the	
  
examples	
  in	
  this	
  document,	
  there	
  are	
  several	
  ways	
  to	
  
accomplish	
  this.	
  	
  
You	
  have	
  your	
  choice	
  of	
  manually	
  connecting	
  and	
  parsing	
  
the	
  file	
  (Note:	
  you	
  will	
  need	
  to	
  utilize	
  the	
  JSON.decode()	
  
function	
  located	
  in	
  the	
  com.adobe.serialization.json	
  
package	
  within	
  the	
  as3corelib	
  located	
  at	
  
http://code.google.com/p/as3corelib).	
  	
  
Or,	
  you	
  can	
  use	
  the	
  HTTPService	
  Wizard	
  to	
  connect	
  to	
  a	
  
JSON	
  file,	
  just	
  as	
  we	
  had	
  previously	
  done	
  with	
  the	
  XML	
  
example.	
  
You	
  can	
  see	
  the	
  completed	
  solutions	
  in	
  the	
  Lab7A	
  and	
  
Lab7B	
  projects.	
  
	
  

	
  
	
  
	
  
	
  
	
  
Conclusion	
  
If	
  I	
  have	
  done	
  my	
  job	
  properly	
  you	
  should	
  be	
  able	
  to	
  see	
  the	
  
benefits	
  of	
  the	
  new	
  tooling	
  within	
  FlashBuilder	
  for	
  
connecting	
  to	
  data	
  services.	
  Not	
  only	
  does	
  it	
  make	
  you	
  job	
  a	
  
lot	
  easier,	
  you	
  also	
  wind	
  up	
  with	
  nicely	
  documented	
  and	
  
structured	
  code.	
  
It	
  is	
  also	
  worthwhile	
  to	
  point	
  out	
  that	
  although	
  we	
  didn’t	
  
cover	
  it	
  within	
  this	
  session,	
  there	
  are	
  also	
  FlashBuilder	
  data	
  
wizards	
  to	
  connect	
  to	
  BlazeDS,	
  ColdFusion,	
  LCDS,	
  and	
  PHP	
  
services.	
  
If	
  you	
  still	
  don’t	
  see	
  the	
  benefits	
  of	
  using	
  FlashBuilder	
  as	
  
your	
  development	
  tool,	
  you	
  can	
  still	
  go	
  the	
  route	
  of	
  
manually	
  connecting	
  and	
  parsing	
  the	
  results	
  and	
  compiling	
  
your	
  code	
  via	
  the	
  Free	
  SDK.	
  
	
  

	
  
	
  

Contenu connexe

Tendances

Exchange Server 2013 : upgrade migration et co-existence avec les anciennes v...
Exchange Server 2013 : upgrade migration et co-existence avec les anciennes v...Exchange Server 2013 : upgrade migration et co-existence avec les anciennes v...
Exchange Server 2013 : upgrade migration et co-existence avec les anciennes v...Microsoft Technet France
 
Apache Web server Complete Guide
Apache Web server Complete GuideApache Web server Complete Guide
Apache Web server Complete Guidewebhostingguy
 
Apache web server tutorial for linux
Apache web server tutorial for linuxApache web server tutorial for linux
Apache web server tutorial for linuxSahad Sali
 
mule salesforce
mule salesforcemule salesforce
mule salesforceF K
 
Configuring the Apache Web Server
Configuring the Apache Web ServerConfiguring the Apache Web Server
Configuring the Apache Web Serverwebhostingguy
 
Apache server configuration & optimization
Apache server configuration & optimizationApache server configuration & optimization
Apache server configuration & optimizationGokul Muralidharan
 
How to connect sql server to oracle server
How to connect sql server to oracle serverHow to connect sql server to oracle server
How to connect sql server to oracle serverGustavo Bernardo
 
Ch02 installing exchange
Ch02 installing exchangeCh02 installing exchange
Ch02 installing exchangeShane Flooks
 
Build Application With MongoDB
Build Application With MongoDBBuild Application With MongoDB
Build Application With MongoDBEdureka!
 
APACHE WEB SERVER FOR LINUX
APACHE WEB SERVER FOR LINUXAPACHE WEB SERVER FOR LINUX
APACHE WEB SERVER FOR LINUXwebhostingguy
 
Apache web server installation/configuration, Virtual Hosting
Apache web server installation/configuration, Virtual HostingApache web server installation/configuration, Virtual Hosting
Apache web server installation/configuration, Virtual Hostingwebhostingguy
 
Apache Server Tutorial
Apache Server TutorialApache Server Tutorial
Apache Server TutorialJagat Kothari
 
Windows Hosting Documentation
Windows Hosting DocumentationWindows Hosting Documentation
Windows Hosting Documentationwebhostingguy
 
Oracle WebLogic Server 12c with Docker
Oracle WebLogic Server 12c with DockerOracle WebLogic Server 12c with Docker
Oracle WebLogic Server 12c with DockerGuatemala User Group
 

Tendances (20)

Apache ppt
Apache pptApache ppt
Apache ppt
 
Apache Ppt
Apache PptApache Ppt
Apache Ppt
 
Exchange Server 2013 : upgrade migration et co-existence avec les anciennes v...
Exchange Server 2013 : upgrade migration et co-existence avec les anciennes v...Exchange Server 2013 : upgrade migration et co-existence avec les anciennes v...
Exchange Server 2013 : upgrade migration et co-existence avec les anciennes v...
 
Apache Web server Complete Guide
Apache Web server Complete GuideApache Web server Complete Guide
Apache Web server Complete Guide
 
Apache web server tutorial for linux
Apache web server tutorial for linuxApache web server tutorial for linux
Apache web server tutorial for linux
 
mule salesforce
mule salesforcemule salesforce
mule salesforce
 
Apache
ApacheApache
Apache
 
Configuring the Apache Web Server
Configuring the Apache Web ServerConfiguring the Apache Web Server
Configuring the Apache Web Server
 
Apache server configuration & optimization
Apache server configuration & optimizationApache server configuration & optimization
Apache server configuration & optimization
 
How to connect sql server to oracle server
How to connect sql server to oracle serverHow to connect sql server to oracle server
How to connect sql server to oracle server
 
Apache web server
Apache web serverApache web server
Apache web server
 
Ch02 installing exchange
Ch02 installing exchangeCh02 installing exchange
Ch02 installing exchange
 
Build Application With MongoDB
Build Application With MongoDBBuild Application With MongoDB
Build Application With MongoDB
 
APACHE WEB SERVER FOR LINUX
APACHE WEB SERVER FOR LINUXAPACHE WEB SERVER FOR LINUX
APACHE WEB SERVER FOR LINUX
 
Lect06 tomcat1
Lect06 tomcat1Lect06 tomcat1
Lect06 tomcat1
 
Apache web server installation/configuration, Virtual Hosting
Apache web server installation/configuration, Virtual HostingApache web server installation/configuration, Virtual Hosting
Apache web server installation/configuration, Virtual Hosting
 
Apache Server Tutorial
Apache Server TutorialApache Server Tutorial
Apache Server Tutorial
 
Power shell
Power shellPower shell
Power shell
 
Windows Hosting Documentation
Windows Hosting DocumentationWindows Hosting Documentation
Windows Hosting Documentation
 
Oracle WebLogic Server 12c with Docker
Oracle WebLogic Server 12c with DockerOracle WebLogic Server 12c with Docker
Oracle WebLogic Server 12c with Docker
 

En vedette

HTTP cache @ PUG Rome 03-29-2011
HTTP cache @ PUG Rome 03-29-2011HTTP cache @ PUG Rome 03-29-2011
HTTP cache @ PUG Rome 03-29-2011Alessandro Nadalin
 
Java Web Application Security - Denver JUG 2013
Java Web Application Security - Denver JUG 2013Java Web Application Security - Denver JUG 2013
Java Web Application Security - Denver JUG 2013Matt Raible
 
Bluetooth
Bluetooth Bluetooth
Bluetooth srinidpi
 
Magento implementation - by Divante.co
Magento implementation - by Divante.coMagento implementation - by Divante.co
Magento implementation - by Divante.coDivante
 
Supply chain management
Supply chain managementSupply chain management
Supply chain managementBhabesh Gautam
 
Supply chain management
Supply chain managementSupply chain management
Supply chain managementAniket Verma
 
Basics of Supply Chain Managment
Basics of Supply Chain ManagmentBasics of Supply Chain Managment
Basics of Supply Chain ManagmentYoussef Serroukh
 
Enterprise Systems: SCM, CRM, & ERP
Enterprise Systems: SCM, CRM, & ERPEnterprise Systems: SCM, CRM, & ERP
Enterprise Systems: SCM, CRM, & ERPUMaine
 
e-Commerce Trends from 2014 to 2015 by Divante.co
e-Commerce Trends from 2014 to 2015 by Divante.coe-Commerce Trends from 2014 to 2015 by Divante.co
e-Commerce Trends from 2014 to 2015 by Divante.coDivante
 
Masters of SlideShare
Masters of SlideShareMasters of SlideShare
Masters of SlideShareKapost
 
10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation Optimization10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation OptimizationOneupweb
 
What Makes Great Infographics
What Makes Great InfographicsWhat Makes Great Infographics
What Makes Great InfographicsSlideShare
 
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareSTOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareEmpowered Presentations
 
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingHow To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingContent Marketing Institute
 
2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShareSlideShare
 

En vedette (20)

Embedded System Case Study
Embedded System Case StudyEmbedded System Case Study
Embedded System Case Study
 
HTTP cache @ PUG Rome 03-29-2011
HTTP cache @ PUG Rome 03-29-2011HTTP cache @ PUG Rome 03-29-2011
HTTP cache @ PUG Rome 03-29-2011
 
Java Web Application Security - Denver JUG 2013
Java Web Application Security - Denver JUG 2013Java Web Application Security - Denver JUG 2013
Java Web Application Security - Denver JUG 2013
 
Case study of digital camera
Case study of digital cameraCase study of digital camera
Case study of digital camera
 
Bluetooth
Bluetooth Bluetooth
Bluetooth
 
Magento implementation - by Divante.co
Magento implementation - by Divante.coMagento implementation - by Divante.co
Magento implementation - by Divante.co
 
Proxy Server
Proxy ServerProxy Server
Proxy Server
 
Supply chain management
Supply chain managementSupply chain management
Supply chain management
 
Supply chain management
Supply chain managementSupply chain management
Supply chain management
 
Basics of Supply Chain Managment
Basics of Supply Chain ManagmentBasics of Supply Chain Managment
Basics of Supply Chain Managment
 
Enterprise Systems: SCM, CRM, & ERP
Enterprise Systems: SCM, CRM, & ERPEnterprise Systems: SCM, CRM, & ERP
Enterprise Systems: SCM, CRM, & ERP
 
e-Commerce Trends from 2014 to 2015 by Divante.co
e-Commerce Trends from 2014 to 2015 by Divante.coe-Commerce Trends from 2014 to 2015 by Divante.co
e-Commerce Trends from 2014 to 2015 by Divante.co
 
Supply Chain Management
Supply Chain ManagementSupply Chain Management
Supply Chain Management
 
Masters of SlideShare
Masters of SlideShareMasters of SlideShare
Masters of SlideShare
 
10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation Optimization10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation Optimization
 
What Makes Great Infographics
What Makes Great InfographicsWhat Makes Great Infographics
What Makes Great Infographics
 
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareSTOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
 
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingHow To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
 
You Suck At PowerPoint!
You Suck At PowerPoint!You Suck At PowerPoint!
You Suck At PowerPoint!
 
2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare
 

Similaire à New Flash Builder 4 WSDL and HTTP Connectors

Wps ol client_tutorial-1
Wps ol client_tutorial-1Wps ol client_tutorial-1
Wps ol client_tutorial-1goodmanding1
 
Writing simple web services in java using eclipse editor
Writing simple web services in java using eclipse editorWriting simple web services in java using eclipse editor
Writing simple web services in java using eclipse editorSantosh Kumar Kar
 
Step by step installation of microsoft dynamics 365 finance and operations on...
Step by step installation of microsoft dynamics 365 finance and operations on...Step by step installation of microsoft dynamics 365 finance and operations on...
Step by step installation of microsoft dynamics 365 finance and operations on...Umesh Pandit
 
Single Sign-On for APEX applications based on Kerberos (Important: latest ver...
Single Sign-On for APEX applications based on Kerberos (Important: latest ver...Single Sign-On for APEX applications based on Kerberos (Important: latest ver...
Single Sign-On for APEX applications based on Kerberos (Important: latest ver...Niels de Bruijn
 
Activemq installation and master slave setup using shared broker data
Activemq installation and master slave setup using shared broker dataActivemq installation and master slave setup using shared broker data
Activemq installation and master slave setup using shared broker dataRamakrishna Narkedamilli
 
DCHQ Cloud Application Platform | Linux Containers | Docker PaaS
DCHQ Cloud Application Platform | Linux Containers | Docker PaaSDCHQ Cloud Application Platform | Linux Containers | Docker PaaS
DCHQ Cloud Application Platform | Linux Containers | Docker PaaSdchq
 
Weblogic Console Customization labs
Weblogic Console Customization labsWeblogic Console Customization labs
Weblogic Console Customization labsPeter van Nes
 
BestInFlowCompetitionTutorials03May2023
BestInFlowCompetitionTutorials03May2023BestInFlowCompetitionTutorials03May2023
BestInFlowCompetitionTutorials03May2023Timothy Spann
 
Example Cosmos SDK Application Tutorial
Example Cosmos SDK Application TutorialExample Cosmos SDK Application Tutorial
Example Cosmos SDK Application TutorialJim Yang
 
Step by step_linux_guide
Step by step_linux_guideStep by step_linux_guide
Step by step_linux_guidevinod31dec
 
Tomcat Configuration (1)
Tomcat Configuration (1)Tomcat Configuration (1)
Tomcat Configuration (1)nazeer pasha
 
"Running CF in a Shared Hosting Environment"
"Running CF in a Shared Hosting Environment""Running CF in a Shared Hosting Environment"
"Running CF in a Shared Hosting Environment"webhostingguy
 
Salesforce Admin's guide : the data loader from the command line
Salesforce Admin's guide : the data loader from the command lineSalesforce Admin's guide : the data loader from the command line
Salesforce Admin's guide : the data loader from the command lineCyrille Coeurjoly
 

Similaire à New Flash Builder 4 WSDL and HTTP Connectors (20)

Adobe Flex4
Adobe Flex4 Adobe Flex4
Adobe Flex4
 
Wps ol client_tutorial-1
Wps ol client_tutorial-1Wps ol client_tutorial-1
Wps ol client_tutorial-1
 
Writing simple web services in java using eclipse editor
Writing simple web services in java using eclipse editorWriting simple web services in java using eclipse editor
Writing simple web services in java using eclipse editor
 
Step by step installation of microsoft dynamics 365 finance and operations on...
Step by step installation of microsoft dynamics 365 finance and operations on...Step by step installation of microsoft dynamics 365 finance and operations on...
Step by step installation of microsoft dynamics 365 finance and operations on...
 
Single Sign-On for APEX applications based on Kerberos (Important: latest ver...
Single Sign-On for APEX applications based on Kerberos (Important: latest ver...Single Sign-On for APEX applications based on Kerberos (Important: latest ver...
Single Sign-On for APEX applications based on Kerberos (Important: latest ver...
 
Lampstack (1)
Lampstack (1)Lampstack (1)
Lampstack (1)
 
Activemq installation and master slave setup using shared broker data
Activemq installation and master slave setup using shared broker dataActivemq installation and master slave setup using shared broker data
Activemq installation and master slave setup using shared broker data
 
treeview
treeviewtreeview
treeview
 
treeview
treeviewtreeview
treeview
 
Tomcat server
 Tomcat server Tomcat server
Tomcat server
 
DCHQ Cloud Application Platform | Linux Containers | Docker PaaS
DCHQ Cloud Application Platform | Linux Containers | Docker PaaSDCHQ Cloud Application Platform | Linux Containers | Docker PaaS
DCHQ Cloud Application Platform | Linux Containers | Docker PaaS
 
Weblogic Console Customization labs
Weblogic Console Customization labsWeblogic Console Customization labs
Weblogic Console Customization labs
 
BestInFlowCompetitionTutorials03May2023
BestInFlowCompetitionTutorials03May2023BestInFlowCompetitionTutorials03May2023
BestInFlowCompetitionTutorials03May2023
 
Example Cosmos SDK Application Tutorial
Example Cosmos SDK Application TutorialExample Cosmos SDK Application Tutorial
Example Cosmos SDK Application Tutorial
 
Step by step_linux_guide
Step by step_linux_guideStep by step_linux_guide
Step by step_linux_guide
 
Tomcat Configuration (1)
Tomcat Configuration (1)Tomcat Configuration (1)
Tomcat Configuration (1)
 
Microsoft Lync Server 2010 Installation
Microsoft Lync Server 2010 InstallationMicrosoft Lync Server 2010 Installation
Microsoft Lync Server 2010 Installation
 
"Running CF in a Shared Hosting Environment"
"Running CF in a Shared Hosting Environment""Running CF in a Shared Hosting Environment"
"Running CF in a Shared Hosting Environment"
 
AD102 - Break out of the Box
AD102 - Break out of the BoxAD102 - Break out of the Box
AD102 - Break out of the Box
 
Salesforce Admin's guide : the data loader from the command line
Salesforce Admin's guide : the data loader from the command lineSalesforce Admin's guide : the data loader from the command line
Salesforce Admin's guide : the data loader from the command line
 

New Flash Builder 4 WSDL and HTTP Connectors

  • 1. New  Flash  Builder  4  WSDL  and   HTTP  Connectors     Java  SDK:     To  run  a  Tomcat  server,  you  must  download  a  Java  SDK  and   setup  a  JAVA_HOME  environmental  variable.     Windows:     • Right click on the My Computer icon on your desktop and select properties • Click the Advanced Tab • Click the Environment Variables button • Under System Variable, click New • Enter the variable name as JAVA_HOME • Enter the variable value as the install path for the Development Kit (Ex: C:j2sdk1.4.2) • Click OK • Click Apply Changes
  • 2.     MAC  OS  X     • Open Terminal. • First confirm you have JDK by typing “which java”. It should show something like /usr/bin/java. • Check you have the needed version of Java, by typing “java -version”. My setup shows java version “1.5.0_13″ • JAVA_HOME is essentially the full path of the directory that contains a sub-directory named bin which in turn contains the java. • For Mac OSX – it is /Library/Java/Home (There are other directories too, but this is the simplest!)
  • 3. Set JAVA_HOME using this command in Terminal: export JAVA_HOME=/Library/Java/Home • echo $JAVA_HOME on Terminal to confirm the path • You should now be able to run your application   Start  the  Server:     Before  we  can  use  Flash  Builder  to  access  our  services,  we   need  to  start  up  the  Tomcat  server.  To  do  so  please  follow   the  steps  below:     WINDOWS:   Open  console  window  and  navigate  to  your  BlazeDS  install   directory:      cd  <BlazeDS  Root>BlazeDStomcatbin   Now  enter  cataina  run  to  start  up  the  Tomcat  server.        
  • 4. MAC:     Open  terminal  window.  Navigate  to  your  install  directory,   in  my  case  it  is  located  in  my  Applications  folder:      cd    <BlazeDS  Root>/BlazeDS/tomcat/bin   Now  enter  ./startup.sh  to  start  up  the  Tomcat  server.       TEST  the  Server:   Test  to  make  sure  your  server  is  running  by  opening  a   browser  and  navigating  to:   http://localhost:8400/xml/Wines.xml   http://localhost:8400/json/Wines.json  
  • 5. http://localhost:8400/axis/MyWebService.jws?wsdl   http://localhost:8400/crossdomain.xml   Notice  the  last  of  the  URL’s  listed  above  is  titled   crossdomain.xml.  This  file  is  required  for  the  FlashPlayer  to   access  data  services  hosted  on  remote  domains.    How  does   it  work?   When  a  Flash  document  attempts  to  access  data  from  another   domain,  Flash  Player  automatically  attempts  to  load  a  policy   file  from  that  domain.  If  the  domain  of  the  Flash  document   that  is  attempting  to  access  the  data  is  included  in  the  policy   file,  the  data  is  automatically  accessible.   Policy  files  must  be  named  crossdomain.xml,  and  can  reside   either  at  the  root  directory  or  in  another  directory  on  the   server  that  is  serving  the  data  with  some  additional   ActionScript.  Policy  files  function  only  on  servers  that   communicate  over  HTTP,  HTTPS,  or  FTP.  The  policy  file  is   specific  to  the  port  and  protocol  of  the  server  where  it   resides.           A  very  simplified  example  of  a  crossdomain.xml  file  is:   <cross-­‐domain-­‐policy>   <allow-­‐access-­‐from  domain="*"/>   <site-­‐control     permitted-­‐cross-­‐domain-­‐policies="master-­‐only"/>   </cross-­‐domain-­‐policy>  
  • 6. For  more  information  on  crossdomain.xml  please  visit:   http://www.adobe.com/devnet/articles/crossdomain_poli cy_file_spec.html     Lab  0:  Creating  a  Flash  Builder  Project     We  will  be  creating  multiple  Flash  Builder  projects  within   this  lab,  so  before  we  start  integrating  data,  lets  create  our   first  Flash  Builder  project.     Step  1:  Create  a  new  Flash  Builder  project       Select  File  >  New  Flex  Project  from  the  main  menu         Title  the  project  Lab1  and  choose  Web  (runs  in  Adobe   Flash  Player)  within  the  Application  type.     Set  the  Application  server  type  to  J2EE  and  select  the   BlazeDS  radio  button  and  click  Next.    
  • 7.   Click  Next  and  fill  in  the  necessary  information  to  connect   to  your  BlazeDS  server.  Note  that  your  Root  folder  may  be   different  than  what  is  shown  below.       In  my  case  the  Root  folder  is   /Applications/BlazeDS/tomcat/webapps/blazeds  and  the   Root  URL  is  http://localhost:8400/blazeds  and  the  Context   root  is  /blazeds.  Click  Validate  Configuration.  
  • 8.   Now  click  Finish.            
  • 9. Lab  1:  Code  View     (MXML  and  AS3  to  get  REST  Data)     Section  1:  Connect  to  data  using  MXML     Open  the  project  created  above  named  Lab1.     To  define  the  service,  we  need  to  add  an  <fx:Declarations>   block  to  wrap  the  HTTPService.  Note:  this  is  something  that   is  new  to  Flex  4.  Within  the  declarations  nested  tags,  you   will  notice  the  <mx:HTTPService/>  tag.  This  tag  defines  the   service  operation.  The  attributes  define  the  id,  expected   result  format,  URL  of  the  service,  whether  or  not  to  use  the   proxy  (more  on  this  later),  and  the  callback  functions  for   successful  or  failed  operations.     <fx:Declarations> <mx:HTTPService id="wines" resultFormat="e4x" url="http://localhost:8400/xml/Wines.xml" useProxy="false" result="parseXML(event)" fault="trace(event.fault)"/> </fx:Declarations>     Next,  add  the  <fx:Script>  block  defined  below.     <fx:Script> <![CDATA[ import mx.collections.XMLListCollection; import mx.rpc.events.ResultEvent; private function parseXML(event:ResultEvent):void{ var xml:XML = event.result as XML; dg.dataProvider = xml["Vintage"];
  • 10. } ]]> </fx:Script>   If  you  look  at  the  script  block  above  you  will  notice  the   parseXML()  function.  This  is  the  callback  function  that  we   previously  discussed  which  will  parse  out  the  XML  that  is   returned  on  a  successful  service  call.     Finally  we  need  some  UI  elements  to  trigger  the  call  and  to   display  the  data.  Add  the  component  declarations  below  to   your  application.     <mx:VBox horizontalCenter="0"> <mx:DataGrid id="dg"> <mx:columns> <mx:DataGridColumn headerText="Vintner" dataField="Vintner" /> <mx:DataGridColumn headerText="Name" dataField="Name" /> <mx:DataGridColumn headerText="Vintage" dataField="Vintage" /> <mx:DataGridColumn headerText="ParkerNotation" dataField="ParkerNotation" /> <mx:DataGridColumn headerText="Price" dataField="Price" /> </mx:columns> </mx:DataGrid> <mx:HBox> <s:Button click="wines.send()" label="Get Wines MXML"/> </mx:HBox> </mx:VBox>     Examining  the  code  above  you  will  notice  that  we  have  a   DataGrid  with  an  id  of  dg  that  contains  five  columns  that   match  the  XML  nodes.  There  is  also  a  Button  that  is  used  to   trigger  the  wines  service.  
  • 11.   Save  you  file  and  run  the  application  and  you  should  see   the  following  after  clicking  the  Get  Wines  button.         Section  2:  Connect  to  data  using  AS3     In  Section  1  of  Lab  1  we  utilized  MXML  to  call  our  service,   we  can  also  call  the  service  using  ActionScript.       Add  the  function  below  to  the  <fx:Script>  block  of  Lab1.     private function getWines():void{ var service:HTTPService = new HTTPService(); service.resultFormat = "e4x"; service.url="http://localhost:8400/xml/Wines.xml"; service.useProxy=false; service.addEventListener(ResultEvent.RESULT,parseXML); service.send(); } Notice  that  we  have  many  of  the  same  properties  set  as   were  declared  within  the  MXML  component.  By  setting  the  
  • 12. event  listener  for  the  successful  call,  we  are  able  to  reuse   the  parseXML()  function.       Now,  simply  add  a  few  buttons  below  the  Get  Wines  MXML   to  call  the  getWines()  function  and  clear  the  data  button:   <s:Button click="getWines()" label="Get Wines AS3"/> <s:Button click="dg.dataProvider=null" label="Clear Datagrid"/> Save  your  file,  run  the  project,  and  click  on  the  new  Get   Wines  AS3  button  and  you  should  see  the  results  shown   below.                      
  • 13. Lab  2:  Code  View     (MXML  and  AS3  to  get  WSDL  Data)     Create  a  new  project  named  Lab2  (as  demonstrated   previously  in  Lab0)     Add  the  following  declarations  tag  to  define  the  connection   to  the  WSDL:   <fx:Declarations> <mx:WebService id="myWebService" wsdl="http://localhost:8400/axis/MyWebService.jws?wsdl" useProxy="false" result="parseResult(event)" fault="trace(event.fault)"/> </fx:Declarations>     Next  add  a  script  block  below  the  declarations  block  to   handle  the  service  result.     <fx:Script> <![CDATA[ import mx.rpc.events.ResultEvent; private function parseResult(event:ResultEvent):void{ lbl.text = event.result as String; } ]]> </fx:Script> Finally,  add  a  Label  component  to  display  the  service   results.     <mx:Label id="lbl" fontSize="36" creationComplete="myWebService.hello()" horizontalCenter="0" verticalCenter="0"/>
  • 14.   Run  the  project  and  you  should  see  the  message  shown   below:                                          
  • 15. Lab  3:  Design  View     (Using  Flash  Builder  to  get  REST  data)   Now  that  we  have  looked  at  several  ways  to  connect  to  data   services,  lets  take  a  look  at  how  the  new  Flash  Builder   tooling  creates  data  connections.       Create  a  new  project  named  Lab3  (as  demonstrated   previously  in  Lab0)     Next,  click  on  the  Connect  to  Data  /  Services  link  within  the   Data  /  Services  view.         Select  HTTPService  from  the  New  Flex  Service  window.    
  • 16.   Click  Next  and  you  will  see  the  Configure  HTTP  Service   form.     Enter  getWines  for  the  Operation  name  and   http://localhost:8400/xml/Wines.xml  for  the  URL  within  the  
  • 17. Operations  Grid.  Then  enter  WinesService  for  the  Service   Name  and  click  Finish.       You  should  now  see  the  new  service  defined  within  the   Data  /  Services  view.    
  • 18.     Switch  your  project  to  Design  View  and  drag  a  DataGrid   component  from  the  Components  view  onto  the  stage.     Right  click  on  the  DataGrid  component  and  select  Bind  To   Data.         The  Bind  To  Data  window  will  open.    
  • 19.     Before  you  can  select  the  service,  you  need  to  configure  the   return  type.  Click  on  the  Configure  Return  Type  button  and   the  Configure  Operation  Return  Type  window  will  open.      
  • 20.   Leave  the  radio  button  set  to  Auto  detect  and  click  Next.     In  Step  2,  leave  the  radio  button  set  to  Enter  parameter   values  and  click  Next.    
  • 21.   Within  Step  3,  select  Vintage  from  the  Select  Node  drop   down  menu  and  click  Finish.    
  • 22.     Now  click  OK  to  close  the  Bind  To  Data  window  and  you   should  see  the  DataGrid  now  has  the  column  names   defined.    
  • 23.   Run  the  project  and  you  will  see  your  data!                      
  • 24. Lab  4:  Design  View     (Using  Flash  Builder  to  get  WSDL  data)     Create  a  new  project  named  Lab4  (as  demonstrated   previously  in  Lab0)     Section  1:  Connect  to  a  WSDL  within  Design   View     Next,  click  on  the  Connect  to  Data  /  Services  link  within  the   Data  /  Services  view.         Select  WSDL  from  the  New  Flex  Service  window.    
  • 25.   Click  Next  and  the  Specify  WSDL  to  Introspect  form  will   open.  Enter  a  WSDL  URI  of   http://localhost:8400/axis/MyWebService.jws?wsdl  and  if   it  doesn’t  automatically  create  one,  enter  a  Service  Name  of   MyWebService.    
  • 26.   Click  Next  and  the  Configure  Code  Generation  form  will   open.  Click  Select  All  to  generate  the  code  for  the  hello()   and  personalHello()  web  service  operations.  Now  click   Finish.  
  • 27.   Switch  the  editor  to  Design  View  and  from  within  the   Properties  panel,  change  the  applications  layout  to   sparks.layouts.VerticalLayout.  
  • 28.   Now  drag  a  TextInput  component  onto  the  stage,  right  click   on  it  and  select  Bind  To  Data.       Select  the  MyWebService  /  hello()  from  the  New  Service   Call  combo  boxes    and  click  OK.    
  • 29.   You  should  now  see  the  following:         Run  the  application  and  you  should  again  see  a  welcome   message.      
  • 30. Section  2:  Connect  to  a  WSDL  with  Form   Generation     When  we  created  the  service  connection  to  the   MyWebService  WSDL,  there  were  two  operations.  In   Section  1  above  we  connected  to  the  simple  hello()  method   which  did  not  have  any  required  arguments.     The  second  method  personalHello()  has  two  incoming   String  arguments.  Flash  Builder  has  another  new  feature   that  will  do  some  quick  code  generation  to  connect  to  this   WSDL.     To  create  a  form  to  access  the  WSDL,  right  click  on  the   personalHello()  method  and  select  Generate  Form.    
  • 31.     The  Generate  Form  window  will  open.  You  can  leave  all  as   is  and  just  click  Next.  
  • 32.   The  next  screen  is  the  Property  control  mapping  screen.   Again  for  the  purposes  of  this  demo,  you  can  leave  it  all  as   is  and  just  click  Finish.    
  • 33.     You  should  now  see  a  new  form  that  has  been  generated  on   stage.    
  • 34.   Go  ahead  and  run  the  application,  fill  in  you’re  first  and  last   name  and  click  the  PersonalHello  button  and  you  should   see  something  like  what  is  shown  below.             Lab  5:  Accessing  a  Proxy  Defined   Service  
  • 35.   To  use  a  proxy  configuration  rather  than  hard  coding  the   service  URL  within  the  application,  we  will  need  to  make   some  edits  to  the  BlazeDS  configuration  files.     Navigate  to:     Install directory/BlazeDS/tomcat/webapps/blazeds/WEB- INF/flex Open the proxy-config.xml file within a text editor. (TextEdit on Mac or NotePad on Windows) To define the web service, you will need to add the following within the <service> node right above the last </service> tag: <destination id="MyWebService" adapter="soap-proxy"> <properties> <wsdl> http://localhost:8400/axis/MyWebService.jws?wsdl </wsdl> <soap> http://localhost:8400/axis/MyWebService* </soap> </properties> </destination> You will now need to restart the BlazeDS server so that the newly defined service is available to FlashBuilder. Now, as we have done previously done, click on Connect to Data/Service within the Data/Service panel.
  • 36.     Select  WSDL  from  the  New  Flex  Service  window.    
  • 37.       Next  select  the  Through  a  LCDS/BlazeDS  proxy  destination   and  after  a  few  second  you  should  be  able  to  select  the   MyWebService  destination  from  the  Destination  combo   box.      
  • 38.   Click  Next  and  the  Configure  Code  Generation  form  will   open.  Click  Select  All  to  generate  the  code  for  the  hello()   and  personalHello()  web  service  operations.  Now  click   Finish.  
  • 39.       Switch  the  editor  to  Design  View  and  from  within  the   Properties  panel,  change  the  applications  layout  to   sparks.layouts.VerticalLayout.  
  • 40.   Now  drag  a  TextInput  component  onto  the  stage,  right  click   on  it  and  select  Bind  To  Data.       Select  the  MyWebService  /  hello()  from  the  New  Service   Call  combo  boxes    and  click  OK.    
  • 41.   You  should  now  see  the  following:         Run  the  application  and  you  should  again  see  a  welcome   message.      
  • 42. Section  2:  Connect  to  a  WSDL  with  Form   Generation     When  we  created  the  service  connection  to  the   MyWebService  WSDL,  there  were  two  operations.  In   Section  1  above  we  connected  to  the  simple  hello()  method   which  did  not  have  any  required  arguments.     The  second  method  personalHello()  has  two  incoming   String  arguments.  Flash  Builder  has  another  new  feature   that  will  do  some  quick  code  generation  to  connect  to  this   WSDL.     To  create  a  form  to  access  the  WSDL,  right  click  on  the   personalHello()  method  and  select  Generate  Form.    
  • 43.     The  Generate  Form  window  will  open.  You  can  leave  all  as   is  and  just  click  Next.  
  • 44.   The  next  screen  is  the  Property  control  mapping  screen.   Again  for  the  purposes  of  this  demo,  you  can  leave  it  all  as   is  and  just  click  Finish.    
  • 45.     You  should  now  see  a  new  form  that  has  been  generated  on   stage.    
  • 46.   Go  ahead  and  run  the  application,  fill  in  your  first  and  last   name  and  click  the  PersonalHello  button  and  you  should   see  something  like  what  is  shown  below.                
  • 47. Lab  6:  Enable  Paging  (Bonus)     One of the coolest new features of Flash Builder 4 is the Enable Paging option. We will demonstrate this by using a Java class defined as a remote object within the remoting-config.xml file. Create a new project named Lab6. Click on Connect to Data/DService     Choose BlazeDS and click Next
  • 48. If prompted, check No password required
  • 49.   Check the MyService checkbox and click Finish
  • 50. Right click on the getItems_paged method within the MyService and choose Enable Paging
  • 51.     Check Index from the Enable Paging window and click Next
  • 52. Enter 20 as the Number of Items to fetch and set the Count operation to count() and click Finish
  • 53. Now switch to design view, drag a DataGridto the workspace. Right click on the DataGrid and choose Bind To Data
  • 54. Select the MyService with the Operation getItems_paged() and click OK
  • 55. Now run the project and you will see the following. You will also notice that as you scroll the DataGrid, your data will be retrieved.
  • 56.     Lab  7:  JSON  HTTPService  (extra  credit)     The  BlazeDS  server  also  included  a  JSON  sample  at   http://localhost:8400/json/Wines.json.   For  extra  credit,  attempt  to  connect  to  this  file  and  output   the  contents  to  a  DataGrid.  As  we  have  seen  throughout  the   examples  in  this  document,  there  are  several  ways  to   accomplish  this.     You  have  your  choice  of  manually  connecting  and  parsing   the  file  (Note:  you  will  need  to  utilize  the  JSON.decode()   function  located  in  the  com.adobe.serialization.json   package  within  the  as3corelib  located  at   http://code.google.com/p/as3corelib).    
  • 57. Or,  you  can  use  the  HTTPService  Wizard  to  connect  to  a   JSON  file,  just  as  we  had  previously  done  with  the  XML   example.   You  can  see  the  completed  solutions  in  the  Lab7A  and   Lab7B  projects.               Conclusion   If  I  have  done  my  job  properly  you  should  be  able  to  see  the   benefits  of  the  new  tooling  within  FlashBuilder  for   connecting  to  data  services.  Not  only  does  it  make  you  job  a   lot  easier,  you  also  wind  up  with  nicely  documented  and   structured  code.   It  is  also  worthwhile  to  point  out  that  although  we  didn’t   cover  it  within  this  session,  there  are  also  FlashBuilder  data   wizards  to  connect  to  BlazeDS,  ColdFusion,  LCDS,  and  PHP   services.   If  you  still  don’t  see  the  benefits  of  using  FlashBuilder  as   your  development  tool,  you  can  still  go  the  route  of  
  • 58. manually  connecting  and  parsing  the  results  and  compiling   your  code  via  the  Free  SDK.