SWX Error #2100... Empty ByteArray

85 views
Skip to first unread message

Bear Man Gun

unread,
Aug 18, 2009, 8:06:45 AM8/18/09
to SWX: The Native Data Format for Adobe Flash
Hi all,

Aral sent me over this way trying to find an answer to my problem.

Here is the case:

I am calling to one of my services that is to return an Array of
objects. If I use the Service Browser ( gateway amf.php ) all comes
back as expected. However, when I make the same call from the Flash
app ( gateway sxw.php ) I am returned with this error: Unable to parse
content: Error #2100: The ByteArray parameter in Loader.loadBytes()
must have length greater than 0.

I can't understand why all data would be correctly formatted and
showing up in the Service Browser yet chocking in my Flash app. I have
triple checked everything.

Please help!!

Thank you,

James

Ben Lagoutte

unread,
Aug 18, 2009, 7:27:56 PM8/18/09
to swx-f...@googlegroups.com
Hi James,

Well the service explorer always throws people off. It's quite possible it works in the service explorer but not with swx because the swx explorer uses a flavour of AMF and doesn't actually uses swx (not sure why it was designed like that, but i think that comes from the times when we didn't have an AS3 version, which would be required for the Flex-made explorer to work)... anyway, using the service explorer really only tests that your PHP service works, it doesn't validate the swx communication part  (maybe the dev team should look into making a version that only uses the swx gateway).

Anyhoo, all that to say it's possible it works in the Explorer but not in your flash app. 

The error looks like it's not receiving the response.. Are you doing a cross domain request? 
On top of the cross domain policy file you need to explicitly initialize the swx request object as described here: 

Can you send a sample of your code otherwise? 

Ben

Bear Man Gun

unread,
Aug 18, 2009, 7:36:46 PM8/18/09
to SWX: The Native Data Format for Adobe Flash
Hey Ben,

Thanks for taking the time to get back to me on that. I figured that
may have been the case and went ahead and switched over to using amf-
php for this project. All works well now. It would be a good idea for
the future that the explorer actually runs off of the SWX gateway to
not confuse users.

Just to give you a little heads-up on what I am working on - I am
using amf to tap into wordpress' internal functions by including the
wp-headers.php in my globals.php file. So far it's working great but
SWX can not ( I don't know why ) do this. No matter what call I make
using the internal wordpress API my return chocks with the same error
yet in AMF-PHP it works as expected.

I would love to know why you think that is. I am not a php coder so I
really have no clue what's happening here.

Thanks for your time!!!

Cheers.

Ben Lagoutte

unread,
Aug 18, 2009, 8:11:29 PM8/18/09
to swx-f...@googlegroups.com
Hey James,

Sorry you couldn't get it to work. I believe someone did write a
Wordpress service class for swx, you could hunt it down.

Which version of wordpress are you using anyway? I don't see a wp-
headers.php on the latest ones..

if you're talking about wp-blog-headers.php this won't work. Afaik the
wp() function inside it will cause the response to be tagged as 404
because wordpress doesn't understand where the page fits in. This
might be enough to throw swx off, maybe amf is a bit tolerant with the
response code as long as the body contains a valid response (You can
check these with an Http proxy like Fiddler or Charles).

To access the wordpress functionalities outside of the wordpress
structures, I found that the following code was enough to bootstrap it
and have access to the main things like wpdb. I've successfully used
it to write json services to access wordpress elements:

<?php
require_once('./wp-load.php');

/** do you things here */

?>

Maybe you can tweak the swx.php gateway and add something similar to
it to enable access the wordpress api ? obviously the path to wp-load
might be a bit different, not sure if that would work...

Hope this helps

Cheers
Ben
Reply all
Reply to author
Forward
0 new messages