I am trying to compile the below piece of code to run a basic https server and i am encountering an error which i am not able to resolve. The class hello_world_resource is responsible for the server startup and the return statement gives the response that the server should give when it is accessed.
the url for the server is defined by function 'register_resource'
the url for the github documentation of the library - https://github.com/etr/libhttpserver
I've tried downloading ssl and curl multiple times and searched the google too but i am still not able to find the cause for this problem.
abcd.key and xyz.crt are the self-signed certificates that i generated following this procedure online -
https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-apache-in-ubuntu-16-04
#include <httpserver.hpp>
using namespace httpserver;
class hello_world_resource : public http_resource
{
public:
const std::shared_ptr<http_response> render(const http_request&)
{
return std::shared_ptr<http_response>(new
string_response("Hello, World!"));
}
};
int main()
{
webserver ws = create_webserver(8080)
.use_ssl()
.https_mem_key("/path/to/abcd.key")
.https_mem_cert("/path/to/xyz.crt");
hello_world_resource hwr;
ws.register_resource("/hello", &hwr);
ws.start(true);
return 0;
}
The error being thrown is :
terminate called after throwing an instance of 'std::invalid_argument'
what(): BD
A
(G BBJ
Aborted
the code should run and a server should be available at - https://localhost:8080/hello
Related
Trying to use restart with source in case of Kafka rebalance , however below code is throwing error when using Alpakka Kafka library
Throwing complies error while using below code
Caused by: java.lang.ClassCastException: akka.NotUsed$ cannot be cast to java.util.concurrent.CompletionStage
CompletionStage<Done> streamCompletion =
RestartSource.onFailuresWithBackoff(
restartSettings,
() ->
Consumer.plainSource(consumerSettings, Subscriptions.topics(topic))
.mapMaterializedValue(
c -> {
// this is a hack to get access to the Consumer.Control
// instances of the latest Kafka Consumer source
control.set(c);
return c;
})
.via(business()))
.runWith(Sink.ignore(), system);
Introduction
I am new to using mysql in c++ and have been trying to use mysqlcppconnector for connecting to my local database. I have successfully linked the libraries after a lot of effort. (It wasn't straightforward for me)
Preparation
I am using the following code to connect with a database running on my local.
#include <mysqlx/xdevapi.h>
void make_db_connection() {
mysqlx::Session sess("localhost", 33060, "mudrex", "mudrex");
mysqlx::Schema db= sess.getSchema("mudrex");
// or Schema db(sess, "test");
mysqlx::Collection myColl = db.getCollection("user_api_key_map");
// or Collection myColl(db, "my_collection");
mysqlx::DocResult myDocs = myColl.find("user_id")
.limit(1)
.bind("user_id","L%").execute();
cout << myDocs.fetchOne()<<endl;
}
Errors
When I call the above function, I get the following error :
libc++abi.dylib: terminating with uncaught exception of type mysqlx::abi2::r0::Error: CDK Error: Connection refused (generic:61)
Abort trap: 6
Any help would be really appreciated. Thank you for your time.
mysqlx::Session is for connection to the MySQL X protocol. The Error: Connection refused is the very first hint of missing listeners of the port 33060. You need to install and enable the MySQL Shell that supports X Protocol and enables you to use X DevAPI. See https://dev.mysql.com/doc/mysql-shell/en/mysql-shell-install.html for instructions.
I created a Win32Console application using MSVS2013 and it was compiled successfully. Now I tried creating a service using CreateService and binary path was set to the path of the above produced executable. Though I was able to create the service, I cannot start it using StartService. The error code 1053 is thrown each time. I tried using sc.exe and also tried to start the service manually from Services. The same error is shown. How can I solve it now?
You must create a ServiceMain.
Here is a sample.
If you want to execute a non-service application you can use psexec.
You have collision with SC- manager and your function inside application start service
your name of the function service dispatcher table for service;)
prevent from error 1053 if call was send not from SC - manager
C++ code:
if(argc < 2)
{
if(!Service_Dispatcher_Table())
{
std::cout<<"ERROR :"<< GetLastError();
}
}
else
{
//your command line "argc"
}
//here your commands or function : startservice();
I am trying to call a web service from my SmartGWT program by coding on server side.
However the XMLTools.LoadWSDL(WSDLurl,WSDLLoadCallback) is giving me an error for the following code:
CODE :
XMLTools.loadWSDL("http://www.webservicex.net/uszip.asmx?WSDL",new WSDLLoadCallback(){
//#Override
public void execute(WebService webService) {
System.out.println("********************In XMLTools");
temp = webService;
}
});
ERROR :
java.lang.UnsatisfiedLinkError: com.smartgwt.client.data.XMLTools.loadWSDL(Ljava/lang/String;Lcom/smartgwt/client/data/WSDLLoadCallback;
What would be the cause and possible solution for the same?
Thanks!
I am writing a simple cmd client to try to consume the WCF web service i developed in order to test how to connect to the Web service using unmanaged C++.
I have been following this tutorial http://www.blinnov.com/en/2008/01/22/wcf-service-unmanaged-client/ step by step but still not managed to consume the service successfully.
#include "BasicHttpBinding_USCOREIService1.nsmap"
#include "soapBasicHttpBinding_USCOREIService1Proxy.h"
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char **argv)
{
BasicHttpBinding_USCOREIService1Proxy myProxy;
static const char* const endPoint = "http://localhost:50181/Service1.svc";
myProxy.soap_endpoint = endPoint;
_ns1__GetData param;
_ns1__GetDataResponse response;
param.fileName = &std::string("house.ifc");
if ( myProxy.GetData(¶m, &response) == SOAP_OK) {
cout << "Hello" << endl; //Succeeded
}
else {
myProxy.soap_stream_fault(std::cerr);
}
return 0;
}
it always gives me
Error 415 fault: SOAP-ENV:Server[no subcode]
"HTTP Error"
Detail: HTTP/1.1 415 Unsupported Media Type
I have been trying all the day to get it done but still nothing new. :(
This is because gSOAP client and WCF service do not play nicely with SOAP 1.2.
It will work if you use soapcpp2 with the "-1" switch to force SOAP 1.1.
I've tested it with gSOAP 2.8.4 on Ubuntu and it works.
If your client will be installed in windows machine , the best way is to use a C++\CLI bridge that connect your client and the managed generated proxy, this is the only solution that works for all kind of wcf bindings (HTTP,TCP,MSMQ,...).
If you choose another librairy be sure that it can works perfectly only for HTTP binding.