Hi Piotr, Thanks for the example - I tried modifying my code but now I am having compilation errors :
C:\Dev\moonshine\ESSLite\src\service\LoginDelegate.as(34): col: 17 Error: Access of possibly undefined property contentData through a reference with static type mx.rpc.http.HTTPService. : : loginService.contentData = urlParams; Is the example you provided using "mx.rpc.http.HTTPService" ? Because I can't seem to find the property "contentData" on the HTTPService instance (looked through the asDocs here [1]) Also, I can't find the "URLSearchParams" either in the docs... and I tried to replace that with "org.apache.royale.net.URLVariables" - is this OK or it's not the same thing at all ? see [2] for the updated code. The project I am working on is to be compiled for "JS" only. Thanks for your help. Joanne [1] https://royale.apache.org/asdoc/index.html#!mx.rpc.http/HTTPService [2] https://www.paste.org/flatcode/108158 On 2020/07/28 05:51:03, Piotr Zarzycki <[email protected]> wrote: > Hi Joanne, > > Here is how we are sending POST with some parameters. [1] In that case > parameter one parameter called "dominoXML" > > I hope it helps. > > [1] https://paste.apache.org/x22su > > Thanks, > Piotr > > > > > > On Tue, Jul 28, 2020, 7:28 AM SENEQUE CRAIG THIERRY <[email protected]> > wrote: > > > Hi Carlos, > > > > I added the optional compiler parameters: > > > > -js-default-initializers=true > > -js-dynamic-access-unknown-members=true > > > > But am still having the warning in console: > > getStaticConstantsByConvention.js:52 [WARNING] > > getStaticConstantsByConvention :: the reflection target > > mx.rpc.http.mxml.HTTPService was not Compiled with default > > initializers enabled > > > > And also my POST param is still blank on server request... > > When using same request but in flex3 (by the way I am > > re-writing the client side of an existing application > > developed with flex and actionscript - with apache royale) > > and I would like to re-use the existing server functions > > (which is in PHP) - when the same request is called from > > old flex application - the POST params are present... But > > when called using HTTPService from apache royale - it is > > blank :( > > > > Do you have an example using HTTPService with POST > > parameters that work ? > > > > Thanks & Regards > > Joanne > > > > > > > > On Fri, 24 Jul 2020 10:20:28 +0200 > > Carlos Rovira <[email protected]> wrote: > > > Hi Joanne, > > > > > > "getStaticConstantsByConvention" problem use to be > > >solved using the > > > optional compilation parameter: > > >*-js-default-initializers=true* > > > > > > (See this link: > > > > > https://apache.github.io/royale-docs/create-an-application/optimizations/compiler-configuration-settings.html#default-initializers > > > ) > > > > > > In Royale by default the variables are not initialized > > >unlike in Flash / > > >Flex. > > > Crux needs for some things that these variables are > > >initialized. > > > > > > Also maybe you need to add > > >-js-dynamic-access-unknown-members=true > > > ( > > > > > https://apache.github.io/royale-docs/create-an-application/optimizations/compiler-configuration-settings.html#dynamic-access-unknown-members > > > ) > > > in case you are adding dynamic properties to plain > > >objects > > > > > > HTH > > > > > > Carlos > > > > > > El vie., 24 jul. 2020 a las 10:05, Joanne Seneque > > >(<[email protected]>) > > > escribió: > > > > > >> Hi Carlos, > > >> Thanks for the reply, I added traces to the code (client > > >>+ server side) > > >> and was able to debug up to the point where the message > > >>is constructed & > > >> sent to server (in > > >>mx.rpc.http.AbstractOperation.prototype.sendBody ) > > >> ---- > > >> message.contentType = > > >>"application/x-www-form-urlencoded" > > >> message.method = "POST" > > >> message.body = {loginMode: "1", pwd: "jbggAFxcXFx7", > > >>scope: > > >> "jbggAFdXV1fSpQ9e", username: "jbggAFhYWFgPvC96U1U="} > > >> message.httpHeaders = {} > > >> ---- > > >> We can see that the "body" contains the object to be > > >>sent to the PHP > > >> service / request call... > > >> But in my PHP log: > > >> > > >> 2020-07-24 11:45:04 +04:00 --- info: request method: > > >>POST > > >> 2020-07-24 11:45:04 +04:00 --- info: php input: > > >> 2020-07-24 11:45:04 +04:00 --- info: user: > > >> 2020-07-24 11:45:04 +04:00 --- info: pwd: > > >> 2020-07-24 11:45:04 +04:00 --- info: scope: > > >> 2020-07-24 11:45:05 +04:00 --- error: Login - Scope is > > >>not valid. > > >> 2020-07-24 11:45:05 +04:00 --- error: Login - Blank user > > >>or password given > > >> --------------------------- > > >> > > >> One thing I saw in the browser console is the following > > >>warning: > > >> [WARNING] getStaticConstantsByConvention :: the > > >>reflection target > > >> mx.rpc.http.mxml.HTTPService was not Compiled with > > >>default initializers > > >> enabled > > >> org.apache.royale.reflection.utils.getStaticConstantsByConvention > > >>@ > > >> getStaticConstantsByConvention.js:52 > > >> org.apache.royale.crux.reflection.TypeDescriptor.fromTypeDefinition > > >>@ > > >> TypeDescriptor.js:194 > > >> org.apache.royale.crux.reflection.TypeCache.getTypeDescriptor > > >>@ > > >> TypeCache.js:64 > > >> org.apache.royale.crux.BeanFactory.constructBean @ > > >>BeanFactory.js:577 > > >> org.apache.royale.crux.BeanProvider.initializeBeans @ > > >>BeanProvider.js:79 > > >> org.apache.royale.crux.BeanProvider.initialize @ > > >>BeanProvider.js:65 > > >> org.apache.royale.crux.Crux.constructProviders @ > > >>Crux.js:169 > > >> org.apache.royale.crux.Crux.init @ Crux.js:145 > > >> org.apache.royale.crux.Crux.set__strand @ Crux.js:233 > > >> org.apache.royale.core.ElementWrapper.addBead @ > > >>ElementWrapper.js:120 > > >> org.apache.royale.core.HTMLElementWrapper.addBead @ > > >> HTMLElementWrapper.js:50 > > >> org.apache.royale.jewel.Application.start @ > > >>Application.js:260 > > >> (anonymous) @ (index):560 > > >> > > >> Could this be linked to my issue (i.e. POST content is > > >>blank on PHP > > >> server) ? > > >> > > >> Thanks & Regards > > >> Joanne > > >> > > >> > > >> > > >> On 2020/07/23 07:45:44, Carlos Rovira > > >><[email protected]> wrote: > > >> > Hi Joanne, > > >> > > > >> > Here's a working example that uses mx:HTTPService with > > >>Crux [1], very > > >> > similar to your code. > > >> > > > >> > can't see any issue in your code. Just ensure the > > >>service is responding > > >> > correctly and put some traces in the classes to detect > > >>the point where it > > >> > is failing. > > >> > > > >> > [1] > > >> > > > >> > > https://github.com/codeoscopic/avant2-website/blob/master/avant2-products-companies/src/main/royale/com/codeoscopic/avant/config/Beans.mxml > > >> > > > >> > El jue., 23 jul. 2020 a las 8:48, SENEQUE CRAIG > > >>THIERRY (< > > >> > [email protected]>) escribió: > > >> > > > >> > > Hi, I am using an HTTPService to make a POST request > > >>to a > > >> > > PHP server - the issue I am having is that the POST > > >> > > data/params is not retrieved on the server... > > >> > > Below is my code in delegate file (I followed > > >>examples > > >> > > using 'crux'): > > >> > > > > >> > > Beans.mxml > > >> > > > > >> > > <crux:BeanProvider > > >> > > xmlns:fx="http://ns.adobe.com/mxml/2009" > > >> > > > > >> xmlns:crux="library://ns.apache.org/royale/crux" > > >> > > xmlns:mx="library://ns.apache.org/royale/mx" > > >> > > xmlns:model="model.*" > > >> > > xmlns:service="service.*" > > >> > > xmlns:controller="controller.*"> > > >> > > > > >> > > <!-- services config --> > > >> > > <mx:HTTPService id="loginService" > > >>showBusyCursor="true"/> > > >> > > > > >> > > LoginDelegate.as > > >> > > package service > > >> > > { > > >> > > import > > >>org.apache.royale.events.IEventDispatcher; > > >> > > import mx.rpc.AsyncToken; > > >> > > import mx.rpc.http.HTTPService; > > >> > > > > >> > > /** > > >> > > * @royalesupresspublicvarwarning > > >> > > */ > > >> > > public class LoginDelegate > > >> > > { > > >> > > > > >> > > [Dispatcher] > > >> > > public var > > >>dispatcher:IEventDispatcher; > > >> > > > > >> > > [Inject('loginService')] > > >> > > public var loginService:HTTPService; > > >> > > > > >> > > public function LoginDelegate() { > > >> > > } > > >> > > > > >> > > public function > > >>login(loginURL:String, > > >> > > params:Object):AsyncToken { > > >> > > loginService.method = > > >>"POST"; > > >> > > loginService.url = loginURL > > >>+ 'login_web'; // > > >> > > "login_URL" is for e.g. http://localhost/mySite/ > > >> > > > > >> > > > > >> > > return > > >>loginService.send(params); // "params" > > >> is > > >> > > an > > >> > > object as {user: xxx:, pwd: 123} > > >> > > } > > >> > > } > > >> > > } > > >> > > > > >> > > ------------ > > >> > > > > >> > > On my PHP server both the "$_POST" and > > >> > > "file_get_contents('php://input')" returns blank... > > >> > > > > >> > > Did I miss something on the HTTPService ? Or is > > >>there > > >> > > another way to pass data through POST request ? > > >> > > > > >> > > > > >> > > Thanks & Regards > > >> > > > > >> > > Joanne > > >> > > > > >> > > > >> > > > >> > -- > > >> > Carlos Rovira > > >> > http://about.me/carlosrovira > > >> > > > >> > > > > > > > > > -- > > > Carlos Rovira > > > http://about.me/carlosrovira > > > > >
