Hi Joanne,

great you make it work finally! :)

but mx:HTTPService should work in that case too. don't know if there's a
bug there or if that case is still not supported. Hope others using mx
version could give us more info about this.

About RemoteObject. For this case I think you'll need for sure MXRoyale
version. The Network version is still in its infancy and MX version was
heavily ported and used in lots of projects now. So no doubt, use MX version

best


El mar., 28 jul. 2020 a las 21:41, Joanne Seneque (<joannesene...@intnet.mu>)
escribió:

> Hi Carlos & Piotr,
>
> Thanks for your help.
>
> It works with http service from module network instead of
> "mx.rpc.http.HTTPService", even if I still see the following warning in
> console:
> [WARNING] getStaticConstantsByConvention :: the reflection target
> org.apache.royale.net.HTTPService was not Compiled with default
> initializers enabled
>
> Below are the updated codes for "beans.mxml" [1] & the login delegate [2]
> (I had to change the delegate/service a bit as it no longer returns an
> AsyncToken object as the "mx" http service did)
>
> I will now try to use RemoteObject and AMF to access other parts of the
> existing PHP server which communicated with the existing flex application
> using AMF. While checking the documentation on RemoteObject [3], I see that
> there implementations using MXRoyale and Network, can I use the "MxRoyale"
> implementation or is it best to use the "network" one ?
>
> Thanks again
> Joanne
>
> [1] https://bit.ly/2DaUYhB
> [2] https://bit.ly/2CZBZGK
> [3]
> https://apache.github.io/royale-docs/features/loading-external-data/remoteobject
>
> On 2020/07/28 13:23:50, Piotr Zarzycki <piotrzarzyck...@gmail.com> wrote:
> > Joanne,
> >
> > My example is showing of usage http service class from module Network [1]
> >
> > import org.apache.royale.net.HTTPService;
> > import org.apache.royale.net.beads.CORSCredentialsBead;
> >
> > URLSearchParams [2] is native HTML/JS class - whatever API is native you
> > can just use it in theory and your code completion should see it - If not
> > something is wrong with you code completion.
> >
> > [1]
> >
> https://github.com/apache/royale-asjs/tree/develop/frameworks/projects/Network/src/main/royale/org/apache/royale/net
> > [2] https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
> >
> > Thanks,
> > Piotr
> >
> > wt., 28 lip 2020 o 15:17 Joanne Seneque <joannesene...@intnet.mu>
> > napisał(a):
> >
> > > Sorry, updated code to be found here instead:
> > > https://bit.ly/2Esj8EQ
> > >
> > > On 2020/07/28 13:14:09, Joanne Seneque <joannesene...@intnet.mu>
> wrote:
> > > > 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 <piotrzarzyck...@gmail.com>
> > > 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 <
> > > joannesene...@intnet.mu>
> > > > > 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 <carlosrov...@apache.org> 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
> > > > > > >(<joannesene...@intnet.mu>)
> > > > > > > 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
> > > > > > >><carlosrov...@apache.org> 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 (<
> > > > > > >> > joannesene...@intnet.mu>) 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
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> >
> > --
> >
> > Piotr Zarzycki
> >
> > Patreon: *https://www.patreon.com/piotrzarzycki
> > <https://www.patreon.com/piotrzarzycki>*
> >
>


-- 
Carlos Rovira
http://about.me/carlosrovira

Reply via email to