Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7596091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:50:06+00:00 2026-05-30T21:50:06+00:00

I have a Java-based server side and a flex client side using Spring BlazeDS

  • 0

I have a Java-based server side and a flex client side using Spring BlazeDS Integration. It works fine, but I want to get sound from server side recently.

I followed this BlazeDS mapping doc, it says when Java return a Byte[], it will be converted to ByteArray which I want. So I handle the MP3 file by ByteArrayOutputStream, convert it to Byte[] and return it back to front-end, but the value that Actionscript gets turns to be null value.

public Byte[] sayHello() {
    Byte[] ba = null;

    try {
        FileInputStream fis = new FileInputStream(
                "D:/e/Ryan Adams - I Wish You Were Here.mp3");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] buffer = new byte[8192];
        int bytesRead;
        while ((bytesRead = fis.read(buffer)) > 0) {
            baos.write(buffer, 0, bytesRead);
        }

        byte[] byteArray = baos.toByteArray();
        ba = new Byte[byteArray.length];

        for (int i = 0; i < byteArray.length; i++) {
            ba[i] = Byte.valueOf(byteArray[i]);
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return ba;
}

The ActionScript code:

<s:RemoteObject id="ro" destination="helloWorldService" fault="handleFault(event)">
    <s:channelSet>
        <s:ChannelSet>
            <s:AMFChannel uri="/flexspring/messagebroker/amf"/>
        </s:ChannelSet>
    </s:channelSet>
</s:RemoteObject>

...

private function loaded():void {
    var bArr:ByteArray = ro.sayHello() as ByteArray;
    l.text = "" + (bArr == null);
}

...

<s:Label id="l" text=""/>

And it says “true”. Does anyone have any idea what’s the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:50:07+00:00Added an answer on May 30, 2026 at 9:50 pm

    The problem with your code is that all flex calls over a BlazeDS are async. So, ro.SomeMethod() doesn’t return immediately, it queues it up and then does callbacks as necessary.

    Here’s an example of something that works Note that I’ve never sent byte[] over a BlazeDS connection, but I don’t see why it wouldn’t work — as J_A_X suggests, you probably want to stream the sound, rather than sending the whole thing at once.

    Anyway – here’s the example:

    public function loaded():void
    {
       var token:AsyncToken = ro.sayHello();
       token.addResponder(new mx.rpc.Responder(result, fault));
       // ...Code continues to execute...
    }
    
    public function result(event:ResultEvent):void
    {
       // The byte[] is in event.result
       var bArr:ByteArray = event.result as ByteArray;
    }
    
    public function fault(event:FaultEvent):void 
    {
       // Something went wrong (maybe the server on the other side went AWOL) 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java based web-application using Java Server Faces and Facelets. I am
I have a 100% Flex based enterprise web application with a Java/BlazeDS backend. In
I currently have a client/server application which is based on Windows technology (using C#
I have a java requirment contains both client and server side program. Server side
I want to have achieve something similar to Java Tiles framework using only client
We have a Java EE-based web application running on a Glassfish app server cluster.
Because I didn't want to implement a communication protocol for my client-server based application,
I have recently been investigating java server-side web frameworks to serve as a rendering
I have limited knowledge of Java-based technologies, and for business enforced reasons, I may
I have a legacy Java webservice based on Axis2. This webservice classes consist of:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.