views:

2119

answers:

7

I am running blazeds on the server side. I would like to filter http requests using an http header. My goal is to send extra parameters to the server without changing the signatures of my blazeds services.

On the client side, I am using Flex RemoteObject methods.

With Flex WebService components, it is possible to set an http header using the property httpHeaders. I have not found anything similar on the RemoteObject class...

A: 

You might be trying to re-invent the wheel. Is there a reason you can't use the standard HTTP(s) authentication?

No I cannot use HTTP authenticvcation, I have a very specific need.
Alexandre Victoor
+1  A: 

RemoteObject uses AMF as the data channel, and is managed in a completely different way than HttpService or WebService (which use Http). What you can do, is call setCredentials(username,password) and then capture this on the server side using the FlexLoginCommand (either the standard one for your container, or derive your own). Lookup setCredentials and how you should handle this on both sides (client and server).

Verdant
RemoteObject calls are made over HTTP, it's just that the content is encoded in Action Message Format (AMF).
cliff.meyers
A: 

A reason I was thinking too to use http headers was for the server to be able to 'recognize' the flex client in the a context of service versionning. On the server I can always build an indirection/proxy that would allow the different clients to only use 1 end point and route to the right adapter depending on the client version. The question is on the client side. How would the server identify the flex client token or 'version'. One way is certainly via authentication. But, assuming there is not authentication involved?

elextra
A: 

Hi Alex,

I am having very similar needs and I was wandering if you would share the solution you've found ... if you've found one of course.

Thanks,

Naso.

Naso
A: 

Have you ever found a solution to this? I need this also.

festerwim
A: 

I have similar problem, and I afraid there is no simple way to set HTTP header when using AMF. But I've designed following solution.

Flex uses HTTP to transfer AMF, but invokes it through browser interfaces, this allows you to set cookie. Just in document containing application invoke following JavaScript

document.cookie="clientVersion=1.0;expires=2100-01-01;path=/";

Browser should transfer it to server, and you can filter (problem will be if the user will have cookies turned off).

Much more you can invoke JavaScript functions from Flex (more is here: livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_4.html).

Kind regards,
Radek
http://softperience.eu

A: 

Hi there!

I couldnt modify http request from flex, instead I can add custom headers to the mx.messaging.messages.IMessage that RemoteObject sends to the server and there, extending flex.messaging.services.remoting.adapters.JavaAdapter (used for accessing Spring beans), it's posible to read the header parameters and put them into the HTTPRequest.

In the flex part, I had to extend mx.rpc.AsyncRequest: declares a new property "header" and overwrites invoke method that checks if there is a not null value for set the msg.headers.

and mx.rpc.remoting.mxml.RemoteObject: the constructor creates a new instance of our custom AsyncRequest and overwrite old AsyncRequest and it defines a setHeaders method that set the argument to the custom AsyncRequest.

com.asfusion.mate.actions.builders.RemoteObjectInvoker (extra :P): this one reads the param declared in the Mate's map RemoteObjectInvoker and puts in the RemoteObject header.

I hope it will be understandable (with my apache english xDDD)

Bye. Agur!

hongo