Re: [Cppcms-users] CppCMS handle SOAP or RESTful like Web Services?
Brought to you by:
artyom-beilis
|
From: <ele...@ex...> - 2012-04-22 02:59:05
|
#include <cppcms/http_request.h>
Petr
> ... since i asked something that RTFM could have solved, i wrote the
> RESTful WS example (attached). i hope that's what everybody has in mind.
> i am open to learning.
>
> a couple of things i have yet to figure out:
>
> if (request().request_method() != "GET") ...
>
> if (request().content_type() == "application/xml") ...
>
> gave me errors at compilation time:
>
> g++ -I include -c -O2 -Wall -g src/base_rest_ws.cpp -o obj/base_rest_ws.o
> src/base_rest_ws.cpp: In member function bool
> base_rest_ws::is_request_method_get():
> src/base_rest_ws.cpp:39:15: error: invalid use of incomplete type
> struct cppcms::http::request
> /usr/local/include/cppcms/application.h:41:9: error: forward declaration
> of struct cppcms::http::request
>
> g++ -I include -c -O2 -Wall -g src/users.cpp -o obj/users.o
> src/users.cpp: In member function void users::count():
> src/users.cpp:78:38: error: invalid use of incomplete type struct
> cppcms::http::request
> /usr/local/include/cppcms/application.h:41:9: error: forward declaration
> of struct cppcms::http::request
>
> maybe somebody can set me straight on those.
>
> cheers!
>
> k
>
> On 04/19/2012 02:50 PM, Klaus Wenger wrote:
>> thx artyom!
>>
>> i should have re-read the product planning page. i am looking forward to
>> the
>> rest support that does handle the scope and the encoded parameters. i
>> was
>> just lately looking at other c++ web frameworks that allow you to
>> register a
>> class and its methods to handle the rest call and get the scope and
>> parameters resolved and fed.
>>
>> great many thanks!
>>
>> k
>>
>> "Artyom Beilis"<art...@ya...> wrote in
>> message
>> news:133...@we......
>>> Note, today it is really not a problem to implement RESTful web
>>>
>>> services with CppCMS.
>>>
>>> Note REST is not a protocol like "JSON-RPC" is just
>>> general guidelines.
>>>
>>> So:
>>>
>>> 1. Create a mapping between resource and function/application
>>> 2. Handle requests differently for PUT/GET/DELETE etc.
>>>
>>>
>>>
>>> void myhandler(std::string resource_id)
>>> {
>>> if(request().method() == "GET") {
>>> ...
>>>
>>> }
>>> else if(request().method() == "PUT") {
>>> ...
>>>
>>> }
>>> else if(request().method() == "DELETE") { ... }
>>>
>>> }
>>>
>>>
>>>
>>> And so on, so RESTful service implementation with CppCMS
>>> is quite trivial.
>>>
>>>
>>>
>>> Artyom Beilis
>>> --------------
>>> CppCMS - C++ Web Framework: http://cppcms.com/
>>> CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/
>>>
>>>
>>>
>>>> ________________________________
>>>> From: william lee<we...@gm...>
>>>> To: cpp...@li...
>>>> Sent: Thursday, April 19, 2012 5:54 AM
>>>> Subject: Re: [Cppcms-users] CppCMS handle SOAP or RESTful like Web
>>>> Services?
>>>>
>>>>
>>>> Hi Klaus,
>>>> According to roadmap, it is planned to address in 1.3.0 or later :)
>>>> http://cppcms.com/wikipp/en/page/cppcms_1x_tasks#Improve.Support.of.RESTful.services
>>>>
>>>> Artyom can correct me if I'm wrong.
>>>>
>>>>
>>>> thanks,
>>>> William L.
>>>>
>>>>
>>>> On Wed, Apr 18, 2012 at 10:58 PM, Klaus Wenger
>>>> <kjw...@ya...> wrote:
>>>>
>>>> thank you guys for the useful thread!
>>>>>
>>>>> are there any plans on providing a rest_ws scaffold somewhat similar
>>>>> to
>>>>> rpc_json? any quick example to show the best practice?
>>>>>
>>>>> stay cool!
>>>>>
>>>>> k
>>>>>
>>>>>
>>>>> On 04/17/2012 07:28 AM, william lee wrote:
>>>>>> Thanks Artyom, it is clear to me now.
>>>>>>
>>>>>> Best Regards,
>>>>>> William L.
>>>>>>
>>>>>> On Tue, Apr 17, 2012 at 6:14 PM, Artyom Beilis
>>>>>> <art...@ya...
>>>>>
>>>>>> <mailto:art...@ya...>> wrote:
>>>>>>
>>>>>> >Hi,
>>>>>>
>>>>>> >If I want to use CppCMS framework provide web services like
>>>>>> SOAP
>>>>>> or RESTFul etc,
>>>>>> >Shall I need to use cppcms::http::request::raw_post_data()
>>>>>> and
>>>>>> parse the XML by myself?
>>>>>> >
>>>>>>
>>>>>> Yes, raw_post_data() created exactly for this purpose and for
>>>>>> example
>>>>>> JSON-RPC API uses it.
>>>>>>
>>>>>>
>>>>>> >
>>>>>> >
>>>>>> >CppCMS has built-in support for JSON-RPC, and any
>>>>>> recommendation
>>>>>> for handle other web services? :)
>>>>>> >
>>>>>>
>>>>>> JSON-RPC is provided as most lightweight and efficient
>>>>>> services,
>>>>>> that can be easily integrated with client (both Browser and
>>>>>> other client that generates JSON-RPC requests)
>>>>>>
>>>>>>
>>>>>> (Note that JSON is much more lightweight format then XML...)
>>>>>>
>>>>>> If you want to create other services you may want to use your
>>>>>> favorite
>>>>>>
>>>>>> XML library (tinyxml, libxml2 etc) and you may generate
>>>>>> responses
>>>>>> as XML using both CppCMS templates language or generate XML
>>>>>> using
>>>>>> your favorite XML library.
>>>>>>
>>>>>> Also note that for RESTFul services the url-dispatching/mapping
>>>>>> services
>>>>>> fit very well as it allows to handle proper hierarchy easily.
>>>>>>
>>>>>> Artyom
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Better than sec? Nothing is better than sec when it comes to
>>>>>> monitoring Big Data applications. Try Boundary one-second
>>>>>> resolution app monitoring today. Free.
>>>>>> http://p.sf.net/sfu/Boundary-dev2dev
>>>>>> _______________________________________________
>>>>>> Cppcms-users mailing list
>>>>>> Cpp...@li...
>>>>>>
>>>>>> <mailto:Cpp...@li...>
>>>>>> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Better than sec? Nothing is better than sec when it comes to
>>>>>> monitoring Big Data applications. Try Boundary one-second
>>>>>> resolution app monitoring today. Free.
>>>>>> http://p.sf.net/sfu/Boundary-dev2dev
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Better than sec? Nothing is better than sec when it comes to
>>>>> monitoring Big Data applications. Try Boundary one-second
>>>>> resolution app monitoring today. Free.
>>>>> http://p.sf.net/sfu/Boundary-dev2dev
>>>>> _______________________________________________
>>>>> Cppcms-users mailing list
>>>>> Cpp...@li...
>>>>> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> For Developers, A Lot Can Happen In A Second.
>>>> Boundary is the first to Know...and Tell You.
>>>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
>>>> http://p.sf.net/sfu/Boundary-d2dvs2
>>>> _______________________________________________
>>>> Cppcms-users mailing list
>>>> Cpp...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>>>>
>>>>
>>>>
>>>
>>> ------------------------------------------------------------------------------
>>> For Developers, A Lot Can Happen In A Second.
>>> Boundary is the first to Know...and Tell You.
>>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
>>> http://p.sf.net/sfu/Boundary-d2dvs2
>>
>>
>>
>> ------------------------------------------------------------------------------
>> For Developers, A Lot Can Happen In A Second.
>> Boundary is the first to Know...and Tell You.
>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
>> http://p.sf.net/sfu/Boundary-d2dvs2
>
> ------------------------------------------------------------------------------
> For Developers, A Lot Can Happen In A Second.
> Boundary is the first to Know...and Tell You.
> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
> http://p.sf.net/sfu/Boundary-d2dvs2_______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
|