<p>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.</p>

<p>On the client side, I am using Flex <strong>RemoteObject</strong> methods. </p>

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

[{'answer_id': 81607, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>You might be trying to re-invent the wheel. Is there a reason you can't use the standard HTTP(s) authentication?</p>\n"}, {'answer_id': 133095, 'author': 'Verdant', 'author_id': 450527, 'author_profile': 'https://Stackoverflow.com/users/450527', 'pm_score': 1, 'selected': False, 'text': '<p>RemoteObject uses AMF as the data channel, and is managed in a completely different way than HttpService or WebService (which use Http). \nWhat you can do, is call <code>setCredentials(username,password)</code> and then capture this on the server side using the FlexLoginCommand (either the standard one for your container, or derive your own).\nLookup <code>setCredentials</code> and how you should handle this on both sides (client and server).</p>\n'}, {'answer_id': 776559, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>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.\nOn 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. \nThe 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?</p>\n"}, {'answer_id': 3156087, 'author': 'Radek', 'author_id': 380861, 'author_profile': 'https://Stackoverflow.com/users/380861', 'pm_score': 1, 'selected': False, 'text': '<p>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.</p>\n\n<p>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</p>\n\n<pre><code>document.cookie="clientVersion=1.0;expires=2100-01-01;path=/";\n</code></pre>\n\n<p>Browser should transfer it to server, and you can filter (problem will be if the user will have cookies turned off).</p>\n\n<p>Much more you can invoke JavaScript functions from Flex (more is here: <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_4.html" rel="nofollow noreferrer">http://livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_4.html</a>).</p>\n'}, {'answer_id': 3178195, 'author': 'hongo', 'author_id': 383503, 'author_profile': 'https://Stackoverflow.com/users/383503', 'pm_score': 2, 'selected': False, 'text': '<p>I couldnt modify http request from flex, instead I can add custom headers to the <code>mx.messaging.messages.IMessage</code> that <code>RemoteObject</code> sends to the server and there, extending <code>flex.messaging.services.remoting.adapters.JavaAdapter</code> (used for accessing Spring beans), it\'s posible to read the header parameters and put them into the HTTPRequest.</p>\n\n<p>In the flex part, I had to extend <code>mx.rpc.AsyncRequest</code>:\ndeclares a new property "header" and overwrites invoke method that checks if there is a not null value for set the msg.headers.</p>\n\n<p>and <code>mx.rpc.remoting.mxml.RemoteObject</code>: \nthe constructor creates a new instance of our custom AsyncRequest and overwrite old <code>AsyncRequest</code> and it defines a <code>setHeaders</code> method that set the argument to the custom <code>AsyncRequest</code>.</p>\n\n<p><code>com.asfusion.mate.actions.builders.RemoteObjectInvoker</code> (extra :P): \nthis one reads the param declared in the Mate\'s map <code>RemoteObjectInvoker</code> and puts in the <code>RemoteObject</code> header.</p>\n\n<p>I hope it will be understandable (with my apache english xDDD)</p>\n\n<p>Bye. Agur!</p>\n'}, {'answer_id': 15371118, 'author': 'Marcelo Rodovalho', 'author_id': 1213594, 'author_profile': 'https://Stackoverflow.com/users/1213594', 'pm_score': -1, 'selected': False, 'text': "<p>You can debug the $GLOBALS in PHP to see that.\nI think this is in the </p>\n\n<pre><code>$GLOBALS['HTTP_RAW_POST_DATA'];\n</code></pre>\n\n<p>or you can simple do </p>\n\n<pre><code>file_get_contents('php://input');\n</code></pre>\n"}, {'answer_id': 26745792, 'author': 'yiotix', 'author_id': 2435139, 'author_profile': 'https://Stackoverflow.com/users/2435139', 'pm_score': 0, 'selected': False, 'text': "<p>We recently run into the same issue and this is how we added our custom headers without creating a subclass:</p>\n\n<pre><code>var operation:AbstractOperation = _remoteSession.getOperation('myRemoteOperation');\nvar async:AsyncRequest = operation.mx_internal::asyncRequest;\nasync.defaultHeaders = {my_header:'my_value'};\n</code></pre>\n\n<p>The AsyncRequest object is actually accessible via the operation object via the mx_internal namespace.</p>\n"}, {'answer_id': 29437014, 'author': 'Ronny Shibley', 'author_id': 3040886, 'author_profile': 'https://Stackoverflow.com/users/3040886', 'pm_score': 2, 'selected': False, 'text': '<p>This worked for me using BlazeDS and Spring-Flex 1.5.2</p>\n\n<p><strong>Flex:</strong></p>\n\n<pre><code>use namespace mx_internal;\n\nvar service:RemoteObject = new RemoteObject(destination);\nvar operation:Operation = service[functionName];\noperation.asyncRequest.defaultHeaders  = {company:\'company\'};\n\nvar token:AsyncToken =  operation.send();\n</code></pre>\n\n<p>Java Spring-Flex:</p>\n\n<pre><code>public class FlexJavaCustomAdapter extends JavaAdapter{\n    @Override\n    public Object invoke(Message message) {\n        String locale = (String) message.getHeader("com.foo.locale");   \n        return super.invoke(message);\n    }   \n}\n</code></pre>\n\n<p><strong>dispatcher-servlet.xml</strong></p>\n\n<pre><code>&lt;bean id="customAdapter" class="org.springframework.flex.core.ManageableComponentFactoryBean"&gt;\n            &lt;constructor-arg value="com.codefish.model.flex.FlexJavaCustomAdapter"/&gt;\n        &lt;/bean&gt; \n\n        &lt;flex:message-broker id="_messageBroker"  services-config-path="classpath*:/com/codefish/resources/spring/services-config.xml"  &gt; \n              &lt;flex:remoting-service default-adapter-id="customAdapter" \n            default-channels="my-amf, my-secure-amf" /&gt;\n        &lt;/flex:message-broker&gt;\n&lt;/bean&gt;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/81548', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11897/']