nwebb

Flex, Flash, AIR

Using WebOrb with AIR (Step 1)

[I'm using the .NET version of WebOrb but this should be generic enough to apply to all versions]

Examples Work For Flex But Not AIR
When you load WebOrb you get access to the ‘weborbconsole‘ which is a Flex app that runs on localhost). In the ‘Getting Started‘ section of this app there is a tutorial which will work if you run it as a Flex application, but will throw an error if you run it as an AIR application. I found some very helpful documentation pointing to the necessary changes, but it is slightly outdated so I thought I’d fill in the gaps.

Recommended Reading
First of all, here is the documentation which I’d highly recommend reading (I’ll summarise some of the key points below): Channels, endpoints and destinations

Config Files
Okay, so if you stuck with the default installation then you should find all your config files located here:
C:\inetpub\wwwroot\weborb30\WEB-INF\flex
The two files we are most interested in are services-config.xml (specifies channels) and remoting-config.xml (specifies destinations). The former references the latter.

In remoting-config.xml you can see that some default channels are defined:

<default-channels>
<channel ref=”my-amf”/>
<channel ref=”my-secure-amf”/>
</default-channels>

You can also see that a bunch of destinations are declared, one of which is called “GenericDestination” and uses a wildcard (*) for the source:

<destination id=”GenericDestination”>
<properties>
<source>*</source>
</properties>
</destination>

When the wildcard is used, WebOrb uses one of the default-channels. The default channels apply to all remoting destinations unless a channel is specifically referenced in a destination declaration (thanks Mark!).

You can see that the first of the default channels references the “my-amf” channel, so by default any [non-secure app?] setting the destination to be “GenericDestination” will actually end up using the “my-amf” channel. Here is an example of the Flex RemoteObject tag doing just that:

<mx:RemoteObject id=”compinfo”
destination=”GenericDestination”
source=”noteperfect.remote.ComputerInfoService”
showBusyCursor=”true”
fault=”faultHandler(event)” >
<mx:method name=”getComputerInfo” result=”getComputerInfoHandler(event)”/>
</mx:RemoteObject>

A Solution
The documentation I linked to ( above) explains how AIR needs absolute URLs rather than relative URLs, and this is why we need to use different channels for Flex and AIR apps ( the only difference being that the AIR channel has an absolute reference to the endpoint uri ) . The doc also refers to “my-air-amf” and “GenericAIRDestination“. I could only find an “air-http” channel definition in my version of WebOrb, and as for “GenericAIRDestination“, that does exist (in weborb-services-config.xml) but it is exactly the same as “GenericDestination“.

So, I was able to get the example working as an AIR app by doing the following:

  • Changing the default channel in remoting-config.xml to be  <channel ref=”air-http”/>
  • Setting the destination on my RemoteObject in Flex to be “GenericDestination” (rather than GenericAIRDestination)

I’m brand-new to WebOrb and I’m not suggesting that this is the only/best/recommended way to get things working - although the documentation seems to suggest it is. Please feel free to leave a comment if there is a better way.

——————————————————————————————-
Edit:

After chatting to Mark from MidnightCoders I’ve changed things slightly. All I’ve really done is:
(1) Reverted the default-channel to be “my-amf” (in remoting-config)
(2) Copied “GenericAIRDestination” ( from weborb-services-config.xml) in to remoting-config,  and added both a channels attribute and tag - see the xml below.
(3)
Changed my RemoteObject in Flex to use “GenericAIRDestination”

In Remoting Config:

<default-channels>
<channel ref=”my-amf”/>
</default-channels>

Also In Remoting Config (copied over from weborb-services-config & ammended):

<destination id=”GenericAIRDestination” channels=”air-http”>
<channels>
<channel ref=”air-http” />
</channels>
<properties>
<source>*</source>
</properties>
</destination>

In Services Config:

<channel-definition id=”air-http” class=”mx.messaging.channels.AMFChannel”>

