我找不到任何用于通过名称空间 web :: http :: client 将xml内容发布到服务器的API。它不向服务器发送数据。请与XML + C ++ Rest SDk共享任何示例。或任何示例代码都可以
#include "cpprest/containerstream.h"
#include "cpprest/filestream.h"
#include "cpprest/http_client.h"
#include "cpprest/json.h"
#include "cpprest/producerconsumerstream.h"
#include <iostream>
#include <sstream>
using namespace ::pplx;
using namespace utility;
using namespace concurrency::streams;
using namespace web::http;
using namespace web::http::client;
using namespace web::json;
namespace web
{
namespace http
{
namespace client
{
class http_client;
}
}
}
int main()
{
std::wostringstream stream;
web::http::client::http_client* client= new http_client("http://192.168.91.36:80/testConfig");
http_response response = client->request(methods::POST, "", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE config SYSTEM \"/path/to/dtd\" ><config type=\"TestRequest\">===XML Data===</config>").get();
if (response.status_code() == status_codes::OK)
{
auto body = response.extract_string();
std::wcout << L"Added new Id: " << body.get().c_str() << std::endl;
}
}
以上是我尝试过的。我无法在服务器端获取正文内容,因此无法正常工作。请帮助解决此问题。