Re: [Cppcms-users] jsonrpc web service
Brought to you by:
artyom-beilis
|
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
|