Category Archives: Web Services

BabelFish web service works!

The BabelFish web service is now working! Looks like they have implemented the policy file for Flash developers. Check it out (Flash Player 7 required):

Here are the source files. For more info, see the original post.

UPDATE: Looks like this still doesn’t work in Mozilla! Is this a player problem, the new security policy, or something else? Please leave a comment if you find anything (I’m too busy to look into this right now).

Updated Class Browser with hidden classes

The “class browser” has been updated – it now includes hidden class files for data connectivity.

Unless you add these hidden files to the actual paths, you’ll see a little yellow triangle (see diagram) and won’t be able to double-click and see the class definitions. However, they’re still useful as a quick lookup of the class paths for entering into your code.

Note that the Include folder contains files that are part of Flash Remoting Components for Flash MX 2004.

For non-English installations, you may have to change the class paths in this .flp file. Open it up in a text editor, Find & Replace words like “/Program Files/” and “/en/” to your OS settings.

You can download the updated file here.

Still no go with BabelFish redirection proxy

I’ve updated the BabelFish tutorial, now using a server-side proxy for redirection to the actual BabelFish web service. The proxy taken from Macromedia does not work when the movie is accessed through HTTP in a browser, but works fine when playing inside Flash’s IDE or the standalone projector.

Has anyone got a redirection proxy that works with the new WebServiceConnector component?

Read more…

Tutorial: BabelFish with WebServiceConnector

The new WebServiceConnector component in Flash MX 2004 Professional makes talking to standard (SOAP) web services extremely easy. Here’s how to make a simple call to the BabelFish web service using Flash MX 2004 Professional’s new features:

  1. Drag the WebServiceConnector component to the stage (just outside of it), and give it an instance name “babelfish”
  2. Select it and open the Component Inspector
  3. Under the Parameters tab, enter the WSDLURL:
    http://www.xmethods.net/sd/2001/BabelFishService.wsdl
  4. Click the next field “operation” and select BabelFish
  5. Click the Schema tab and check out the schema for this web service
  6. Note that it requires two parameters (translationmode and sourcedata), and it returns a string
  7. Now let’s create the interface of the application:

  8. Drag a TextInput component to the stage, adjust its size as needed, and give it an instance name “sourcedata”
  9. Drag a ComboBox to the stage and name it “translationmode”
  10. Drag a TextArea component to the stage (this is for displaying the result from the web service), adjust its size as needed, and name it “results”
  11. Drag a button to the stage, change its label to “Translate”
  12. With the button selected, add a new behavior from the Behaviors panel: Click the + button, select Data – Trigger Data Source. In the popup window, select babelfish.
  13. Let’s bind the babelfish component to the interface:

  14. Select the babelfish component, open the Component Inspector panel and click the Bindings tab
  15. Click the + button, select “translationmode:string”, and click OK. Double-click on the “bound to” field underneath. In the Bound To dialog box, select “Combobox, ” on the left, and “value:String” on the right. Click OK.
  16. Add another binding, this time select “sourcedata:String” and click OK. In the Bound To dialog box, choose “TextInput, ” and click OK.
  17. Add another binding, select “results:String” and click OK. In the Bound To dialog box, choose “TextArea, ” and click OK.

Now is a good time to save the FLA.

Before we can make this work, we need to populate the ComboBox. First, let’s take a look at how the web interface of BabelFish looks like: http://babelfish.altavista.com/. From the dropdown menus, you can tell the languages and translation directions.

View Source from the browser, inspect the data that is sent to the server when an item is selected from the dropdown menu:

Let’s populate these data into our ComboBox: Deselect all items from the stage, and add a new script:

That’s it! Test movie and enter some text, select a translation mode, and click the Translate button to see the translated text! Not too bad is it? Try it out:

Okay, this is what it looks like. Why doesn’t it work? It’s because when the new Flash Player 7 is running inside a browser through HTTP, the new cross-domain security prevents this SWF from loading data from another domain.

What is needed is a policy file – an XML document specifying who is allowed, and this file has to reside at the web service domain. One way to get around this is to use a redirection proxy (server-side script) at this domain, to pass the data between servers and back to this translator. This will be the subject for another day.

UPDATE:

Instead of hardcoding the translation modes into the movie, Mark Shepherd of Macromedia suggested using the XMLConnector component to load an external XML file with the translation modes, and bind the data to the ComboBox. I’ve gone one step further by adding the web service URL in this XML document (BabelFish.xml). This is what I usually do for application configurations, it makes updating quick and easy without going into the source movie and recompiling another SWF.

Also, a redirection proxy file is being used. However, for some reason, this proxy only works when the movie is running inside Flash’s IDE or from the desktop standalone projector, but still not from this domain, even though both the SWF and the proxy are located in the same folder. This is the proxy similar to the one posted at Macromedia, except I’m using JScript instead of VBScript (that does not work either):

Why does this proxy work outside of the browser and not from the same domain? I’d really like to get an answer to this one.

You can download the source files, check them out and let me know if you find anything. Thanks!