コメント (11)

1 mirv によるコメント登録時刻 固定リンク

I found this article to be very useful! Thanks for sharing it.

2 Nathan Hazout によるコメント登録時刻 固定リンク

Additional reading: http://www.ibm.com/developerworks/websphere/techjournal/1212_paris/1212_paris.html

3 Mikalai Zaikin によるコメント登録時刻 固定リンク

Hice article, thanks. Is it possible to use Java language for Adapter, for example to prepare coplicated HTTP binary request and send it to the backed application?

4 Nathan Hazout によるコメント登録時刻 固定リンク

nzaikin - absolutely. See http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/04_08_Using_Java_in_adapters.pdf
Also http://pic.dhe.ibm.com/infocenter/wrklight/v6r1m0/topic/com.ibm.worklight.dev.doc/devref/t_calling_java_code_from_a_javas.html

5 Mikalai Zaikin によるコメント登録時刻 固定リンク

Thanks, Nathan ! Great links.

 
Now I have one more quick question question: is there any storage like HTTP session from Java Servlet API? Probably should be... Could the [same] storage be accessed from within JavaScript adapater and/or Java code invoked by adapter (I saw some object WorklightBundles exists, maybe through it or similar class)
 
Best regards,
MZ

6 Nathan Hazout によるコメント登録時刻 固定リンク

nzaikin - since we are getting kind of out of the scope of this article, may I suggest you ask this question on StackOverflow.com (with the tags worklight and worklight-adapters) so that this topic can be found by more people searching online in the future?

7 Mikalai Zaikin によるコメント登録時刻 固定リンク

Thanks, Nathan!

 
Hopefully documentation covers this, will try to look up in the infocenter.
 
Best regards,
MZ

8 supal によるコメント登録時刻 固定リンク

Hi Nathan,

 
I have some issue on getting the response with full content. Seems it gets truncated as a result I am getting Error :
"exception. TypeError: Cannot read property 'isSuccessful' of undefined"
 
The response I got that truncated is as below.
{"responseID":"1","statusCode":200,"text":"\0\0\0 ftypisom\0\0\u0002\0isomiso2avc1mp41\0\0\u001a\bmoov
 
My Http adapter is calling GET REST service that retries binary content (.mp4) and response back as above.
 
When I run the standalone adapter , I am getting response as below :
{
"errors": [
],
"info": [
],
"isSuccessful": true,
"responseHeaders": {
"Cache-Control": "no-cache",
"Content-Length": "1393457",
"Content-Type": "application\/octet-stream",
"Date": [
"Sun, 23 Mar 2014 18:06:35 GMT",
"Sun, 23 Mar 2014 18:06:35 GMT"
],
"Expires": [
"Sun, 23 Mar 2014 18:06:35 GMT",
"Sun, 23 Mar 2014 18:06:35 GMT"
],
"Pragma": [
"no-cache",
"no-cache"
],
"Server": "Jetty(6.1.26.cloudera.2)"
},
"responseTime": 10042,
"statusCode": 200,
"statusReason": "OK",
"text": "\0\0\0 ftypisom\0\0\u0002\0isomiso2avc1mp41\0\0\u001a\bmoov\0\0\0lmvhd\
 
But when I call from android main.js the response gets truncated as a result it throws Error :
"exception. TypeError: Cannot read property 'isSuccessful' of undefined"
 
Can you please provide me some clue?

9 Raanan Avidor によるコメント登録時刻 固定リンク

@supal.
One does not simply send an a binary file in a JSON object. it must be a string.
You need to convert the binary file to a base64 string and send it.

10 supal によるコメント登録時刻 固定リンク

Thanks a lot Rannon.
Just one quick info, once I convert the binary (which .mp4,) to a base64 string and then can I pass that base64 string to any player to play it or should I need to decode back the bas364 to binary and use it?

11 supal によるコメント登録時刻 固定リンク

Hi Raanan,

 
When my HTTPAdapter (MyAdapter) calls the REST service, it is sending back response as JSON format as below where "text" property contain the binary code:
 
"isSuccessful": true,
"responseTime": 10042,
"statusCode": 200,
"statusReason": "OK",
"text": "\0\0\0 ftypisom\0\0\u0002\0isomiso2avc1mp41\0\0\u001a\bmoov\0\0\0"
 
In my android Application I call the adapter in following way:
var invocationData = {
adapter : 'MyAdapter',
procedure : 'getData',
compressResponse : true
};
 
WL.Client.invokeProcedure(invocationData, {
onSuccess : handleSuccessStreamVideo,
onFailure : handleFailure,
timeout: 120000
});
 
Now my question : Is there any way I can control in worklight programatically to transform or convert byte stream to base64 string during onSucess process, prior send back to application ? Can I do the following :
1) need to grab the bytestream
2) run custom xslt to the convert byte stream (contained in the JSON "text" property ) to base64 string.
3) And send back the JSON to APP
 
Appreciate if you can shed some light.