HTTPService and POST

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

HTTPService and POST

Joanne Seneque
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
Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

Carlos Rovira-2
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.


El jue., 23 jul. 2020 a las 8:48, SENEQUE CRAIG THIERRY (<[hidden email]>) 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


--
Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

Joanne Seneque
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 <[hidden email]> 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 (<
> [hidden email]>) 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
>
Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

Carlos Rovira-2
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
in case you are adding dynamic properties to plain objects

HTH

Carlos

El vie., 24 jul. 2020 a las 10:05, Joanne Seneque (<[hidden email]>) 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 <[hidden email]> 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 (<
> [hidden email]>) 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
>


--
Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

Joanne Seneque
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 <[hidden email]> 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
>(<[hidden email]>)
> 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
>><[hidden email]> 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 (<
>> > [hidden email]>) 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

Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

Piotr Zarzycki
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.


Thanks,
Piotr





On Tue, Jul 28, 2020, 7:28 AM SENEQUE CRAIG THIERRY <[hidden email]> 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 <[hidden email]> 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
>(<[hidden email]>)
> 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
>><[hidden email]> 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 (<
>> > [hidden email]>) 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

Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

Carlos Rovira-2
Hi Piotr,

seems Joanne has problem in part due to MXRoyale not compiled with 

-js-default-initializers=true

(getStaticConstantsByConvention :: the reflection target
mx.rpc.http.mxml.HTTPService was not Compiled with default
initializers enabled)

Don't know if it is possible to add that to MXRoyale. What do you think [hidden email] , [hidden email]  and others?

@Joanne, if you are building from sources, can you try to add that config to MRoyale library?

thanks




El mar., 28 jul. 2020 a las 7:51, Piotr Zarzycki (<[hidden email]>) escribió:
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.


Thanks,
Piotr





On Tue, Jul 28, 2020, 7:28 AM SENEQUE CRAIG THIERRY <[hidden email]> 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 <[hidden email]> 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
>(<[hidden email]>)
> 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
>><[hidden email]> 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 (<
>> > [hidden email]>) 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



--
Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

Joanne Seneque
In reply to this post by Piotr Zarzycki
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 <[hidden email]> 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 <[hidden email]>
> 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 <[hidden email]> 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
> > >(<[hidden email]>)
> > > 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
> > >><[hidden email]> 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 (<
> > >> > [hidden email]>) 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
> >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

Joanne Seneque
Sorry, updated code to be found here instead:
https://bit.ly/2Esj8EQ

On 2020/07/28 13:14:09, Joanne Seneque <[hidden email]> 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 <[hidden email]> 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 <[hidden email]>
> > 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 <[hidden email]> 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
> > > >(<[hidden email]>)
> > > > 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
> > > >><[hidden email]> 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 (<
> > > >> > [hidden email]>) 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
> > >
> > >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

Carlos Rovira-2
Hi Joanne,

I think you're mixing HTTPService classes. Seems Piotr was using the one in Network instead the emulation in MXRoyale.
try to switch to Network one and see if that works for you.


El mar., 28 jul. 2020 a las 15:17, Joanne Seneque (<[hidden email]>) escribió:
Sorry, updated code to be found here instead:
https://bit.ly/2Esj8EQ

On 2020/07/28 13:14:09, Joanne Seneque <[hidden email]> 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 <[hidden email]> 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 <[hidden email]>
> > 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 <[hidden email]> 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
> > > >(<[hidden email]>)
> > > > 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
> > > >><[hidden email]> 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 (<
> > > >> > [hidden email]>) 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
> > >
> > >
> >
>


--
Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

Piotr Zarzycki
In reply to this post by Joanne Seneque
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.


Thanks,
Piotr

wt., 28 lip 2020 o 15:17 Joanne Seneque <[hidden email]> napisał(a):
Sorry, updated code to be found here instead:
https://bit.ly/2Esj8EQ

On 2020/07/28 13:14:09, Joanne Seneque <[hidden email]> 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 <[hidden email]> 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 <[hidden email]>
> > 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 <[hidden email]> 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
> > > >(<[hidden email]>)
> > > > 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
> > > >><[hidden email]> 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 (<
> > > >> > [hidden email]>) 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

Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

