Improve the response result composition.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "example/common/book_xml.h"
|
||||
|
||||
static const std::string kResultName = "Result";
|
||||
static const std::string kResult = "Result";
|
||||
|
||||
static void PrintSeparateLine() {
|
||||
std::cout << "--------------------------------";
|
||||
@@ -104,7 +104,7 @@ bool BookClient::Call1(const std::string& operation,
|
||||
bool BookClient::Call(const std::string& operation,
|
||||
std::vector<webcc::SoapParameter>&& parameters,
|
||||
std::string* result_str) {
|
||||
if (!soap_client_.Request(operation, std::move(parameters), kResultName,
|
||||
if (!soap_client_.Request(operation, std::move(parameters), kResult,
|
||||
result_str)) {
|
||||
PrintError();
|
||||
return false;
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
static BookStore g_book_store;
|
||||
|
||||
static const std::string kResult = "Result";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool BookService::Handle(const webcc::SoapRequest& soap_request,
|
||||
@@ -27,7 +29,6 @@ bool BookService::Handle(const webcc::SoapRequest& soap_request,
|
||||
});
|
||||
|
||||
soap_response->set_operation(operation);
|
||||
soap_response->set_result_name("Result");
|
||||
|
||||
if (operation == "CreateBook") {
|
||||
return CreateBook(soap_request, soap_response);
|
||||
@@ -97,7 +98,7 @@ bool BookService::CreateBook(const webcc::SoapRequest& soap_request,
|
||||
std::string response_xml = NewResultXml(0, "ok", "book", "id",
|
||||
id.c_str());
|
||||
|
||||
soap_response->set_result_moved(std::move(response_xml), true);
|
||||
soap_response->set_simple_result(kResult, std::move(response_xml), true);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -137,7 +138,7 @@ bool BookService::GetBook(const webcc::SoapRequest& soap_request,
|
||||
|
||||
const Book& book = g_book_store.GetBook(id);
|
||||
|
||||
soap_response->set_result_moved(NewResultXml(0, "ok", book), true);
|
||||
soap_response->set_simple_result(kResult, NewResultXml(0, "ok", book), true);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -176,7 +177,7 @@ bool BookService::ListBooks(const webcc::SoapRequest& soap_request,
|
||||
|
||||
const std::list<Book>& books = g_book_store.books();
|
||||
|
||||
soap_response->set_result_moved(NewResultXml(0, "ok", books), true);
|
||||
soap_response->set_simple_result(kResult, NewResultXml(0, "ok", books), true);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -210,9 +211,9 @@ bool BookService::DeleteBook(const webcc::SoapRequest& soap_request,
|
||||
const std::string& id = soap_request.GetParameter("id");
|
||||
|
||||
if (g_book_store.DeleteBook(id)) {
|
||||
soap_response->set_result_moved(NewResultXml(0, "ok"), true);
|
||||
soap_response->set_simple_result(kResult, NewResultXml(0, "ok"), true);
|
||||
} else {
|
||||
soap_response->set_result_moved(NewResultXml(1, "error"), true);
|
||||
soap_response->set_simple_result(kResult, NewResultXml(1, "error"), true);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -58,9 +58,7 @@ bool CalcService::Handle(const webcc::SoapRequest& soap_request,
|
||||
});
|
||||
|
||||
soap_response->set_operation(soap_request.operation());
|
||||
|
||||
soap_response->set_result_name("Result");
|
||||
soap_response->set_result_moved(std::to_string(result), false);
|
||||
soap_response->set_simple_result("Result", std::to_string(result), false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user