Rename project from csoap to webcc
This commit is contained in:
+7
-6
@@ -1,14 +1,15 @@
|
|||||||
cmake_minimum_required(VERSION 3.0)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
project(csoap)
|
project(webcc)
|
||||||
|
|
||||||
option(CSOAP_ENABLE_SOAP "Enable SOAP support (need PugiXml)?" ON)
|
option(WEBCC_ENABLE_SOAP "Enable SOAP support (need PugiXml)?" ON)
|
||||||
option(CSOAP_ENABLE_UT "Enable unit test?" OFF)
|
option(WEBCC_ENABLE_UT "Enable unit test?" ON)
|
||||||
|
option(WEBCC_ENABLE_DEMO "Enable demo programs?" ON)
|
||||||
|
|
||||||
if(CSOAP_ENABLE_SOAP)
|
if(WEBCC_ENABLE_SOAP)
|
||||||
add_definitions(-DCSOAP_ENABLE_SOAP)
|
add_definitions(-DWEBCC_ENABLE_SOAP)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CSOAP_ENABLE_UT)
|
if(WEBCC_ENABLE_UT)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -1,11 +1,13 @@
|
|||||||
if(CSOAP_ENABLE_UT)
|
if(WEBCC_ENABLE_UT)
|
||||||
add_subdirectory(gtest)
|
add_subdirectory(gtest)
|
||||||
add_subdirectory(csoap_unittest)
|
add_subdirectory(webcc_unittest)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(pugixml)
|
add_subdirectory(pugixml)
|
||||||
|
|
||||||
add_subdirectory(csoap)
|
add_subdirectory(webcc)
|
||||||
|
|
||||||
|
if(WEBCC_ENABLE_DEMO)
|
||||||
add_subdirectory(demo/soap/calc_client)
|
add_subdirectory(demo/soap/calc_client)
|
||||||
add_subdirectory(demo/soap/calc_server)
|
add_subdirectory(demo/soap/calc_server)
|
||||||
|
endif()
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
if(UNIX)
|
|
||||||
add_definitions(-D_GLIBCXX_USE_WCHAR_T -std=c++11)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(CSOAP_DEBUG_OUTPUT "Enable debug output?" OFF)
|
|
||||||
|
|
||||||
if(CSOAP_DEBUG_OUTPUT)
|
|
||||||
add_definitions(-DCSOAP_DEBUG_OUTPUT)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Don't use any deprecated definitions (e.g., io_service).
|
|
||||||
add_definitions(-DBOOST_ASIO_NO_DEPRECATED)
|
|
||||||
|
|
||||||
file(GLOB SRCS *.cc *.h)
|
|
||||||
|
|
||||||
add_library(csoap ${SRCS})
|
|
||||||
@@ -2,4 +2,4 @@ file(GLOB SRCS *.cc *.h)
|
|||||||
|
|
||||||
add_executable(soap_calc_client ${SRCS})
|
add_executable(soap_calc_client ${SRCS})
|
||||||
|
|
||||||
target_link_libraries(soap_calc_client csoap pugixml)
|
target_link_libraries(soap_calc_client webcc pugixml)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ bool CalcClient::Divide(double x, double y, double* result) {
|
|||||||
return Calc("divide", "numerator", "denominator", x, y, result);
|
return Calc("divide", "numerator", "denominator", x, y, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set to 0 to test our own calculator server created with csoap.
|
// Set to 0 to test our own calculator server created with webcc.
|
||||||
#define ACCESS_PARASOFT 0
|
#define ACCESS_PARASOFT 0
|
||||||
|
|
||||||
void CalcClient::Init() {
|
void CalcClient::Init() {
|
||||||
@@ -48,19 +48,19 @@ bool CalcClient::Calc(const std::string& operation,
|
|||||||
double y,
|
double y,
|
||||||
double* result) {
|
double* result) {
|
||||||
// Prepare parameters.
|
// Prepare parameters.
|
||||||
std::vector<csoap::Parameter> parameters{
|
std::vector<webcc::Parameter> parameters{
|
||||||
{ x_name, x },
|
{ x_name, x },
|
||||||
{ y_name, y }
|
{ y_name, y }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Make the call.
|
// Make the call.
|
||||||
std::string result_str;
|
std::string result_str;
|
||||||
csoap::Error error = Call(operation, std::move(parameters), &result_str);
|
webcc::Error error = Call(operation, std::move(parameters), &result_str);
|
||||||
|
|
||||||
// Error handling if any.
|
// Error handling if any.
|
||||||
if (error != csoap::kNoError) {
|
if (error != webcc::kNoError) {
|
||||||
std::cerr << "Error: " << error;
|
std::cerr << "Error: " << error;
|
||||||
std::cerr << ", " << csoap::GetErrorMessage(error) << std::endl;
|
std::cerr << ", " << webcc::GetErrorMessage(error) << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
#define CALC_CLIENT_H_
|
#define CALC_CLIENT_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "csoap/soap_client.h"
|
#include "webcc/soap_client.h"
|
||||||
|
|
||||||
class CalcClient : public csoap::SoapClient {
|
class CalcClient : public webcc::SoapClient {
|
||||||
public:
|
public:
|
||||||
CalcClient();
|
CalcClient();
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,4 @@ file(GLOB SRCS *.cc *.h)
|
|||||||
|
|
||||||
add_executable(soap_calc_server ${SRCS})
|
add_executable(soap_calc_server ${SRCS})
|
||||||
|
|
||||||
target_link_libraries(soap_calc_server csoap pugixml)
|
target_link_libraries(soap_calc_server webcc pugixml)
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
#include "boost/lexical_cast.hpp"
|
#include "boost/lexical_cast.hpp"
|
||||||
|
|
||||||
#include "csoap/soap_request.h"
|
#include "webcc/soap_request.h"
|
||||||
#include "csoap/soap_response.h"
|
#include "webcc/soap_response.h"
|
||||||
|
|
||||||
bool CalcService::Handle(const csoap::SoapRequest& soap_request,
|
bool CalcService::Handle(const webcc::SoapRequest& soap_request,
|
||||||
csoap::SoapResponse* soap_response) {
|
webcc::SoapResponse* soap_response) {
|
||||||
try {
|
try {
|
||||||
if (soap_request.operation() == "add") {
|
if (soap_request.operation() == "add") {
|
||||||
double x = boost::lexical_cast<double>(soap_request.GetParameter("x"));
|
double x = boost::lexical_cast<double>(soap_request.GetParameter("x"));
|
||||||
@@ -14,7 +14,7 @@ bool CalcService::Handle(const csoap::SoapRequest& soap_request,
|
|||||||
|
|
||||||
double result = x + y;
|
double result = x + y;
|
||||||
|
|
||||||
soap_response->set_soapenv_ns(csoap::kSoapEnvNamespace);
|
soap_response->set_soapenv_ns(webcc::kSoapEnvNamespace);
|
||||||
soap_response->set_service_ns({
|
soap_response->set_service_ns({
|
||||||
"cal",
|
"cal",
|
||||||
"http://www.example.com/calculator/"
|
"http://www.example.com/calculator/"
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
#ifndef CALC_SERVICE_H_
|
#ifndef CALC_SERVICE_H_
|
||||||
#define CALC_SERVICE_H_
|
#define CALC_SERVICE_H_
|
||||||
|
|
||||||
#include "csoap/soap_service.h"
|
#include "webcc/soap_service.h"
|
||||||
|
|
||||||
class CalcService : public csoap::SoapService {
|
class CalcService : public webcc::SoapService {
|
||||||
public:
|
public:
|
||||||
CalcService() = default;
|
CalcService() = default;
|
||||||
~CalcService() override = default;
|
~CalcService() override = default;
|
||||||
|
|
||||||
bool Handle(const csoap::SoapRequest& soap_request,
|
bool Handle(const webcc::SoapRequest& soap_request,
|
||||||
csoap::SoapResponse* soap_response) override;
|
webcc::SoapResponse* soap_response) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CALC_SERVICE_H_
|
#endif // CALC_SERVICE_H_
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "csoap/soap_server.h"
|
#include "webcc/soap_server.h"
|
||||||
#include "calc_service.h"
|
#include "calc_service.h"
|
||||||
|
|
||||||
static void Help(const char* argv0) {
|
static void Help(const char* argv0) {
|
||||||
@@ -19,7 +19,7 @@ int main(int argc, char* argv[]) {
|
|||||||
std::size_t workers = 2;
|
std::size_t workers = 2;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
csoap::SoapServer server(port, workers);
|
webcc::SoapServer server(port, workers);
|
||||||
|
|
||||||
server.RegisterService(std::make_shared<CalcService>(),
|
server.RegisterService(std::make_shared<CalcService>(),
|
||||||
"/calculator");
|
"/calculator");
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
option(WEBCC_DEBUG_OUTPUT "Enable debug output?" OFF)
|
||||||
|
|
||||||
|
if(WEBCC_DEBUG_OUTPUT)
|
||||||
|
add_definitions(-DWEBCC_DEBUG_OUTPUT)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Don't use any deprecated definitions (e.g., io_service).
|
||||||
|
add_definitions(-DBOOST_ASIO_NO_DEPRECATED)
|
||||||
|
|
||||||
|
file(GLOB SRCS *.cc *.h)
|
||||||
|
|
||||||
|
add_library(webcc ${SRCS})
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "csoap/common.h"
|
#include "webcc/common.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
// NOTE:
|
// NOTE:
|
||||||
// Field names are case-insensitive.
|
// Field names are case-insensitive.
|
||||||
@@ -103,4 +103,4 @@ Parameter& Parameter::operator=(Parameter&& rhs) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
#ifndef CSOAP_COMMON_H_
|
#ifndef WEBCC_COMMON_H_
|
||||||
#define CSOAP_COMMON_H_
|
#define WEBCC_COMMON_H_
|
||||||
|
|
||||||
// Common definitions.
|
// Common definitions.
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -155,6 +155,6 @@ private:
|
|||||||
std::string value_;
|
std::string value_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_COMMON_H_
|
#endif // WEBCC_COMMON_H_
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "csoap/http_client.h"
|
#include "webcc/http_client.h"
|
||||||
|
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -13,11 +13,11 @@
|
|||||||
#include "boost/asio/write.hpp"
|
#include "boost/asio/write.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "csoap/http_response_parser.h"
|
#include "webcc/http_response_parser.h"
|
||||||
#include "csoap/http_request.h"
|
#include "webcc/http_request.h"
|
||||||
#include "csoap/http_response.h"
|
#include "webcc/http_response.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ Error HttpClient::SendRequest(const HttpRequest& request,
|
|||||||
|
|
||||||
// Send HTTP request.
|
// Send HTTP request.
|
||||||
|
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
std::cout << "# REQUEST" << std::endl << request << std::endl;
|
std::cout << "# REQUEST" << std::endl << request << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ Error HttpClient::SendRequest(const HttpRequest& request,
|
|||||||
return kSocketWriteError;
|
return kSocketWriteError;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
std::cout << "# RESPONSE" << std::endl;
|
std::cout << "# RESPONSE" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ Error HttpClient::SendRequest(const HttpRequest& request,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
// NOTE: the content XML might not be well formated.
|
// NOTE: the content XML might not be well formated.
|
||||||
std::cout.write(buffer_.data(), length);
|
std::cout.write(buffer_.data(), length);
|
||||||
#endif
|
#endif
|
||||||
@@ -129,7 +129,7 @@ Error HttpClient::SendRequest(const HttpRequest& request,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
std::cout << "# RESPONSE (PARSED)" << std::endl;
|
std::cout << "# RESPONSE (PARSED)" << std::endl;
|
||||||
std::cout << *response << std::endl;
|
std::cout << *response << std::endl;
|
||||||
@@ -138,4 +138,4 @@ Error HttpClient::SendRequest(const HttpRequest& request,
|
|||||||
return kNoError;
|
return kNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
#ifndef CSOAP_HTTP_CLIENT_H_
|
#ifndef WEBCC_HTTP_CLIENT_H_
|
||||||
#define CSOAP_HTTP_CLIENT_H_
|
#define WEBCC_HTTP_CLIENT_H_
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include "boost/asio/io_context.hpp"
|
#include "boost/asio/io_context.hpp"
|
||||||
|
|
||||||
#include "csoap/common.h"
|
#include "webcc/common.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
class HttpRequest;
|
class HttpRequest;
|
||||||
class HttpResponse;
|
class HttpResponse;
|
||||||
@@ -31,6 +31,6 @@ private:
|
|||||||
int timeout_seconds_;
|
int timeout_seconds_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_HTTP_CLIENT_H_
|
#endif // WEBCC_HTTP_CLIENT_H_
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "csoap/http_message.h"
|
#include "webcc/http_message.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
void HttpMessage::SetHeader(const std::string& name, const std::string& value) {
|
void HttpMessage::SetHeader(const std::string& name, const std::string& value) {
|
||||||
for (HttpHeader& h : headers_) {
|
for (HttpHeader& h : headers_) {
|
||||||
@@ -13,4 +13,4 @@ void HttpMessage::SetHeader(const std::string& name, const std::string& value) {
|
|||||||
headers_.push_back({ name, value });
|
headers_.push_back({ name, value });
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
#ifndef CSOAP_HTTP_MESSAGE_H_
|
#ifndef WEBCC_HTTP_MESSAGE_H_
|
||||||
#define CSOAP_HTTP_MESSAGE_H_
|
#define WEBCC_HTTP_MESSAGE_H_
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "csoap/common.h"
|
#include "webcc/common.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
class HttpHeader {
|
class HttpHeader {
|
||||||
public:
|
public:
|
||||||
@@ -81,6 +81,6 @@ protected:
|
|||||||
std::string content_;
|
std::string content_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_HTTP_MESSAGE_H_
|
#endif // WEBCC_HTTP_MESSAGE_H_
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
#include "csoap/http_parser.h"
|
#include "webcc/http_parser.h"
|
||||||
|
|
||||||
#include "boost/algorithm/string.hpp"
|
#include "boost/algorithm/string.hpp"
|
||||||
#include "boost/lexical_cast.hpp"
|
#include "boost/lexical_cast.hpp"
|
||||||
|
|
||||||
#include "csoap/http_message.h"
|
#include "webcc/http_message.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
HttpParser::HttpParser(HttpMessage* message)
|
HttpParser::HttpParser(HttpMessage* message)
|
||||||
: message_(message)
|
: message_(message)
|
||||||
@@ -107,4 +107,4 @@ void HttpParser::ParseContentLength(const std::string& line) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#ifndef CSOAP_HTTP_PARSER_H_
|
#ifndef WEBCC_HTTP_PARSER_H_
|
||||||
#define CSOAP_HTTP_PARSER_H_
|
#define WEBCC_HTTP_PARSER_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "csoap/common.h"
|
#include "webcc/common.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
class HttpMessage;
|
class HttpMessage;
|
||||||
|
|
||||||
@@ -40,6 +40,6 @@ protected:
|
|||||||
bool finished_;
|
bool finished_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_HTTP_PARSER_H_
|
#endif // WEBCC_HTTP_PARSER_H_
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#include "csoap/http_request.h"
|
#include "webcc/http_request.h"
|
||||||
|
|
||||||
#include "boost/algorithm/string.hpp"
|
#include "boost/algorithm/string.hpp"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os, const HttpRequest& request) {
|
std::ostream& operator<<(std::ostream& os, const HttpRequest& request) {
|
||||||
os << request.start_line();
|
os << request.start_line();
|
||||||
@@ -68,4 +68,4 @@ std::vector<boost::asio::const_buffer> HttpRequest::ToBuffers() const {
|
|||||||
return buffers;
|
return buffers;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
#ifndef CSOAP_HTTP_REQUEST_H_
|
#ifndef WEBCC_HTTP_REQUEST_H_
|
||||||
#define CSOAP_HTTP_REQUEST_H_
|
#define WEBCC_HTTP_REQUEST_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "boost/asio/buffer.hpp" // for const_buffer
|
#include "boost/asio/buffer.hpp" // for const_buffer
|
||||||
#include "csoap/http_message.h"
|
#include "webcc/http_message.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
class HttpRequest;
|
class HttpRequest;
|
||||||
|
|
||||||
@@ -73,6 +73,6 @@ private:
|
|||||||
std::string port_;
|
std::string port_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_HTTP_REQUEST_H_
|
#endif // WEBCC_HTTP_REQUEST_H_
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
#include "csoap/http_request_handler.h"
|
#include "webcc/http_request_handler.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "csoap/common.h"
|
#include "webcc/common.h"
|
||||||
#include "csoap/http_request.h"
|
#include "webcc/http_request.h"
|
||||||
#include "csoap/http_response.h"
|
#include "webcc/http_response.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
void HttpRequestHandler::Enqueue(HttpSessionPtr session) {
|
void HttpRequestHandler::Enqueue(HttpSessionPtr session) {
|
||||||
queue_.Push(session);
|
queue_.Push(session);
|
||||||
@@ -20,25 +20,25 @@ void HttpRequestHandler::Start(std::size_t count) {
|
|||||||
assert(count > 0 && workers_.size() == 0);
|
assert(count > 0 && workers_.size() == 0);
|
||||||
|
|
||||||
for (std::size_t i = 0; i < count; ++i) {
|
for (std::size_t i = 0; i < count; ++i) {
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
boost::thread* worker =
|
boost::thread* worker =
|
||||||
#endif
|
#endif
|
||||||
workers_.create_thread(std::bind(&HttpRequestHandler::WorkerRoutine, this));
|
workers_.create_thread(std::bind(&HttpRequestHandler::WorkerRoutine, this));
|
||||||
|
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
std::cout << "Worker is running (thread: " << worker->get_id() << ")\n";
|
std::cout << "Worker is running (thread: " << worker->get_id() << ")\n";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpRequestHandler::Stop() {
|
void HttpRequestHandler::Stop() {
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
std::cout << "Stopping workers...\n";
|
std::cout << "Stopping workers...\n";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Close pending sessions.
|
// Close pending sessions.
|
||||||
for (HttpSessionPtr conn = queue_.Pop(); conn; conn = queue_.Pop()) {
|
for (HttpSessionPtr conn = queue_.Pop(); conn; conn = queue_.Pop()) {
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
std::cout << "Closing pending session...\n";
|
std::cout << "Closing pending session...\n";
|
||||||
#endif
|
#endif
|
||||||
conn->Stop();
|
conn->Stop();
|
||||||
@@ -49,13 +49,13 @@ void HttpRequestHandler::Stop() {
|
|||||||
|
|
||||||
workers_.join_all();
|
workers_.join_all();
|
||||||
|
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
std::cout << "All workers have been stopped.\n";
|
std::cout << "All workers have been stopped.\n";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpRequestHandler::WorkerRoutine() {
|
void HttpRequestHandler::WorkerRoutine() {
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
boost::thread::id thread_id = boost::this_thread::get_id();
|
boost::thread::id thread_id = boost::this_thread::get_id();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ void HttpRequestHandler::WorkerRoutine() {
|
|||||||
HttpSessionPtr session = queue_.PopOrWait();
|
HttpSessionPtr session = queue_.PopOrWait();
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
std::cout << "Worker is going to stop (thread: " << thread_id << ")\n";
|
std::cout << "Worker is going to stop (thread: " << thread_id << ")\n";
|
||||||
#endif
|
#endif
|
||||||
// For stopping next worker.
|
// For stopping next worker.
|
||||||
@@ -77,4 +77,4 @@ void HttpRequestHandler::WorkerRoutine() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
#ifndef CSOAP_HTTP_REQUEST_HANDLER_H_
|
#ifndef WEBCC_HTTP_REQUEST_HANDLER_H_
|
||||||
#define CSOAP_HTTP_REQUEST_HANDLER_H_
|
#define WEBCC_HTTP_REQUEST_HANDLER_H_
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "boost/thread/thread.hpp"
|
#include "boost/thread/thread.hpp"
|
||||||
|
|
||||||
#include "csoap/http_session.h"
|
#include "webcc/http_session.h"
|
||||||
#include "csoap/queue.h"
|
#include "webcc/queue.h"
|
||||||
#include "csoap/soap_service.h"
|
#include "webcc/soap_service.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
class HttpRequest;
|
class HttpRequest;
|
||||||
class HttpResponse;
|
class HttpResponse;
|
||||||
@@ -46,6 +46,6 @@ private:
|
|||||||
boost::thread_group workers_;
|
boost::thread_group workers_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_HTTP_REQUEST_HANDLER_H_
|
#endif // WEBCC_HTTP_REQUEST_HANDLER_H_
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
#include "csoap/http_request_parser.h"
|
#include "webcc/http_request_parser.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "boost/algorithm/string.hpp"
|
#include "boost/algorithm/string.hpp"
|
||||||
|
|
||||||
#include "csoap/http_request.h"
|
#include "webcc/http_request.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
HttpRequestParser::HttpRequestParser(HttpRequest* request)
|
HttpRequestParser::HttpRequestParser(HttpRequest* request)
|
||||||
: HttpParser(request), request_(request) {
|
: HttpParser(request), request_(request) {
|
||||||
@@ -13,7 +13,7 @@ HttpRequestParser::HttpRequestParser(HttpRequest* request)
|
|||||||
|
|
||||||
Error HttpRequestParser::ParseStartLine(const std::string& line) {
|
Error HttpRequestParser::ParseStartLine(const std::string& line) {
|
||||||
std::vector<std::string> strs;
|
std::vector<std::string> strs;
|
||||||
boost::split(strs, line, boost::is_any_of(" "));
|
boost::split(strs, line, boost::is_any_of(" "), boost::token_compress_on);
|
||||||
|
|
||||||
if (strs.size() != 3) {
|
if (strs.size() != 3) {
|
||||||
return kHttpStartLineError;
|
return kHttpStartLineError;
|
||||||
@@ -27,4 +27,4 @@ Error HttpRequestParser::ParseStartLine(const std::string& line) {
|
|||||||
return kNoError;
|
return kNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#ifndef CSOAP_HTTP_REQUEST_PARSER_H_
|
#ifndef WEBCC_HTTP_REQUEST_PARSER_H_
|
||||||
#define CSOAP_HTTP_REQUEST_PARSER_H_
|
#define WEBCC_HTTP_REQUEST_PARSER_H_
|
||||||
|
|
||||||
#include "csoap/http_parser.h"
|
#include "webcc/http_parser.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
class HttpRequest;
|
class HttpRequest;
|
||||||
|
|
||||||
@@ -18,6 +18,6 @@ private:
|
|||||||
HttpRequest* request_;
|
HttpRequest* request_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_HTTP_REQUEST_PARSER_H_
|
#endif // WEBCC_HTTP_REQUEST_PARSER_H_
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "csoap/http_response.h"
|
#include "webcc/http_response.h"
|
||||||
|
|
||||||
#include "csoap/common.h"
|
#include "webcc/common.h"
|
||||||
#include "csoap/xml.h"
|
#include "webcc/xml.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os, const HttpResponse& response) {
|
std::ostream& operator<<(std::ostream& os, const HttpResponse& response) {
|
||||||
os << response.start_line();
|
os << response.start_line();
|
||||||
@@ -118,4 +118,4 @@ HttpResponse HttpResponse::Fault(HttpStatus::Enum status) {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
#ifndef CSOAP_HTTP_RESPONSE_H_
|
#ifndef WEBCC_HTTP_RESPONSE_H_
|
||||||
#define CSOAP_HTTP_RESPONSE_H_
|
#define WEBCC_HTTP_RESPONSE_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "boost/asio/buffer.hpp" // for const_buffer
|
#include "boost/asio/buffer.hpp" // for const_buffer
|
||||||
#include "csoap/http_message.h"
|
#include "webcc/http_message.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
class HttpResponse;
|
class HttpResponse;
|
||||||
|
|
||||||
@@ -38,6 +38,6 @@ private:
|
|||||||
int status_ = HttpStatus::kOK; // TODO: HttpStatus
|
int status_ = HttpStatus::kOK; // TODO: HttpStatus
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_HTTP_RESPONSE_H_
|
#endif // WEBCC_HTTP_RESPONSE_H_
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#include "csoap/http_response_parser.h"
|
#include "webcc/http_response_parser.h"
|
||||||
#include "boost/lexical_cast.hpp"
|
#include "boost/lexical_cast.hpp"
|
||||||
#include "csoap/http_response.h"
|
#include "webcc/http_response.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
HttpResponseParser::HttpResponseParser(HttpResponse* response)
|
HttpResponseParser::HttpResponseParser(HttpResponse* response)
|
||||||
: HttpParser(response)
|
: HttpParser(response)
|
||||||
@@ -46,4 +46,4 @@ Error HttpResponseParser::ParseStartLine(const std::string& line) {
|
|||||||
return kNoError;
|
return kNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#ifndef CSOAP_HTTP_RESPONSE_PARSER_H_
|
#ifndef WEBCC_HTTP_RESPONSE_PARSER_H_
|
||||||
#define CSOAP_HTTP_RESPONSE_PARSER_H_
|
#define WEBCC_HTTP_RESPONSE_PARSER_H_
|
||||||
|
|
||||||
#include "csoap/http_parser.h"
|
#include "webcc/http_parser.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
class HttpResponse;
|
class HttpResponse;
|
||||||
|
|
||||||
@@ -20,6 +20,6 @@ private:
|
|||||||
HttpResponse* response_;
|
HttpResponse* response_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_HTTP_RESPONSE_PARSER_H_
|
#endif // WEBCC_HTTP_RESPONSE_PARSER_H_
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
#include "csoap/http_server.h"
|
#include "webcc/http_server.h"
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "csoap/http_request_handler.h"
|
#include "webcc/http_request_handler.h"
|
||||||
#include "csoap/soap_service.h"
|
#include "webcc/soap_service.h"
|
||||||
#include "csoap/utility.h"
|
#include "webcc/utility.h"
|
||||||
|
|
||||||
using tcp = boost::asio::ip::tcp;
|
using tcp = boost::asio::ip::tcp;
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
HttpServer::HttpServer(unsigned short port, std::size_t workers)
|
HttpServer::HttpServer(unsigned short port, std::size_t workers)
|
||||||
: signals_(io_context_)
|
: signals_(io_context_)
|
||||||
@@ -49,7 +49,7 @@ HttpServer::~HttpServer() {
|
|||||||
void HttpServer::Run() {
|
void HttpServer::Run() {
|
||||||
assert(request_handler_ != NULL);
|
assert(request_handler_ != NULL);
|
||||||
|
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
boost::thread::id thread_id = boost::this_thread::get_id();
|
boost::thread::id thread_id = boost::this_thread::get_id();
|
||||||
std::cout << "Server main thread: " << thread_id << std::endl;
|
std::cout << "Server main thread: " << thread_id << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@@ -95,4 +95,4 @@ void HttpServer::DoAwaitStop() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef CSOAP_HTTP_SERVER_H_
|
#ifndef WEBCC_HTTP_SERVER_H_
|
||||||
#define CSOAP_HTTP_SERVER_H_
|
#define WEBCC_HTTP_SERVER_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -11,9 +11,9 @@
|
|||||||
#include "boost/asio/signal_set.hpp"
|
#include "boost/asio/signal_set.hpp"
|
||||||
#include "boost/asio/ip/tcp.hpp"
|
#include "boost/asio/ip/tcp.hpp"
|
||||||
|
|
||||||
#include "csoap/http_session.h"
|
#include "webcc/http_session.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
class HttpRequestHandler;
|
class HttpRequestHandler;
|
||||||
|
|
||||||
@@ -57,6 +57,6 @@ private:
|
|||||||
boost::scoped_ptr<boost::asio::ip::tcp::acceptor> acceptor_;
|
boost::scoped_ptr<boost::asio::ip::tcp::acceptor> acceptor_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_HTTP_SERVER_H_
|
#endif // WEBCC_HTTP_SERVER_H_
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
#include "csoap/http_session.h"
|
#include "webcc/http_session.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "boost/asio/write.hpp"
|
#include "boost/asio/write.hpp"
|
||||||
|
|
||||||
#include "csoap/http_request_handler.h"
|
#include "webcc/http_request_handler.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
HttpSession::HttpSession(boost::asio::ip::tcp::socket socket,
|
HttpSession::HttpSession(boost::asio::ip::tcp::socket socket,
|
||||||
HttpRequestHandler* handler)
|
HttpRequestHandler* handler)
|
||||||
@@ -90,7 +90,7 @@ void HttpSession::HandleRead(boost::system::error_code ec,
|
|||||||
// ensured by Asio.
|
// ensured by Asio.
|
||||||
void HttpSession::HandleWrite(boost::system::error_code ec,
|
void HttpSession::HandleWrite(boost::system::error_code ec,
|
||||||
size_t length) {
|
size_t length) {
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
boost::thread::id thread_id = boost::this_thread::get_id();
|
boost::thread::id thread_id = boost::this_thread::get_id();
|
||||||
std::cout << "Response has been sent back (thread: " << thread_id << ")\n";
|
std::cout << "Response has been sent back (thread: " << thread_id << ")\n";
|
||||||
#endif
|
#endif
|
||||||
@@ -106,4 +106,4 @@ void HttpSession::HandleWrite(boost::system::error_code ec,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
#ifndef CSOAP_HTTP_SESSION_H_
|
#ifndef WEBCC_HTTP_SESSION_H_
|
||||||
#define CSOAP_HTTP_SESSION_H_
|
#define WEBCC_HTTP_SESSION_H_
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "boost/asio/ip/tcp.hpp" // for ip::tcp::socket
|
#include "boost/asio/ip/tcp.hpp" // for ip::tcp::socket
|
||||||
|
|
||||||
#include "csoap/common.h"
|
#include "webcc/common.h"
|
||||||
#include "csoap/http_request.h"
|
#include "webcc/http_request.h"
|
||||||
#include "csoap/http_request_parser.h"
|
#include "webcc/http_request_parser.h"
|
||||||
#include "csoap/http_response.h"
|
#include "webcc/http_response.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
class HttpRequestHandler;
|
class HttpRequestHandler;
|
||||||
|
|
||||||
@@ -77,6 +77,6 @@ private:
|
|||||||
|
|
||||||
typedef std::shared_ptr<HttpSession> HttpSessionPtr;
|
typedef std::shared_ptr<HttpSession> HttpSessionPtr;
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_HTTP_SESSION_H_
|
#endif // WEBCC_HTTP_SESSION_H_
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef CSOAP_QUEUE_H_
|
#ifndef WEBCC_QUEUE_H_
|
||||||
#define CSOAP_QUEUE_H_
|
#define WEBCC_QUEUE_H_
|
||||||
|
|
||||||
// A general message queue.
|
// A general message queue.
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "boost/thread/locks.hpp"
|
#include "boost/thread/locks.hpp"
|
||||||
#include "boost/thread/mutex.hpp"
|
#include "boost/thread/mutex.hpp"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class Queue {
|
class Queue {
|
||||||
@@ -57,6 +57,6 @@ private:
|
|||||||
boost::condition_variable not_empty_cv_;
|
boost::condition_variable not_empty_cv_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_QUEUE_H_
|
#endif // WEBCC_QUEUE_H_
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
#include "csoap/rest_server.h"
|
#include "webcc/rest_server.h"
|
||||||
|
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "csoap/url.h"
|
#include "webcc/url.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ bool RestServiceManager::AddService(RestServicePtr service,
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch (std::regex_error& e) {
|
} catch (std::regex_error& e) {
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
std::cout << e.what() << std::endl;
|
std::cout << e.what() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ HttpStatus::Enum RestRequestHandler::HandleSession(HttpSessionPtr session) {
|
|||||||
std::vector<std::string> sub_matches;
|
std::vector<std::string> sub_matches;
|
||||||
RestServicePtr service = service_manager_.GetService(url.path(), &sub_matches);
|
RestServicePtr service = service_manager_.GetService(url.path(), &sub_matches);
|
||||||
if (!service) {
|
if (!service) {
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
std::cout << "No service matches the URL: " << url.path() << std::endl;
|
std::cout << "No service matches the URL: " << url.path() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
session->SetResponseStatus(HttpStatus::kBadRequest);
|
session->SetResponseStatus(HttpStatus::kBadRequest);
|
||||||
@@ -117,4 +117,4 @@ bool RestServer::RegisterService(RestServicePtr service,
|
|||||||
return rest_request_handler_->RegisterService(service, url);
|
return rest_request_handler_->RegisterService(service, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef CSOAP_REST_SERVER_H_
|
#ifndef WEBCC_REST_SERVER_H_
|
||||||
#define CSOAP_REST_SERVER_H_
|
#define WEBCC_REST_SERVER_H_
|
||||||
|
|
||||||
// HTTP server handling REST requests.
|
// HTTP server handling REST requests.
|
||||||
|
|
||||||
@@ -7,11 +7,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "csoap/http_request_handler.h"
|
#include "webcc/http_request_handler.h"
|
||||||
#include "csoap/http_server.h"
|
#include "webcc/http_server.h"
|
||||||
#include "csoap/rest_service.h"
|
#include "webcc/rest_service.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
class Url;
|
class Url;
|
||||||
|
|
||||||
@@ -100,6 +100,6 @@ private:
|
|||||||
RestRequestHandler* rest_request_handler_;
|
RestRequestHandler* rest_request_handler_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_REST_SERVER_H_
|
#endif // WEBCC_REST_SERVER_H_
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
#ifndef CSOAP_REST_SERVICE_H_
|
#ifndef WEBCC_REST_SERVICE_H_
|
||||||
#define CSOAP_REST_SERVICE_H_
|
#define WEBCC_REST_SERVICE_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "csoap/common.h"
|
#include "webcc/common.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
// Base class for your REST service.
|
// Base class for your REST service.
|
||||||
class RestService {
|
class RestService {
|
||||||
@@ -24,6 +24,6 @@ public:
|
|||||||
|
|
||||||
typedef std::shared_ptr<RestService> RestServicePtr;
|
typedef std::shared_ptr<RestService> RestServicePtr;
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_REST_SERVICE_H_
|
#endif // WEBCC_REST_SERVICE_H_
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
#include "csoap/soap_client.h"
|
#include "webcc/soap_client.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "csoap/http_client.h"
|
#include "webcc/http_client.h"
|
||||||
#include "csoap/http_request.h"
|
#include "webcc/http_request.h"
|
||||||
#include "csoap/http_response.h"
|
#include "webcc/http_response.h"
|
||||||
#include "csoap/soap_request.h"
|
#include "webcc/soap_request.h"
|
||||||
#include "csoap/soap_response.h"
|
#include "webcc/soap_response.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
Error SoapClient::Call(const std::string& operation,
|
Error SoapClient::Call(const std::string& operation,
|
||||||
std::vector<Parameter>&& parameters,
|
std::vector<Parameter>&& parameters,
|
||||||
@@ -68,4 +68,4 @@ Error SoapClient::Call(const std::string& operation,
|
|||||||
return kNoError;
|
return kNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
#ifndef CSOAP_SOAP_CLIENT_H_
|
#ifndef WEBCC_SOAP_CLIENT_H_
|
||||||
#define CSOAP_SOAP_CLIENT_H_
|
#define WEBCC_SOAP_CLIENT_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "csoap/common.h"
|
#include "webcc/common.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
// Base class for your SOAP client.
|
// Base class for your SOAP client.
|
||||||
// Set URL, host, port, etc. in your sub-class before make the call.
|
// Set URL, host, port, etc. in your sub-class before make the call.
|
||||||
@@ -41,6 +41,6 @@ protected:
|
|||||||
std::string result_name_;
|
std::string result_name_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_SOAP_CLIENT_H_
|
#endif // WEBCC_SOAP_CLIENT_H_
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "csoap/soap_message.h"
|
#include "webcc/soap_message.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "csoap/xml.h"
|
#include "webcc/xml.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
void SoapMessage::ToXml(std::string* xml_string) {
|
void SoapMessage::ToXml(std::string* xml_string) {
|
||||||
assert(soapenv_ns_.IsValid() &&
|
assert(soapenv_ns_.IsValid() &&
|
||||||
@@ -51,4 +51,4 @@ bool SoapMessage::FromXml(const std::string& xml_string) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
#ifndef CSOAP_SOAP_MESSAGE_H_
|
#ifndef WEBCC_SOAP_MESSAGE_H_
|
||||||
#define CSOAP_SOAP_MESSAGE_H_
|
#define WEBCC_SOAP_MESSAGE_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "pugixml/pugixml.hpp"
|
#include "pugixml/pugixml.hpp"
|
||||||
#include "csoap/common.h"
|
#include "webcc/common.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
// Base class for SOAP request and response.
|
// Base class for SOAP request and response.
|
||||||
class SoapMessage {
|
class SoapMessage {
|
||||||
@@ -50,6 +50,6 @@ protected:
|
|||||||
std::string operation_;
|
std::string operation_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_SOAP_MESSAGE_H_
|
#endif // WEBCC_SOAP_MESSAGE_H_
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "csoap/soap_request.h"
|
#include "webcc/soap_request.h"
|
||||||
#include "csoap/xml.h"
|
#include "webcc/xml.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
void SoapRequest::AddParameter(const Parameter& parameter) {
|
void SoapRequest::AddParameter(const Parameter& parameter) {
|
||||||
parameters_.push_back(parameter);
|
parameters_.push_back(parameter);
|
||||||
@@ -54,4 +54,4 @@ bool SoapRequest::FromXmlBody(pugi::xml_node xbody) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#ifndef CSOAP_SOAP_REQUEST_H_
|
#ifndef WEBCC_SOAP_REQUEST_H_
|
||||||
#define CSOAP_SOAP_REQUEST_H_
|
#define WEBCC_SOAP_REQUEST_H_
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "csoap/soap_message.h"
|
#include "webcc/soap_message.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
// SOAP request.
|
// SOAP request.
|
||||||
// Used to compose the SOAP request envelope XML which will be sent as the HTTP
|
// Used to compose the SOAP request envelope XML which will be sent as the HTTP
|
||||||
@@ -26,6 +26,6 @@ private:
|
|||||||
std::vector<Parameter> parameters_;
|
std::vector<Parameter> parameters_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_SOAP_REQUEST_H_
|
#endif // WEBCC_SOAP_REQUEST_H_
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "csoap/soap_response.h"
|
#include "webcc/soap_response.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "csoap/xml.h"
|
#include "webcc/xml.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
void SoapResponse::ToXmlBody(pugi::xml_node xbody) {
|
void SoapResponse::ToXmlBody(pugi::xml_node xbody) {
|
||||||
std::string rsp_operation = operation_ + "Response";
|
std::string rsp_operation = operation_ + "Response";
|
||||||
@@ -32,4 +32,4 @@ bool SoapResponse::FromXmlBody(pugi::xml_node xbody) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#ifndef CSOAP_SOAP_RESPONSE_H_
|
#ifndef WEBCC_SOAP_RESPONSE_H_
|
||||||
#define CSOAP_SOAP_RESPONSE_H_
|
#define WEBCC_SOAP_RESPONSE_H_
|
||||||
|
|
||||||
#include "csoap/soap_message.h"
|
#include "webcc/soap_message.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
// SOAP response.
|
// SOAP response.
|
||||||
class SoapResponse : public SoapMessage {
|
class SoapResponse : public SoapMessage {
|
||||||
@@ -45,6 +45,6 @@ private:
|
|||||||
std::string result_;
|
std::string result_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_SOAP_RESPONSE_H_
|
#endif // WEBCC_SOAP_RESPONSE_H_
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
#include "csoap/soap_server.h"
|
#include "webcc/soap_server.h"
|
||||||
|
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "csoap/soap_request.h"
|
#include "webcc/soap_request.h"
|
||||||
#include "csoap/soap_response.h"
|
#include "webcc/soap_response.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -55,13 +55,13 @@ SoapServicePtr SoapRequestHandler::GetServiceByUrl(const std::string& url) {
|
|||||||
UrlServiceMap::const_iterator it = url_service_map_.find(url);
|
UrlServiceMap::const_iterator it = url_service_map_.find(url);
|
||||||
|
|
||||||
if (it != url_service_map_.end()) {
|
if (it != url_service_map_.end()) {
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
std::cout << "Service matches the URL: " << url << std::endl;
|
std::cout << "Service matches the URL: " << url << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CSOAP_DEBUG_OUTPUT
|
#if WEBCC_DEBUG_OUTPUT
|
||||||
std::cout << "No service matches the URL: " << url << std::endl;
|
std::cout << "No service matches the URL: " << url << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -86,4 +86,4 @@ bool SoapServer::RegisterService(SoapServicePtr service,
|
|||||||
return soap_request_handler_->RegisterService(service, url);
|
return soap_request_handler_->RegisterService(service, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
#ifndef CSOAP_SOAP_SERVER_H_
|
#ifndef WEBCC_SOAP_SERVER_H_
|
||||||
#define CSOAP_SOAP_SERVER_H_
|
#define WEBCC_SOAP_SERVER_H_
|
||||||
|
|
||||||
// HTTP server handling SOAP requests.
|
// HTTP server handling SOAP requests.
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "csoap/http_request_handler.h"
|
#include "webcc/http_request_handler.h"
|
||||||
#include "csoap/http_server.h"
|
#include "webcc/http_server.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -47,6 +47,6 @@ private:
|
|||||||
SoapRequestHandler* soap_request_handler_;
|
SoapRequestHandler* soap_request_handler_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_SOAP_SERVER_H_
|
#endif // WEBCC_SOAP_SERVER_H_
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#ifndef CSOAP_SOAP_SERVICE_H_
|
#ifndef WEBCC_SOAP_SERVICE_H_
|
||||||
#define CSOAP_SOAP_SERVICE_H_
|
#define WEBCC_SOAP_SERVICE_H_
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
class SoapRequest;
|
class SoapRequest;
|
||||||
class SoapResponse;
|
class SoapResponse;
|
||||||
@@ -21,6 +21,6 @@ public:
|
|||||||
|
|
||||||
typedef std::shared_ptr<SoapService> SoapServicePtr;
|
typedef std::shared_ptr<SoapService> SoapServicePtr;
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_SOAP_SERVICE_H_
|
#endif // WEBCC_SOAP_SERVICE_H_
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#include "csoap/url.h"
|
#include "webcc/url.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
Url::Url(const std::string& str) {
|
Url::Url(const std::string& str) {
|
||||||
std::size_t pos = str.find('?');
|
std::size_t pos = str.find('?');
|
||||||
@@ -73,4 +73,4 @@ Url::Query Url::SplitQuery(const std::string& query) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef CSOAP_URL_H_
|
#ifndef WEBCC_URL_H_
|
||||||
#define CSOAP_URL_H_
|
#define WEBCC_URL_H_
|
||||||
|
|
||||||
// A simplified implementation of URL (or URI).
|
// A simplified implementation of URL (or URI).
|
||||||
// The URL should start with "/".
|
// The URL should start with "/".
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
class Url {
|
class Url {
|
||||||
public:
|
public:
|
||||||
@@ -48,6 +48,6 @@ private:
|
|||||||
std::string query_;
|
std::string query_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_URL_H_
|
#endif // WEBCC_URL_H_
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "csoap/utility.h"
|
#include "webcc/utility.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using tcp = boost::asio::ip::tcp;
|
using tcp = boost::asio::ip::tcp;
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
// Print the resolved endpoints.
|
// Print the resolved endpoints.
|
||||||
// NOTE: Endpoint is one word, don't use "end point".
|
// NOTE: Endpoint is one word, don't use "end point".
|
||||||
@@ -25,4 +25,4 @@ void DumpEndpoints(tcp::resolver::results_type& endpoints) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
#ifndef CSOAP_UTILITY_H_
|
#ifndef WEBCC_UTILITY_H_
|
||||||
#define CSOAP_UTILITY_H_
|
#define WEBCC_UTILITY_H_
|
||||||
|
|
||||||
#include "boost/asio/ip/tcp.hpp"
|
#include "boost/asio/ip/tcp.hpp"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
|
|
||||||
// Print the resolved endpoints.
|
// Print the resolved endpoints.
|
||||||
// NOTE: Endpoint is one word, don't use "end point".
|
// NOTE: Endpoint is one word, don't use "end point".
|
||||||
void DumpEndpoints(boost::asio::ip::tcp::resolver::results_type& endpoints);
|
void DumpEndpoints(boost::asio::ip::tcp::resolver::results_type& endpoints);
|
||||||
|
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_UTILITY_H_
|
#endif // WEBCC_UTILITY_H_
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "csoap/xml.h"
|
#include "webcc/xml.h"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
namespace xml {
|
namespace xml {
|
||||||
|
|
||||||
void SplitName(const pugi::xml_node& xnode,
|
void SplitName(const pugi::xml_node& xnode,
|
||||||
@@ -106,4 +106,4 @@ bool PrettyPrintXml(std::ostream& os,
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xml
|
} // namespace xml
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
#ifndef CSOAP_XML_H_
|
#ifndef WEBCC_XML_H_
|
||||||
#define CSOAP_XML_H_
|
#define WEBCC_XML_H_
|
||||||
|
|
||||||
// XML utilities.
|
// XML utilities.
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "pugixml/pugixml.hpp"
|
#include "pugixml/pugixml.hpp"
|
||||||
|
|
||||||
namespace csoap {
|
namespace webcc {
|
||||||
namespace xml {
|
namespace xml {
|
||||||
|
|
||||||
// Split the node name into namespace prefix and real name.
|
// Split the node name into namespace prefix and real name.
|
||||||
@@ -86,6 +86,6 @@ bool PrettyPrintXml(std::ostream& os,
|
|||||||
const char* indent = "\t");
|
const char* indent = "\t");
|
||||||
|
|
||||||
} // namespace xml
|
} // namespace xml
|
||||||
} // namespace csoap
|
} // namespace webcc
|
||||||
|
|
||||||
#endif // CSOAP_XML_H_
|
#endif // WEBCC_XML_H_
|
||||||
Reference in New Issue
Block a user