Joanne Seneque
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 <[hidden email]> 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 <[hidden email]>
> napisał(a):
>
> > Sorry, updated code to be found here instead:
> > https://bit.ly/2Esj8EQ
> >
> > On 2020/07/28 13:14:09, Joanne Seneque <[hidden email]> 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 <[hidden email]>
> > 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 <
> > [hidden email]>
> > > > 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 <[hidden email]> 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
> > > > > >(<[hidden email]>)
> > > > > > 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
> > > > > >><[hidden email]> 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 (<
> > > > > >> > [hidden email]>) 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>*
>
Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

Carlos Rovira-2
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 (<[hidden email]>) 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 <[hidden email]> 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 <[hidden email]>
> napisał(a):
>
> > Sorry, updated code to be found here instead:
> > https://bit.ly/2Esj8EQ
> >
> > On 2020/07/28 13:14:09, Joanne Seneque <[hidden email]> 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 <[hidden email]>
> > 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 <
> > [hidden email]>
> > > > 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 <[hidden email]> 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
> > > > > >(<[hidden email]>)
> > > > > > 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
> > > > > >><[hidden email]> 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 (<
> > > > > >> > [hidden email]>) 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>*
>


--
Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

Greg Dove
In reply to this post by Carlos Rovira-2


The 'WARNING' is just a warning. It will not appear in a release build. It appears in this case of the HTTPService class because js-default-initializers is off by default in the framework builds.
Ignoring the warning in most cases it will probably be ok (particularly in this case, where there are no actual static constants on the reflection target). But it could result in problems in some rare cases, and the warning would provide a helpful clue for those situations. 
If someone did something like MyClass["MY_FAKE_CONSTANT"] = 'fake' it would incorrectly collect 'MY_FAKE_CONSTANT' as a constant during the Crux reflection checks for a class that did not have js-default-initializers=true when it was compiled. That seems quite rare, so we could perhaps remove this warning. 

What does everyone think?






On Wed, Jul 29, 2020 at 8:02 AM Carlos Rovira <[hidden email]> wrote:
Hi Harbs,

I think [hidden email] could better respond to it. I think all objects injected by Crux need to be compiled with that flag to true to remove that warning. 

El mar., 28 jul. 2020 a las 21:56, Harbs (<[hidden email]>) escribió:
Right. But what values need to be initialized?

On Jul 28, 2020, at 2:29 PM, Carlos Rovira <[hidden email]> wrote:

Hi,

-js-default-initializers=true is required by Crux, but MXRoyale is not compiled with it

El mar., 28 jul. 2020 a las 11:56, Harbs (<[hidden email]>) escribió:
Which initializer is needed?

On Jul 28, 2020, at 12:29 PM, Carlos Rovira <[hidden email]> wrote:

Hi Piotr,

seems Joanne has problem in part due to MXRoyale not compiled with 

-js-default-initializers=true

(getStaticConstantsByConvention :: the reflection target
mx.rpc.http.mxml.HTTPService was not Compiled with default
initializers enabled)

Don't know if it is possible to add that to MXRoyale. What do you think [hidden email] , [hidden email]  and others?

@Joanne, if you are building from sources, can you try to add that config to MRoyale library?

thanks




El mar., 28 jul. 2020 a las 7:51, Piotr Zarzycki (<[hidden email]>) escribió:
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.


Thanks,
Piotr





On Tue, Jul 28, 2020, 7:28 AM SENEQUE CRAIG THIERRY <[hidden email]> 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 <[hidden email]> 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
>(<[hidden email]>)
> 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
>><[hidden email]> 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 (<
>> > [hidden email]>) 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



--



--



--
Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

serkan
In reply to this post by Joanne Seneque
Hi,

I used both HttpService and URLLoader beside custom services for GET and POST and most of them works well.

I used URLLoader for login for example.

Ref : 
https://github.com/likyateknoloji/pinaraui-royale/blob/master/src/com/likya/pinara/main/PinaraUI.mxml
Line : 446

Hope helps.

Serkan.


28.07.2020 22:40 tarihinde Joanne Seneque yazdı:
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 [hidden email] 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 [hidden email]
napisał(a):

Sorry, updated code to be found here instead:
https://bit.ly/2Esj8EQ

On 2020/07/28 13:14:09, Joanne Seneque [hidden email] 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 [hidden email]
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 <
[hidden email]>
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 [hidden email] 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
([hidden email])
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
[hidden email] 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 (<
[hidden email]>) 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>*


Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

Carlos Rovira-2
In reply to this post by Greg Dove
Hi Greg,

I prefer to maintain and maybe could be better to add some docs to Crux with your explanation and a plus could be to add a link to the docs in the warning. So people getting it see the link and could jump to the web to read what it implies. what do you think?



