0

使用 Gsoap 访问 IIS Web 服务。我有类似的错误,因为在此链接中显示该错误已通过 -lssl 编译解决。

我在构建中做了同样的事情

g++ -o client client.cpp stdsoap2.cpp soapC.cpp  soapDataManagementSoapProxy.cpp -I /usr/local/ssl/include -L/home/xavier/GSOAP/lib -lgsoapssl++  -L/usr/local/ssl/lib -lssl

我的 GSOAP 库是用 OpenSSL 构建的。

但我仍然有错误

SOAP 1.2 fault SOAP-ENV:Sender[no subcode]
"OpenSSL not installed: recompile with -DWITH_OPENSSL"
Detail: [no detail]

我的测试代码如下。有什么问题?

#include "soapDataManagementSoapProxy.h"
#include "DataManagementSoap.nsmap"

const char server[] = "https://XXXXXXX.com/XXXmanagement.asmx";

int main(int argc, char **argv)
{
  DataManagementSoapProxy webinf;
  webinf.soap_endpoint = server;
  _tempuri__ReadTestData* a;
  _tempuri__ReadTestDataResponse res;
  int ret = webinf.ReadTestData(a, res);
  if (webinf.error){
    webinf.soap_stream_fault(std::cerr);    
  }
  else{
    //printf("result = %g\n", result);
    std::cout << "Success " << std::endl;
  }
  webinf.destroy(); /* clean up mem */
  return 0;
}
4

1 回答 1

0

这个问题的解决方案是

#include "calc.nsmap"
#include "soapcalcProxy.h" // generated with soapcpp2 -j calc.h

calcProxy calc("https-server-endpoint-URL");
double sum;
soap_ssl_init();       // init SSL (just need to do this once in an application)
// soap_ssl_no_init(); // or prevent init OpenSSL when already initialized elsewhere in an application
if (soap_ssl_client_context(calc.soap,
   SOAP_SSL_DEFAULT,
   NULL,          // no keyfile
   NULL,          // no keyfile password
   "cacerts.pem", // trusted certificates (or use self-signed cacert.pem)
   NULL,          // no capath to trusted certificates
   NULL           // no random data to seed randomness
))
{
   calc.soap_stream_fault(std::cerr);
   exit(EXIT_FAILURE);
}
if (calc.add(1.23, 4.56, sum) == SOAP_OK)
于 2020-08-24T04:30:22.307 回答