Thread: [Cppcms-users] jsonrpc web service
Brought to you by:
artyom-beilis
From: Leon <le...@wl...> - 2012-01-12 08:10:55
|
Hi, Thank you for the great framework! I have some questions regarding jsonrpc. 1. How can I upload files using client side javascript (and how to handle it on server side)? 2. The sample jsonrpc server functions all take built-in types as parameters. Can structures or classes be used as parameters? 3. How can I generate api reference for my jsonrpc service? 4. Is there any recommended way for authentication/security? Thanks, Lirong |
From: augustin <aug...@ov...> - 2012-01-12 08:19:12
|
On Thursday, January 12, 2012 04:10:37 PM Leon wrote: > 1. How can I upload files using client side javascript (and how to > handle it on server side)? Hi Leon, I am sorry, I don't have any answers for you. Artyom will certainly be able to help you more ;) However, file upload is a topic that regularly comes up on the mailing list. Unfortunately, previous askers didn't bother documenting the answers and the solutions they got. Could you log into the wiki and prepare a placeholder wiki page about file upload? I don't think one exists already, but you can check. You and others will be able to document tips and tricks about file upload. You can search the mailing list, because as I said, the question came up before... Thanks in advance for your contributions. Good luck, Augustin. -- Friends: http://www.reuniting.info/ My projects: http://astralcity.org/ http://3enjeux.overshoot.tv/ http://linux.overshoot.tv/ http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ http://openteacher.info/ http://minguo.info/ http://www.wechange.org/ http://searching911.info/ . |
From: Leon <le...@wl...> - 2012-01-12 08:27:53
|
Hi Augustin, Thank you for your reply! I tried to register with the wiki but failed. On Thu, Jan 12, 2012 at 4:18 PM, augustin <aug...@ov...> wrote: > On Thursday, January 12, 2012 04:10:37 PM Leon wrote: >> 1. How can I upload files using client side javascript (and how to >> handle it on server side)? > > Hi Leon, > > I am sorry, I don't have any answers for you. Artyom will certainly be able to > help you more ;) > > However, file upload is a topic that regularly comes up on the mailing list. > Unfortunately, previous askers didn't bother documenting the answers and the > solutions they got. Could you log into the wiki and prepare a placeholder wiki > page about file upload? I don't think one exists already, but you can check. > You and others will be able to document tips and tricks about file upload. > > You can search the mailing list, because as I said, the question came up > before... > > Thanks in advance for your contributions. > > Good luck, > > Augustin. > > -- > Friends: http://www.reuniting.info/ > My projects: > http://astralcity.org/ http://3enjeux.overshoot.tv/ http://linux.overshoot.tv/ > http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ > http://openteacher.info/ http://minguo.info/ > http://www.wechange.org/ http://searching911.info/ > > > > > > > > > > > > > . > > ------------------------------------------------------------------------------ > RSA(R) Conference 2012 > Mar 27 - Feb 2 > Save $400 by Jan. 27 > Register now! > http://p.sf.net/sfu/rsa-sfdev2dev2 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: Artyom B. <art...@ya...> - 2012-01-12 09:26:17
|
Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.sf.net/ CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/ ----- Original Message ----- > From: Leon <le...@wl...> > To: cpp...@li... > Cc: > Sent: Thursday, January 12, 2012 10:10 AM > Subject: [Cppcms-users] jsonrpc web service > > Hi, > > Thank you for the great framework! > > I have some questions regarding jsonrpc. > 1. How can I upload files using client side javascript (and how to > handle it on server side)? First of all there are plenty if examples http://art-blog.no-ip.info/cppcms_ref_v0_99/examples_page.html Including file upload http://art-blog.no-ip.info/cppcms_ref_v0_99/ex_uploads.html However, you should not upload files via JSON-RPC for several reasons: 1. JSON does not support binary format, only textual UTF-8 so in order to upload the file via JSON you'll have to encode it for example in base64 format and then decode it on server side. 2. It is much better to upload files via native POST interface and forms. > 2. The sample jsonrpc server functions all take built-in types as > parameters. Can structures or classes be used as parameters? Yes, two options: a) Use JSON value as is and as full json it can be a json object b) Define conversion from JSON to C++ object. See example http://art-blog.no-ip.info/cppcms_ref_v0_99/ex_json____json__cpp.html > 3. How can I generate api reference for my jsonrpc service? You mean simple method description (SMD)? Because it is not fully standardized it is not generated automatically. You can write your own SMD the way you want and set it using smd or smd_raw member functions of json_rpc_service: http://art-blog.no-ip.info/cppcms_ref_v0_99/classcppcms_1_1rpc_1_1json__rpc__server.html > 4. Is there any recommended way for authentication/security? > 1. CppCMS has session management that can be used for authentication. 2. For Ajax POST calls you may want to use CSRF tokens as well. There is a wide guide about it: http://art-blog.no-ip.info/wikipp/en/page/secure_programming > Thanks, > Lirong > Artyom |
From: Leon <le...@wl...> - 2012-01-12 10:05:58
|
Thank you for your answers! Suppose I am using the person class in the json sample, can I do the following? void method(const person &p) {} bind("method",cppcms::rpc::json_method(&json_service::method,this)); Another question is that what classes should I use if I want to use cppcms as a jsonrpc client? Best regards, On Thu, Jan 12, 2012 at 5:25 PM, Artyom Beilis <art...@ya...> wrote: > > > > Artyom Beilis > -------------- > CppCMS - C++ Web Framework: http://cppcms.sf.net/ > CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/ > > > ----- Original Message ----- >> From: Leon <le...@wl...> >> To: cpp...@li... >> Cc: >> Sent: Thursday, January 12, 2012 10:10 AM >> Subject: [Cppcms-users] jsonrpc web service >> >> Hi, >> >> Thank you for the great framework! >> >> I have some questions regarding jsonrpc. >> 1. How can I upload files using client side javascript (and how to >> handle it on server side)? > > First of all there are plenty if examples > > http://art-blog.no-ip.info/cppcms_ref_v0_99/examples_page.html > > Including file upload > > http://art-blog.no-ip.info/cppcms_ref_v0_99/ex_uploads.html > > > However, you should not upload files via JSON-RPC for several reasons: > > 1. JSON does not support binary format, only textual UTF-8 so in order > to upload the file via JSON you'll have to encode it for example > in base64 format and then decode it on server side. > > 2. It is much better to upload files via native POST interface and forms. > > >> 2. The sample jsonrpc server functions all take built-in types as >> parameters. Can structures or classes be used as parameters? > > Yes, two options: > > a) Use JSON value as is and as full json it can be a json object > > b) Define conversion from JSON to C++ object. See example > > http://art-blog.no-ip.info/cppcms_ref_v0_99/ex_json____json__cpp.html > > > >> 3. How can I generate api reference for my jsonrpc service? > > You mean simple method description (SMD)? > > Because it is not fully standardized it is not generated automatically. > > You can write your own SMD the way you want and set it using smd or smd_raw > member functions of json_rpc_service: > > http://art-blog.no-ip.info/cppcms_ref_v0_99/classcppcms_1_1rpc_1_1json__rpc__server.html > > >> 4. Is there any recommended way for authentication/security? >> > > 1. CppCMS has session management that can be used for authentication. > > 2. For Ajax POST calls you may want to use CSRF tokens as well. > > There is a wide guide about it: > > http://art-blog.no-ip.info/wikipp/en/page/secure_programming > >> Thanks, >> Lirong >> > > Artyom > > ------------------------------------------------------------------------------ > RSA(R) Conference 2012 > Mar 27 - Feb 2 > Save $400 by Jan. 27 > Register now! > http://p.sf.net/sfu/rsa-sfdev2dev2 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: Artyom B. <art...@ya...> - 2012-01-12 10:15:28
|
> >T hank you for your answers! > > Suppose I am using the person class in the json sample, can I do the following? > > void method(const person &p) {} > bind("method",cppcms::rpc::json_method(&json_service::method,this)); > Yes > Another question is that what classes should I use if I want to use > cppcms as a jsonrpc client? > CppCMS is server side if you want JavaScript json-rpc client you have plenty tool-kits like Dojo or JQuery. You can also find under contrib/clinet_side/jsonrpc simple implementation of JavaScript jronrpc client. that is used in some examples I liked to. Artyom |