luke315774
Posts: 0
Joined: Mon Mar 17, 2014 6:33 pm

REST javascript implementation - Set parameter before invoke

I have this GenericSecurityContext :

Image

I want to set the "session" parameter in the javascript implementation before invoking the service call. So I've done :

Appery.BergerRESTImplementation = Appery.createClass(SecurityContext, {

invoke: function(service, settings) {
// Before invoke

Code: Select all

     settings.ssc_data.session = getSessionParam(localStorage.getItem("_user"), localStorage.getItem("_sessionid"), localStorage.getItem("_appserver"), localStorage.getItem("_environment")); 

     Appery.BergerRESTImplementation.$super.invoke.call(this, service, settings); 

}
});

The parameter is still set to the default value when the service get called. Is it the proper way of doing this?

Thank you for the help.

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

REST javascript implementation - Set parameter before invoke

Hello,

What is codesettings.ssc_data.session/code in your code?
You could set header or some parameter
pre
code
invoke: function(service, settings) {
settings.data.session = "123&quot
settings.headers.session = "456&quot

Code: Select all

 Appery.BergerRESTImplementation.$super.invoke.call(this, service, settings);  

}
/code
/pre

luke315774
Posts: 0
Joined: Mon Mar 17, 2014 6:33 pm

REST javascript implementation - Set parameter before invoke

I keep on getting the default value in my "session" parameter. Even with this code :

Appery.BergerRESTImplementation = Appery.createClass(SecurityContext, {

invoke: function(service, settings) {
// Before invoke
alert('before');

Code: Select all

     settings.data.session = "new session value"; 

     Appery.BergerRESTImplementation.$super.invoke.call(this, service, settings); 

     // After invoke 
     alert('after'); 

}

});

The console tell me settings.data.session is "undefined". How can I set a parameter in my custom Javascript implementation? The said parameter being declared in my service definition.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

REST javascript implementation - Set parameter before invoke

Hello!

[quote:]The console tell me settings.data.session is "undefined"[/quote] could you clarify how do you check it? In console on network tab check if data specified in SecurityContext is sent?

luke315774
Posts: 0
Joined: Mon Mar 17, 2014 6:33 pm

REST javascript implementation - Set parameter before invoke

Hello,

this morning, it now work as expected. I'm sorry. There seem to be some strange behavior with service parameter sometime.

I'm happy it's working. Thanks

luke315774
Posts: 0
Joined: Mon Mar 17, 2014 6:33 pm

REST javascript implementation - Set parameter before invoke

Image

There you see it. "blablabla" is the default value in the service definition. As if this line as no effect at all on the session parameter.. : settings.data.session = "new session value";

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

REST javascript implementation - Set parameter before invoke

Hi Luke,

You can write in parameter URL codehttp://example.com/?session={session}/code and add a request parameter 'session'. Appery.io will automatically replace {session} with a value of that parameter.

luke315774
Posts: 0
Joined: Mon Mar 17, 2014 6:33 pm

REST javascript implementation - Set parameter before invoke

That is exactly what I have done and it is not working. That is why I wrote here...

Here are screenshots of what I have. First, my generic service declaration :
Image

Second, my javascript implementation where I try to set my session parameter :

Image

Next, the actual service definition that use the generic security service :

Image

As you can see from my previous post, the value of session when executing is always the "Default" value set in the generic security service definition.

I must be doing something wrong?
Thank you for your help, I appreciate.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

REST javascript implementation - Set parameter before invoke

Luke,

You use Method=post and Content Type=xml, in this case in Security context Service settings.data - is a string, that includes xml. And settings.data.session = ...
won't have any effect,

You should add necessary xml tag into xml string storing in settings.data

luke315774
Posts: 0
Joined: Mon Mar 17, 2014 6:33 pm

REST javascript implementation - Set parameter before invoke

Ok cool.

Thank you. Your support is very appreciated and invaluable to the delivery of our project.

Return to “Issues”