<endpoint uri=”http://localhost:80/weborb30/weborb.aspx” class=”flex.messaging.endpoints.AMFEndpoint”/>
<properties>
<polling-enabled>false</polling-enabled>
</properties>
</channel-definition>

In Flex App:

<mx:RemoteObject id=”compinfo”
destination=”GenericAIRDestination”
source=”noteperfect.remote.ComputerInfoService”
showBusyCursor=”true”
fault=”faultHandler(event)” >
<mx:method name=”getComputerInfo” result=”getComputerInfoHandler(event)”/>
</mx:RemoteObject>

I won’t go too much further in to this, because (a) Mark has indicated that things will probably be made easier in WebOrb 4, and (b)  my next post is going to be about using WebOrb & AIR without referring to the config files at all ( courtesy of Dan from the moov2 team).

Thanks to Mark for all his help.

No comments

If WebOrbConsole Doesn’t Load

Today I installed/enabled WebOrb for .NET & IIS7 on a Windows7 machine.

Initially the WebOrbConsole page ( which is a Flex app ) loaded without issue, but at some point after a reboot I revisited the console page and it was blank ( ie  I saw nothing but the default blue Flex background; the console never loaded. I didn’t even see the preloader ).

I’m completely new to IIS. ,NET and WebOrb so after doing the obvious stuff (restarting the server etc) I found myself a little stuck. Thankfully Dan came to the rescue and got things working and I thought I’d relay what he did, as it was a little odd. We still don’t really know what was the cause of the issue. It didn’t seem to be the permissions, although that would seem a likely cause.

  1. Make a copy of the default weborb folder ( it will be named weborb30 or something similar, depending on the version of WebOrb you are using - the default location for me is C:\inetpub\wwwroot\weborb30 ).
  2. Rename it to whatever you want  ( e.g. weborbdan )
  3. Bring up the IIS management console (on Win7 this is start->control panel->system & security->Administrative Tools->IIS Manager). It should look something like this:iis_011
  4. Right-click on “Default Web Site” and choose “Add Application…” You should see a window popup that looks like this:
    iis_022
  5. Give it an alias ( we used the same name as the folder  i.e. weborbdan )
  6. Next, browse to the physical path of the folder. The popup should look something like this:iis_032
  7. Now open up a browser and navigate to C:\inetpub\wwwroot\[nameOfYourFolder] ( e.g. we would browse to C:\inetpub\wwwroot\weborbdan )

The strange thing was that we then copied the contents of weborbdan back in to weborb30, and that started working again, so something had obviously gone slightly awry.

Note: If you want to know the difference between an Application & a Virtual Directory look here or here

No comments

WebOrb & .NET (Security Sandbox Violation)

I'm guessing this is a real  [.NET] newbie error but I wanted to record it anyway -  for anyone searching for a potential cause/solution.

Today I installed WebOrb for .NET on Windows7 (IIS7).
I was given a .dll file which I put in my bin folder and I renamed the .dll (bad move!  I was assured that this wouldn't cause any issues but it did).

As you can see below, the error messages I received did not indicate the cause:

Actionscript:
  1. [SWF] /weborb30/NotePerfect_FLEX-debug/NotePerfect_FLEX.swf - 952,782 bytes after decompression
  2. Warning: Failed to load policy file from https://localhost/crossdomain.xml
  3.  
  4. *** Security Sandbox Violation ***
  5.  
  6. Connection to https://localhost/weborb30/NotePerfect_FLEX-debug/weborb.aspx halted - not permitted from http://localhost/weborb30/NotePerfect_FLEX-debug/NotePerfect_FLEX.swf

I had a cross-domain policy in place but still got this error, and I'm not sure why renaming the .dll causes Flex to try to connect over https.  Anyway, re-renaming the file sorts the problem.

No comments

Next Page »

Bad Behavior has blocked 1077 access attempts in the last 7 days.