Cleanup async client APIs.

This commit is contained in:
Chunting Gu
2019-03-07 16:02:49 +08:00
parent ffa0794926
commit 31d0ea3c9d
74 changed files with 267 additions and 2106 deletions
+33
View File
@@ -0,0 +1,33 @@
# Examples
# Common libraries to link for examples.
set(EXAMPLE_COMMON_LIBS webcc ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES}
"${CMAKE_THREAD_LIBS_INIT}")
if(WIN32)
set(EXAMPLE_COMMON_LIBS ${EXAMPLE_COMMON_LIBS} crypt32)
endif()
if(UNIX)
# Add `-ldl` for Linux to avoid "undefined reference to `dlopen'".
set(EXAMPLE_COMMON_LIBS ${EXAMPLE_COMMON_LIBS} ${CMAKE_DL_LIBS})
endif()
add_subdirectory(http_client)
if(WEBCC_ENABLE_REST)
add_subdirectory(rest_book_server)
# add_subdirectory(rest_book_client)
add_subdirectory(github_client)
endif()
if(WEBCC_ENABLE_SOAP)
add_subdirectory(soap_calc_server)
add_subdirectory(soap_book_server)
add_subdirectory(soap_book_client)
endif()
add_executable(soap_calc_client soap_calc_client.cc)
add_executable(soap_calc_client_parasoft soap_calc_client_parasoft.cc)
target_link_libraries(soap_calc_client ${EXAMPLE_COMMON_LIBS} pugixml)
target_link_libraries(soap_calc_client_parasoft ${EXAMPLE_COMMON_LIBS} pugixml)
-36
View File
@@ -1,36 +0,0 @@
HttpBin (http://httpbin.org/) client example.
You request to different endpoints, and it returns information about what was in the request.
E.g., request:
```plain
GET /get HTTP/1.1
Host: httpbin.org:80
User-Agent: Webcc/0.1.0
```
Response:
```plain
HTTP/1.1 200 OK
Connection: keep-alive
Server: gunicorn/19.9.0
Content-Type: application/json
Content-Length: 191
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Via: 1.1 vegur
{
"args": {},
"headers": {
"Connection": "close",
"Host": "httpbin.org",
"User-Agent": "Webcc/0.1.0"
},
"origin": "198.55.94.81",
"url": "http://httpbin.org/get"
}
```
As you can see, the request information is returned in JSON format.
+2 -2
View File
@@ -20,7 +20,7 @@ std::ostream& operator<<(std::ostream& os, const Book& book);
extern const Book kNullBook;
class BookStore {
public:
public:
const std::list<Book>& books() const { return books_; }
const Book& GetBook(const std::string& id) const;
@@ -33,7 +33,7 @@ class BookStore {
bool DeleteBook(const std::string& id);
private:
private:
std::list<Book>::const_iterator FindBook(const std::string& id) const;
std::list<Book>::iterator FindBook(const std::string& id);
+2
View File
@@ -0,0 +1,2 @@
add_executable(github_client main.cc)
target_link_libraries(github_client ${EXAMPLE_COMMON_LIBS} jsoncpp)
@@ -3,8 +3,8 @@
#include "json/json.h"
#include "webcc/http_client_session.h"
#include "webcc/logger.h"
#include "webcc/rest_ssl_client.h"
// -----------------------------------------------------------------------------
@@ -19,7 +19,7 @@ bool kSslVerify = false;
bool kSslVerify = true;
#endif
const std::string kGithubHost = "api.github.com";
const std::size_t kBufferSize = 1500;
// -----------------------------------------------------------------------------
@@ -57,43 +57,48 @@ static void PrettyPrintJsonString(const std::string& str) {
#define PRINT_JSON_STRING(str)
#endif // PRINT_RESPONSE
static void PrintError(const webcc::RestSslClient& client) {
std::cout << webcc::DescribeError(client.error());
if (client.timed_out()) {
std::cout << " (timed out)";
}
std::cout << std::endl;
}
// -----------------------------------------------------------------------------
// List public events.
static void ListEvents(webcc::RestSslClient& client) {
if (client.Get("/events")) {
PRINT_JSON_STRING(client.response_content());
} else {
PrintError(client);
}
}
// List the followers of the given user.
static void ListUserFollowers(webcc::RestSslClient& client,
const std::string& user) {
if (client.Get("/users/" + user + "/followers")) {
PRINT_JSON_STRING(client.response_content());
} else {
PrintError(client);
}
}
//static void PrintError(const webcc::RestSslClient& client) {
// std::cout << webcc::DescribeError(client.error());
// if (client.timed_out()) {
// std::cout << " (timed out)";
// }
// std::cout << std::endl;
//}
//
//// -----------------------------------------------------------------------------
//
//// List public events.
//static void ListEvents(webcc::RestSslClient& client) {
// if (client.Get("/events")) {
// PRINT_JSON_STRING(client.response_content());
// } else {
// PrintError(client);
// }
//}
//
//// List the followers of the given user.
//static void ListUserFollowers(webcc::RestSslClient& client,
// const std::string& user) {
// if (client.Get("/users/" + user + "/followers")) {
// PRINT_JSON_STRING(client.response_content());
// } else {
// PrintError(client);
// }
//}
// List the followers of the current authorized user.
// Header syntax: Authorization: <type> <credentials>
static void ListAuthorizedUserFollowers(webcc::RestSslClient& client,
static void ListAuthorizedUserFollowers(webcc::HttpClientSession& session,
const std::string& auth) {
if (client.Get("/user/followers", { { "Authorization", auth } })) {
PRINT_JSON_STRING(client.response_content());
auto r = session.Request(webcc::HttpRequestArgs("GET").
url("https://api.github.com/user/followers").
headers({ { "Authorization", auth } }).
ssl_verify(kSslVerify).buffer_size(kBufferSize));
if (r) {
PRINT_JSON_STRING(r->content());
} else {
PrintError(client);
//PrintError(client);
}
}
@@ -102,10 +107,10 @@ static void ListAuthorizedUserFollowers(webcc::RestSslClient& client,
int main() {
WEBCC_LOG_INIT("", webcc::LOG_CONSOLE);
webcc::RestSslClient client(kGithubHost, "", kSslVerify, {}, 1500);
webcc::HttpClientSession session;
//ListAuthorizedUserFollowers(client, "Basic c3ByaW5mYWxsQGdtYWlsLmNvbTpYaWFvTHVhbjFA");
ListAuthorizedUserFollowers(client, "Token 1d42e2cce49929f2d24b1b6e96260003e5b3e1b0");
ListAuthorizedUserFollowers(session, "Token 1d42e2cce49929f2d24b1b6e96260003e5b3e1b0");
return 0;
}
@@ -1,2 +0,0 @@
add_executable(github_rest_client main.cc)
target_link_libraries(github_rest_client ${EXAMPLE_COMMON_LIBS} jsoncpp)
-4
View File
@@ -1,4 +0,0 @@
add_executable(http_async_client main.cc)
target_link_libraries(http_async_client webcc ${Boost_LIBRARIES})
target_link_libraries(http_async_client "${CMAKE_THREAD_LIBS_INIT}")
-47
View File
@@ -1,47 +0,0 @@
#include <iostream>
#include "boost/asio/io_context.hpp"
#include "webcc/http_async_client.h"
#include "webcc/logger.h"
// TODO: The program blocks during read response.
// Only HttpBin.org has this issue.
static void Test(boost::asio::io_context& io_context) {
auto request = webcc::HttpRequest::New(webcc::kHttpGet, "/get",
"httpbin.org");
auto client = webcc::HttpAsyncClient::New(io_context);
client->SetTimeout(3);
// Response callback.
auto callback = [](webcc::HttpResponsePtr response, webcc::Error error,
bool timed_out) {
if (error == webcc::kNoError) {
std::cout << response->content() << std::endl;
} else {
std::cout << DescribeError(error);
if (timed_out) {
std::cout << " (timed out)";
}
std::cout << std::endl;
}
};
client->Request(request, callback);
}
int main() {
WEBCC_LOG_INIT("", webcc::LOG_CONSOLE);
boost::asio::io_context io_context;
//Test(io_context);
Test(io_context);
io_context.run();
return 0;
}
+20 -10
View File
@@ -3,6 +3,14 @@
#include "webcc/http_client_session.h"
#include "webcc/logger.h"
void GetBoostOrgLicense(webcc::HttpClientSession& session) {
auto r = session.Get("https://www.boost.org/LICENSE_1_0.txt");
if (r) {
std::cout << r->content() << std::endl;
}
}
int main() {
WEBCC_LOG_INIT("", webcc::LOG_CONSOLE);
@@ -29,21 +37,21 @@ int main() {
// - constructor: HttpRequestArgs{ "GET" }
// - move constructor: auto args = ...
auto args = HttpRequestArgs{"GET"}.
url("http://httpbin.org/get").
parameters({ "key1", "value1", "key2", "value2" }).
headers({ "Accept", "application/json" }).
buffer_size(1000);
//auto args = HttpRequestArgs{"GET"}.
// url("http://httpbin.org/get").
// parameters({ "key1", "value1", "key2", "value2" }).
// headers({ "Accept", "application/json" }).
// buffer_size(1000);
r = session.Request(std::move(args));
//r = session.Request(std::move(args));
// ---------------------------------------------------------------------------
// Use pre-defined wrappers.
r = session.Get("http://httpbin.org/get",
{ "key1", "value1", "key2", "value2" },
{ "Accept", "application/json" },
HttpRequestArgs{}.buffer_size(1000));
//r = session.Get("http://httpbin.org/get",
// { "key1", "value1", "key2", "value2" },
// { "Accept", "application/json" },
// HttpRequestArgs{}.buffer_size(1000));
// ---------------------------------------------------------------------------
// HTTPS is auto-detected from the URL schema.
@@ -56,5 +64,7 @@ int main() {
std::cout << r->content() << std::endl;
}
GetBoostOrgLicense(session);
return 0;
}
@@ -1,11 +0,0 @@
add_executable(http_ssl_async_client main.cc)
# TODO
set(SSL_LIBS ${OPENSSL_LIBRARIES})
if(WIN32)
set(SSL_LIBS ${SSL_LIBS} crypt32)
endif()
target_link_libraries(http_ssl_async_client webcc ${Boost_LIBRARIES})
target_link_libraries(http_ssl_async_client "${CMAKE_THREAD_LIBS_INIT}")
target_link_libraries(http_ssl_async_client ${SSL_LIBS})
-56
View File
@@ -1,56 +0,0 @@
#include <iostream>
#include "boost/asio/io_context.hpp"
#include "webcc/http_ssl_async_client.h"
#include "webcc/logger.h"
int main(int argc, char* argv[]) {
std::string host;
std::string url;
if (argc != 3) {
host = "www.boost.org";
url = "/LICENSE_1_0.txt";
} else {
host = argv[1];
url = argv[2];
}
std::cout << "Host: " << host << std::endl;
std::cout << "URL: " << url << std::endl;
std::cout << std::endl;
WEBCC_LOG_INIT("", webcc::LOG_CONSOLE);
boost::asio::io_context io_context;
// Leave port to default value.
auto request = webcc::HttpRequest::New(webcc::kHttpGet, url, host);
// Verify the certificate of the peer or not.
// See HttpSslClient::Request() for more details.
bool ssl_verify = false;
auto client = webcc::HttpSslAsyncClient::New(io_context, 2000, ssl_verify);
// Response callback.
auto callback = [](webcc::HttpResponsePtr response, webcc::Error error,
bool timed_out) {
if (error == webcc::kNoError) {
std::cout << response->content() << std::endl;
} else {
std::cout << DescribeError(error);
if (timed_out) {
std::cout << " (timed out)";
}
std::cout << std::endl;
}
};
client->Request(request, callback);
io_context.run();
return 0;
}
-2
View File
@@ -1,2 +0,0 @@
add_executable(http_ssl_client main.cc)
target_link_libraries(http_ssl_client ${EXAMPLE_COMMON_LIBS})
-42
View File
@@ -1,42 +0,0 @@
#include <iostream>
#include "webcc/http_ssl_client.h"
#include "webcc/logger.h"
int main(int argc, char* argv[]) {
std::string url;
if (argc != 3) {
url = "www.boost.org/LICENSE_1_0.txt";
} else {
url = argv[1];
}
std::cout << "URL: " << url << std::endl;
std::cout << std::endl;
WEBCC_LOG_INIT("", webcc::LOG_CONSOLE);
// Leave port to default value.
webcc::HttpRequest request(webcc::http::kGet, url);
request.Prepare();
// Verify the certificate of the peer or not.
// See HttpSslClient::Request() for more details.
bool ssl_verify = false;
webcc::HttpSslClient client(ssl_verify, 2000);
if (client.Request(request)) {
//std::cout << client.response()->content() << std::endl;
} else {
std::cout << webcc::DescribeError(client.error());
if (client.timed_out()) {
std::cout << " (timed out)";
}
std::cout << std::endl;
}
return 0;
}
@@ -1,13 +0,0 @@
set(TARGET_NAME rest_book_async_client)
set(SRCS
../common/book.cc
../common/book.h
../common/book_json.cc
../common/book_json.h
main.cc)
add_executable(${TARGET_NAME} ${SRCS})
target_link_libraries(${TARGET_NAME} webcc jsoncpp ${Boost_LIBRARIES})
target_link_libraries(${TARGET_NAME} "${CMAKE_THREAD_LIBS_INIT}")
-194
View File
@@ -1,194 +0,0 @@
#include <iostream>
#include "json/json.h"
#include "webcc/logger.h"
#include "webcc/rest_async_client.h"
#include "example/common/book.h"
#include "example/common/book_json.h"
// -----------------------------------------------------------------------------
class BookClientBase {
public:
BookClientBase(boost::asio::io_context& io_context,
const std::string& host, const std::string& port,
int timeout_seconds)
: rest_client_(io_context, host, port) {
rest_client_.SetTimeout(timeout_seconds);
}
virtual ~BookClientBase() = default;
protected:
void PrintSeparateLine() {
std::cout << "--------------------------------";
std::cout << "--------------------------------";
std::cout << std::endl;
}
// Generic response handler for RestAsyncClient APIs.
void GenericHandler(std::function<void(webcc::HttpResponsePtr)> rsp_callback,
webcc::HttpResponsePtr response,
webcc::Error error,
bool timed_out) {
if (error != webcc::kNoError) {
std::cout << webcc::DescribeError(error);
if (timed_out) {
std::cout << " (timed out)";
}
std::cout << std::endl;
} else {
// Call the response callback on success.
rsp_callback(response);
}
}
webcc::RestAsyncClient rest_client_;
};
// -----------------------------------------------------------------------------
class BookListClient : public BookClientBase {
public:
BookListClient(boost::asio::io_context& io_context,
const std::string& host, const std::string& port,
int timeout_seconds)
: BookClientBase(io_context, host, port, timeout_seconds) {
}
void ListBooks(webcc::HttpResponseCallback callback) {
std::cout << "ListBooks" << std::endl;
rest_client_.Get("/books", callback);
}
void CreateBook(const std::string& title, double price,
std::function<void(std::string)> id_callback) {
std::cout << "CreateBook: " << title << " " << price << std::endl;
Json::Value json(Json::objectValue);
json["title"] = title;
json["price"] = price;
auto rsp_callback = [id_callback](webcc::HttpResponsePtr response) {
Json::Value rsp_json = StringToJson(response->content());
id_callback(rsp_json["id"].asString());
};
rest_client_.Post("/books", JsonToString(json),
std::bind(&BookListClient::GenericHandler, this,
rsp_callback,
std::placeholders::_1,
std::placeholders::_2,
std::placeholders::_3));
}
};
// -----------------------------------------------------------------------------
class BookDetailClient : public BookClientBase {
public:
BookDetailClient(boost::asio::io_context& io_context,
const std::string& host, const std::string& port,
int timeout_seconds)
: BookClientBase(io_context, host, port, timeout_seconds) {
}
void GetBook(const std::string& id, webcc::HttpResponseCallback callback) {
std::cout << "GetBook: " << id << std::endl;
auto rsp_callback = [](webcc::HttpResponsePtr response) {
Json::Value rsp_json = StringToJson(response->content());
//id_callback(rsp_json["id"].asString());
};
rest_client_.Get("/books/" + id, callback);
}
void UpdateBook(const std::string& id,
const std::string& title,
double price,
webcc::HttpResponseCallback callback) {
std::cout << "UpdateBook: " << id << " " << title << " " << price
<< std::endl;
// NOTE: ID is already in the URL.
Json::Value json(Json::objectValue);
json["title"] = title;
json["price"] = price;
rest_client_.Put("/books/" + id, JsonToString(json), callback);
}
void DeleteBook(const std::string& id, webcc::HttpResponseCallback callback) {
std::cout << "DeleteBook: " << id << std::endl;
rest_client_.Delete("/books/" + id, callback);
}
};
// -----------------------------------------------------------------------------
void Help(const char* argv0) {
std::cout << "Usage: " << argv0 << " <host> <port> [timeout]" << std::endl;
std::cout << " E.g.," << std::endl;
std::cout << " " << argv0 << " localhost 8080" << std::endl;
std::cout << " " << argv0 << " localhost 8080 2" << std::endl;
}
int main(int argc, char* argv[]) {
if (argc < 3) {
Help(argv[0]);
return 1;
}
WEBCC_LOG_INIT("", webcc::LOG_CONSOLE);
std::string host = argv[1];
std::string port = argv[2];
int timeout_seconds = -1;
if (argc > 3) {
timeout_seconds = std::atoi(argv[3]);
}
boost::asio::io_context io_context;
BookListClient list_client(io_context, host, port, timeout_seconds);
BookDetailClient detail_client(io_context, host, port, timeout_seconds);
// Response handler.
auto handler = [](webcc::HttpResponsePtr response, webcc::Error error,
bool timed_out) {
if (error == webcc::kNoError) {
std::cout << response->content() << std::endl;
} else {
std::cout << webcc::DescribeError(error);
if (timed_out) {
std::cout << " (timed out)";
}
std::cout << std::endl;
}
};
list_client.ListBooks(handler);
list_client.CreateBook("1984", 12.3, [](std::string id) {
std::cout << "ID: " << id << std::endl;
});
//detail_client.GetBook("1", handler);
//detail_client.UpdateBook("1", "1Q84", 32.1, handler);
//detail_client.GetBook("1", handler);
//detail_client.DeleteBook("1", handler);
//list_client.ListBooks(handler);
io_context.run();
return 0;
}
+1 -2
View File
@@ -9,8 +9,7 @@ set(SRCS
add_executable(${TARGET_NAME} ${SRCS})
target_link_libraries(${TARGET_NAME} webcc jsoncpp ${Boost_LIBRARIES})
target_link_libraries(${TARGET_NAME} "${CMAKE_THREAD_LIBS_INIT}")
target_link_libraries(${TARGET_NAME} ${EXAMPLE_COMMON_LIBS} jsoncpp)
# Install VLD DLLs to build dir so that the example can be launched from
# inside VS.
+4 -4
View File
@@ -20,7 +20,7 @@
// -----------------------------------------------------------------------------
class BookClientBase {
public:
public:
BookClientBase(const std::string& host, const std::string& port,
int timeout_seconds)
: host_(host), port_(port) {
@@ -29,7 +29,7 @@ class BookClientBase {
virtual ~BookClientBase() = default;
protected:
public:
// Helper function to make a request.
webcc::HttpRequestPtr MakeRequest(const std::string& method,
const std::string& url,
@@ -71,7 +71,7 @@ class BookClientBase {
// -----------------------------------------------------------------------------
class BookListClient : public BookClientBase {
public:
public:
BookListClient(const std::string& host, const std::string& port,
int timeout_seconds)
: BookClientBase(host, port, timeout_seconds) {
@@ -131,7 +131,7 @@ class BookListClient : public BookClientBase {
// -----------------------------------------------------------------------------
class BookDetailClient : public BookClientBase {
public:
public:
BookDetailClient(const std::string& host, const std::string& port,
int timeout_seconds)
: BookClientBase(host, port, timeout_seconds) {
+6 -6
View File
@@ -9,12 +9,12 @@
// -----------------------------------------------------------------------------
class BookListService : public webcc::RestListService {
public:
public:
explicit BookListService(int sleep_seconds)
: sleep_seconds_(sleep_seconds) {
}
protected:
public:
// Get a list of books based on query parameters.
void Get(const webcc::UrlQuery& query, webcc::RestResponse* response) final;
@@ -22,7 +22,7 @@ class BookListService : public webcc::RestListService {
void Post(const std::string& request_content,
webcc::RestResponse* response) final;
private:
private:
// Sleep some seconds before send back the response.
// For testing timeout control in client side.
int sleep_seconds_;
@@ -33,12 +33,12 @@ class BookListService : public webcc::RestListService {
// The URL is like '/books/{BookID}', and the 'url_sub_matches' parameter
// contains the matched book ID.
class BookDetailService : public webcc::RestDetailService {
public:
public:
explicit BookDetailService(int sleep_seconds)
: sleep_seconds_(sleep_seconds) {
}
protected:
public:
// Get the detailed information of a book.
void Get(const webcc::UrlSubMatches& url_sub_matches,
const webcc::UrlQuery& query,
@@ -53,7 +53,7 @@ class BookDetailService : public webcc::RestDetailService {
void Delete(const webcc::UrlSubMatches& url_sub_matches,
webcc::RestResponse* response) final;
private:
private:
// Sleep some seconds before send back the response.
// For testing timeout control in client side.
int sleep_seconds_;
+1 -2
View File
@@ -11,8 +11,7 @@ set(SRCS
add_executable(${TARGET_NAME} ${SRCS})
target_link_libraries(${TARGET_NAME} webcc pugixml ${Boost_LIBRARIES})
target_link_libraries(${TARGET_NAME} "${CMAKE_THREAD_LIBS_INIT}")
target_link_libraries(${TARGET_NAME} ${EXAMPLE_COMMON_LIBS} pugixml)
# Install VLD DLLs to build dir so that the example can be launched from
# inside VS.
+2 -2
View File
@@ -10,7 +10,7 @@
#include "example/common/book.h"
class BookClient {
public:
public:
BookClient(const std::string& host, const std::string& port);
int code() const { return code_; }
@@ -28,7 +28,7 @@ class BookClient {
// Delete a book by ID.
bool DeleteBook(const std::string& id);
private:
private:
// Call with 0 parameter.
bool Call0(const std::string& operation, std::string* result_str);
+2 -2
View File
@@ -4,11 +4,11 @@
#include "webcc/soap_service.h"
class BookService : public webcc::SoapService {
public:
public:
bool Handle(const webcc::SoapRequest& soap_request,
webcc::SoapResponse* soap_response) override;
private:
private:
bool CreateBook(const webcc::SoapRequest& soap_request,
webcc::SoapResponse* soap_response);
@@ -8,7 +8,7 @@
static const std::string kResultName = "Result";
class CalcClient {
public:
public:
CalcClient(const std::string& host, const std::string& port)
: soap_client_(host, port) {
soap_client_.SetTimeout(5);
@@ -44,7 +44,7 @@ class CalcClient {
return Calc("unknown", "x", "y", x, y, result);
}
private:
private:
bool Calc(const std::string& operation,
const std::string& x_name, const std::string& y_name,
double x, double y,
-6
View File
@@ -1,6 +0,0 @@
set(TARGET_NAME soap_calc_client)
add_executable(${TARGET_NAME} main.cc)
target_link_libraries(${TARGET_NAME} webcc pugixml ${Boost_LIBRARIES})
target_link_libraries(${TARGET_NAME} "${CMAKE_THREAD_LIBS_INIT}")
@@ -8,7 +8,7 @@
static const std::string kResultName = "Result";
class CalcClient {
public:
public:
// NOTE: Parasoft's calculator service uses SOAP V1.1.
CalcClient(const std::string& host, const std::string& port)
: soap_client_(host, port, webcc::kSoapV11) {
@@ -45,7 +45,7 @@ class CalcClient {
return Calc("unknown", "x", "y", x, y, result);
}
private:
private:
bool Calc(const std::string& operation,
const std::string& x_name, const std::string& y_name,
double x, double y,
@@ -1,6 +0,0 @@
set(TARGET_NAME soap_calc_client_parasoft)
add_executable(${TARGET_NAME} main.cc)
target_link_libraries(${TARGET_NAME} webcc pugixml ${Boost_LIBRARIES})
target_link_libraries(${TARGET_NAME} "${CMAKE_THREAD_LIBS_INIT}")
@@ -1,250 +0,0 @@
<?xml version="1.0" encoding="US-ASCII"?>
<!--generated by GLUE Standard 4.1.2 on Fri Nov 21 13:50:48 PST 2003-->
<wsdl:definitions name="Calculator"
targetNamespace="http://www.parasoft.com/wsdl/calculator/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tme="http://www.themindelectric.com/"
xmlns:tns="http://www.parasoft.com/wsdl/calculator/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xsd:schema
elementFormDefault="qualified"
targetNamespace="http://www.parasoft.com/wsdl/calculator/">
<xsd:element
name="add">
<xsd:complexType>
<xsd:sequence>
<xsd:element
name="x" type="xsd:float"/>
<xsd:element name="y"
type="xsd:float"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element
name="addResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element
name="Result"
type="xsd:float"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element
name="divide">
<xsd:complexType>
<xsd:sequence>
<xsd:element
name="numerator" type="xsd:float"/>
<xsd:element
name="denominator"
type="xsd:float"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element
name="divideResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element
name="Result"
type="xsd:float"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element
name="multiply">
<xsd:complexType>
<xsd:sequence>
<xsd:element
name="x" type="xsd:float"/>
<xsd:element name="y"
type="xsd:float"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element
name="multiplyResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element
name="Result"
type="xsd:float"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element
name="subtract">
<xsd:complexType>
<xsd:sequence>
<xsd:element
name="x" type="xsd:float"/>
<xsd:element name="y"
type="xsd:float"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element
name="subtractResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element
name="Result"
type="xsd:float"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message
name="add0In">
<wsdl:part element="tns:add"
name="parameters"/>
</wsdl:message>
<wsdl:message
name="add0Out">
<wsdl:part element="tns:addResponse"
name="parameters"/>
</wsdl:message>
<wsdl:message
name="divide1In">
<wsdl:part element="tns:divide"
name="parameters"/>
</wsdl:message>
<wsdl:message
name="divide1Out">
<wsdl:part element="tns:divideResponse"
name="parameters"/>
</wsdl:message>
<wsdl:message
name="multiply2In">
<wsdl:part element="tns:multiply"
name="parameters"/>
</wsdl:message>
<wsdl:message
name="multiply2Out">
<wsdl:part element="tns:multiplyResponse"
name="parameters"/>
</wsdl:message>
<wsdl:message
name="subtract3In">
<wsdl:part element="tns:subtract"
name="parameters"/>
</wsdl:message>
<wsdl:message
name="subtract3Out">
<wsdl:part element="tns:subtractResponse"
name="parameters"/>
</wsdl:message>
<wsdl:portType
name="ICalculator">
<wsdl:operation name="add"
parameterOrder="x y">
<wsdl:input message="tns:add0In"
name="add0In"/>
<wsdl:output message="tns:add0Out"
name="add0Out"/>
</wsdl:operation>
<wsdl:operation name="divide"
parameterOrder="numerator denominator">
<wsdl:input
message="tns:divide1In" name="divide1In"/>
<wsdl:output
message="tns:divide1Out"
name="divide1Out"/>
</wsdl:operation>
<wsdl:operation
name="multiply" parameterOrder="x y">
<wsdl:input
message="tns:multiply2In" name="multiply2In"/>
<wsdl:output
message="tns:multiply2Out"
name="multiply2Out"/>
</wsdl:operation>
<wsdl:operation
name="subtract" parameterOrder="x y">
<wsdl:input
message="tns:subtract3In" name="subtract3In"/>
<wsdl:output
message="tns:subtract3Out"
name="subtract3Out"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding
name="ICalculator" type="tns:ICalculator">
<soap:binding
style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation
name="add">
<soap:operation soapAction="add"
style="document"/>
<wsdl:input name="add0In">
<soap:body
use="literal"/>
</wsdl:input>
<wsdl:output
name="add0Out">
<soap:body
use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation
name="divide">
<soap:operation soapAction="divide"
style="document"/>
<wsdl:input name="divide1In">
<soap:body
use="literal"/>
</wsdl:input>
<wsdl:output
name="divide1Out">
<soap:body
use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation
name="multiply">
<soap:operation soapAction="multiply"
style="document"/>
<wsdl:input name="multiply2In">
<soap:body
use="literal"/>
</wsdl:input>
<wsdl:output
name="multiply2Out">
<soap:body
use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation
name="subtract">
<soap:operation soapAction="subtract"
style="document"/>
<wsdl:input name="subtract3In">
<soap:body
use="literal"/>
</wsdl:input>
<wsdl:output
name="subtract3Out">
<soap:body
use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service
name="Calculator">
<wsdl:documentation>instance of class webtool.soap.examples.calculator.Calculator</wsdl:documentation>
<wsdl:port
binding="tns:ICalculator" name="ICalculator">
<soap:address
location="http://ws1.parasoft.com/glue/calculator"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
+1 -1
View File
@@ -4,7 +4,7 @@
#include "webcc/soap_service.h"
class CalcService : public webcc::SoapService {
public:
public:
CalcService() = default;
~CalcService() override = default;