Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

New Post: Error: Cannot return the string in a http_listener for c++ rest sdk

$
0
0
Error: string_t(to_wstring(sum1)) this is not working..

Server.cpp
1>c:\users\amu\desktop\server\server\server.cpp(32): error C2665: 'std::to_wstring' : none of the 9 overloads could convert all the argument types
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\string(644): could be 'std::wstring std::to_wstring(float)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\string(639): or 'std::wstring std::to_wstring(double)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\string(626): or 'std::wstring std::to_wstring(long double)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\string(618): or 'std::wstring std::to_wstring(_ULonglong)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\string(610): or 'std::wstring std::to_wstring(_Longlong)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\string(602): or 'std::wstring std::to_wstring(unsigned long)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\string(594): or 'std::wstring std::to_wstring(long)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\string(586): or 'std::wstring std::to_wstring(unsigned int)'
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\string(578): or 'std::wstring std::to_wstring(int)'
1> while trying to match the argument list '(std::string)'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
#include <cpprest/http_listener.h>             
#include <cpprest/json.h>                      
#include <cpprest/uri.h>                                
#include <cpprest/containerstream.h>            // Async streams backed by STL containers
#include <cpprest/interopstream.h>              // Bridges for integrating Async streams with STL and WinRT streams
#include <cpprest/rawptrstream.h>               // Async streams backed by raw pointer to memory
#include <cpprest/producerconsumerstream.h>     // Async streams for producer consumer scenarios
#include <iostream>

using namespace std;
using namespace utility;                    // Common utilities like string conversions
using namespace web;                        // Common features like URIs.
using namespace web::http;                  // Common HTTP functionality
using namespace web::http::client;          // HTTP client features
using namespace concurrency::streams;       // Asynchronous streams
using namespace web::http::experimental::listener;

std::string sample1()
{
    string text = "hello world";
    return text;
}

int main()
{
    http_listener listener(L"http://localhost:8080/hello");
    listener.support(web::http::methods::GET, [](web::http::http_request request)
    {
        string sum1 = sample1();
        string_t msg = U("\nServer-side Process \nuri:") + request.request_uri().to_string() + U(" \nTime:") + string_t(to_wstring(time(nullptr))) + U(" \nReturn the String = ") + string_t(to_wstring(sum1));
        wcout << msg << endl;
        request.reply(web::http::status_codes::OK, msg);
    }
    );
    listener.open().wait();

    std::string line;
    std::cout << "Press enter to exit" << std::endl;
    std::getline(std::cin, line);

    listener.close().wait();
    
    getchar();
    return 0;
}

Please Give me the solution.. Help me..

Thanks,
Bharathij

Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>