2010-11-19 14 views
7

C++でRESTfulクライアント(HTTP要求をRESTサービス呼び出しとして解釈するライブラリ)を実装するオープンソースライブラリはありますか?C++のRESTfulクライアントAPI

私の要件は、Amazon Web Servicesに接続して、C++で特定のユーザーアカウントで使用可能なEC2インスタンス(およびその詳細)のリストを取得することです。

私はAmazonがこれをJavaのC#で提供していることを知っています。しかし、私はC++で欲しいです。 AmazonがC++でも提供しているのなら、それでいいでしょう、私を案内してください。

お手数をおかけします。

よろしくお願いいたします。

Bharatha Selvan

答えて

2

XMLを解析する必要があります。 Qt C++ Toolkitを試すことをお勧めします。これは、HTTP呼び出しを行うQHttpインスタンスとxmlを解析するQtXmlモジュールを提供します。この方法で、C++ Rest Clientを作成することができます。

1

libawsを試しましたか?

2

ウェブフレームワークffead-cppを試してください。 Dependency Injection、Serialization、Limited Reflection、JSONなどのような多くの機能を持っています。それをチェックしてください...

0

Restbedは同期と非同期のHTTP/HTTPSクライアント機能を提供しています。

#include <memory> 
#include <future> 
#include <cstdio> 
#include <cstdlib> 
#include <restbed> 

using namespace std; 
using namespace restbed; 

void print(const shared_ptr<Response>& response) 
{ 
    fprintf(stderr, "*** Response ***\n"); 
    fprintf(stderr, "Status Code: %i\n", response->get_status_code()); 
    fprintf(stderr, "Status Message: %s\n", response->get_status_message().data()); 
    fprintf(stderr, "HTTP Version: %.1f\n", response->get_version()); 
    fprintf(stderr, "HTTP Protocol: %s\n", response->get_protocol().data()); 

    for (const auto header : response->get_headers()) 
    { 
     fprintf(stderr, "Header '%s' > '%s'\n", header.first.data(), header.second.data()); 
    } 

    auto length = 0; 
    response->get_header("Content-Length", length); 

    Http::fetch(length, response); 

    fprintf(stderr, "Body:   %.*s...\n\n", 25, response->get_body().data()); 
} 

int main(const int, const char**) 
{ 
    auto request = make_shared<Request>(Uri("http://www.corvusoft.co.uk:80/?query=search%20term")); 
    request->set_header("Accept", "*/*"); 
    request->set_header("Host", "www.corvusoft.co.uk"); 

    auto response = Http::sync(request); 
    print(response); 

    auto future = Http::async(request, [ ](const shared_ptr<Request>, const shared_ptr<Response> response) 
    { 
     fprintf(stderr, "Printing async response\n"); 
     print(response); 
    }); 

    future.wait(); 

    return EXIT_SUCCESS; 
}