El mié., 29 jul. 2020 a las 1:01, Greg Dove (<[hidden email]>) escribió:


The 'WARNING' is just a warning. It will not appear in a release build. It appears in this case of the HTTPService class because js-default-initializers is off by default in the framework builds.
Ignoring the warning in most cases it will probably be ok (particularly in this case, where there are no actual static constants on the reflection target). But it could result in problems in some rare cases, and the warning would provide a helpful clue for those situations. 
If someone did something like MyClass["MY_FAKE_CONSTANT"] = 'fake' it would incorrectly collect 'MY_FAKE_CONSTANT' as a constant during the Crux reflection checks for a class that did not have js-default-initializers=true when it was compiled. That seems quite rare, so we could perhaps remove this warning. 

What does everyone think?






On Wed, Jul 29, 2020 at 8:02 AM Carlos Rovira <[hidden email]> wrote:
Hi Harbs,

I think [hidden email] could better respond to it. I think all objects injected by Crux need to be compiled with that flag to true to remove that warning. 

El mar., 28 jul. 2020 a las 21:56, Harbs (<[hidden email]>) escribió:
Right. But what values need to be initialized?

On Jul 28, 2020, at 2:29 PM, Carlos Rovira <[hidden email]> wrote:

Hi,

-js-default-initializers=true is required by Crux, but MXRoyale is not compiled with it

El mar., 28 jul. 2020 a las 11:56, Harbs (<[hidden email]>) escribió:
Which initializer is needed?

On Jul 28, 2020, at 12:29 PM, Carlos Rovira <[hidden email]> wrote:

Hi Piotr,

seems Joanne has problem in part due to MXRoyale not compiled with 

-js-default-initializers=true

(getStaticConstantsByConvention :: the reflection target
mx.rpc.http.mxml.HTTPService was not Compiled with default
initializers enabled)

Don't know if it is possible to add that to MXRoyale. What do you think [hidden email] , [hidden email]  and others?

@Joanne, if you are building from sources, can you try to add that config to MRoyale library?

thanks




El mar., 28 jul. 2020 a las 7:51, Piotr Zarzycki (<[hidden email]>) escribió:
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.


Thanks,
Piotr





On Tue, Jul 28, 2020, 7:28 AM SENEQUE CRAIG THIERRY <[hidden email]> 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 <[hidden email]> 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
>(<[hidden email]>)
> 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
>><[hidden email]> 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 (<
>> > [hidden email]>) 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



--



--



--


--
Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

Greg Dove

Hi Carlos, I will give it some thought. What you are proposing makes sense in terms of helping people understand. But the warning is not actually being generated by Crux, but by a reflection utility method that Crux is using.


On Wed, Jul 29, 2020 at 7:45 PM Carlos Rovira <[hidden email]> wrote:
Hi Greg,

I prefer to maintain and maybe could be better to add some docs to Crux with your explanation and a plus could be to add a link to the docs in the warning. So people getting it see the link and could jump to the web to read what it implies. what do you think?



El mié., 29 jul. 2020 a las 1:01, Greg Dove (<[hidden email]>) escribió:


The 'WARNING' is just a warning. It will not appear in a release build. It appears in this case of the HTTPService class because js-default-initializers is off by default in the framework builds.
Ignoring the warning in most cases it will probably be ok (particularly in this case, where there are no actual static constants on the reflection target). But it could result in problems in some rare cases, and the warning would provide a helpful clue for those situations. 
If someone did something like MyClass["MY_FAKE_CONSTANT"] = 'fake' it would incorrectly collect 'MY_FAKE_CONSTANT' as a constant during the Crux reflection checks for a class that did not have js-default-initializers=true when it was compiled. That seems quite rare, so we could perhaps remove this warning. 

What does everyone think?






On Wed, Jul 29, 2020 at 8:02 AM Carlos Rovira <[hidden email]> wrote:
Hi Harbs,

I think [hidden email] could better respond to it. I think all objects injected by Crux need to be compiled with that flag to true to remove that warning. 

El mar., 28 jul. 2020 a las 21:56, Harbs (<[hidden email]>) escribió:
Right. But what values need to be initialized?

On Jul 28, 2020, at 2:29 PM, Carlos Rovira <[hidden email]> wrote:

Hi,

-js-default-initializers=true is required by Crux, but MXRoyale is not compiled with it

El mar., 28 jul. 2020 a las 11:56, Harbs (<[hidden email]>) escribió:
Which initializer is needed?

On Jul 28, 2020, at 12:29 PM, Carlos Rovira <[hidden email]> wrote:

Hi Piotr,

seems Joanne has problem in part due to MXRoyale not compiled with 

-js-default-initializers=true

(getStaticConstantsByConvention :: the reflection target
mx.rpc.http.mxml.HTTPService was not Compiled with default
initializers enabled)

Don't know if it is possible to add that to MXRoyale. What do you think [hidden email] , [hidden email]  and others?

@Joanne, if you are building from sources, can you try to add that config to MRoyale library?

thanks




El mar., 28 jul. 2020 a las 7:51, Piotr Zarzycki (<[hidden email]>) escribió:
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.


Thanks,
Piotr





On Tue, Jul 28, 2020, 7:28 AM SENEQUE CRAIG THIERRY <[hidden email]> 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 <[hidden email]> 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
>(<[hidden email]>)
> 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
>><[hidden email]> 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 (<
>> > [hidden email]>) 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



--



--



--


--
Reply | Threaded
Open this post in threaded view
|

Re: HTTPService and POST

Carlos Rovira-2
Hi Greg,

right, the problem here's a library requires others to be compiled with a special config. If we could ease that would be good. Maybe there's some way for constants to just be compiled in all cases with default initializers, since constants seems to me a special case that always are declared with a value and never change through all its life cycle.

El jue., 30 jul. 2020 a las 5:18, Greg Dove (<[hidden email]>) escribió:

Hi Carlos, I will give it some thought. What you are proposing makes sense in terms of helping people understand. But the warning is not actually being generated by Crux, but by a reflection utility method that Crux is using.


On Wed, Jul 29, 2020 at 7:45 PM Carlos Rovira <[hidden email]> wrote:
Hi Greg,

I prefer to maintain and maybe could be better to add some docs to Crux with your explanation and a plus could be to add a link to the docs in the warning. So people getting it see the link and could jump to the web to read what it implies. what do you think?



El mié., 29 jul. 2020 a las 1:01, Greg Dove (<[hidden email]>) escribió:


The 'WARNING' is just a warning. It will not appear in a release build. It appears in this case of the HTTPService class because js-default-initializers is off by default in the framework builds.
Ignoring the warning in most cases it will probably be ok (particularly in this case, where there are no actual static constants on the reflection target). But it could result in problems in some rare cases, and the warning would provide a helpful clue for those situations. 
If someone did something like MyClass["MY_FAKE_CONSTANT"] = 'fake' it would incorrectly collect 'MY_FAKE_CONSTANT' as a constant during the Crux reflection checks for a class that did not have js-default-initializers=true when it was compiled. That seems quite rare, so we could perhaps remove this warning. 

What does everyone think?






On Wed, Jul 29, 2020 at 8:02 AM Carlos Rovira <[hidden email]> wrote:
Hi Harbs,

I think [hidden email] could better respond to it. I think all objects injected by Crux need to be compiled with that flag to true to remove that warning. 

El mar., 28 jul. 2020 a las 21:56, Harbs (<[hidden email]>) escribió:
Right. But what values need to be initialized?

On Jul 28, 2020, at 2:29 PM, Carlos Rovira <[hidden email]> wrote:

Hi,

-js-default-initializers=true is required by Crux, but MXRoyale is not compiled with it

El mar., 28 jul. 2020 a las 11:56, Harbs (<[hidden email]>) escribió:
Which initializer is needed?

On Jul 28, 2020, at 12:29 PM, Carlos Rovira <[hidden email]> wrote:

Hi Piotr,

seems Joanne has problem in part due to MXRoyale not compiled with 

-js-default-initializers=true

(getStaticConstantsByConvention :: the reflection target
mx.rpc.http.mxml.HTTPService was not Compiled with default
initializers enabled)

Don't know if it is possible to add that to MXRoyale. What do you think [hidden email] , [hidden email]  and others?

@Joanne, if you are building from sources, can you try to add that config to MRoyale library?

thanks




El mar., 28 jul. 2020 a las 7:51, Piotr Zarzycki (<[hidden email]>) escribió:
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.


Thanks,
Piotr





On Tue, Jul 28, 2020, 7:28 AM SENEQUE CRAIG THIERRY <[hidden email]> 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 <[hidden email]> 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
>(<[hidden email]>)
> 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
>><[hidden email]> 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 (<
>> > [hidden email]>) 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



--



--



--


--


--