运行使用gSOAP创建的web服务客户端时出现SSL错误 我用C++和gSOAP编写了一个用于Web服务编程的客户端。目前,该客户端应调用SendSMS程序,并向指定的号码发送一条sms文本消息,以代替“收件人”,请参见下面的cod。程序运行平稳,但短信未发送。经调查,我发现这条线 int message_status_code=service.SendSMS("https://www.experttexting.com/exptapi/exptsms.asmx","SendSMS",request_packet,request_packet_response);
给出错误代码,该代码的值等于SOAP_SSL_error 为了纠正这个问题,我在使用g++编译时使用了标志-DWITH_OPENSSL,但没有用 请帮我调试这个问题运行使用gSOAP创建的web服务客户端时出现SSL错误 我用C++和gSOAP编写了一个用于Web服务编程的客户端。目前,该客户端应调用SendSMS程序,并向指定的号码发送一条sms文本消息,以代替“收件人”,请参见下面的cod。程序运行平稳,但短信未发送。经调查,我发现这条线 int message_status_code=service.SendSMS("https://www.experttexting.com/exptapi/exptsms.asmx","SendSMS",request_packet,request_packet_response);,c++,web-services,gsoap,C++,Web Services,Gsoap,给出错误代码,该代码的值等于SOAP_SSL_error 为了纠正这个问题,我在使用g++编译时使用了标志-DWITH_OPENSSL,但没有用 请帮我调试这个问题 #include "soapH.h" #include "ExptTextingAPISoap.nsmap" #include "soapExptTextingAPISoapProxy.h" int main(){ struct soap soap; soap_init(&soap); string Us
#include "soapH.h"
#include "ExptTextingAPISoap.nsmap"
#include "soapExptTextingAPISoapProxy.h"
int main(){
struct soap soap;
soap_init(&soap);
string UserID="MY USER Id";
string PWD="MY PASSWORD";
string APIKEY="MY API KEY";
string FROM="FROM";
string TO="RECEIVER";
string MSG="MY MESSAGE";
_ns1__SendSMS* request_packet=soap_new_set__ns1__SendSMS(&soap,&UserID,&PWD,&APIKEY,&FROM,&TO,&MSG);
_ns1__SendSMSResponse* request_packet_response=soap_new__ns1__SendSMSResponse(&soap);
ExptTextingAPISoapProxy service(soap);
int message_status_code=service.SendSMS("https://www.experttexting.com/exptapi/exptsms.asmx","SendSMS",request_packet,request_packet_response);
service.destroy();
return 0;
}
在进行服务调用之前,需要提供ssl上下文。如果服务器不需要客户端身份验证,则可以使用下面的代码,否则需要提供客户端证书和密钥
if (soap_ssl_client_context(&soap,
/* SOAP_SSL_NO_AUTHENTICATION, */ /* for encryption w/o authentication */
/* SOAP_SSL_DEFAULT | SOAP_SSL_SKIP_HOST_CHECK, */ /* if we don't want the host name checks since these will change from machine to machine */
SOAP_SSL_DEFAULT, /* use SOAP_SSL_DEFAULT in production code */
NULL, /* keyfile (cert+key): required only when client must authenticate to server (see SSL docs to create this file) */
NULL, /* password to read the keyfile */
"cacert.pem", /* optional cacert file to store trusted certificates, use cacerts.pem for all public certificates issued by common CAs */
NULL, /* optional capath to directory with trusted certificates */
NULL /* if randfile!=NULL: use a file with random data to seed randomness */
))
{ soap_print_fault(&soap, stderr);
exit(1);
}
服务器似乎需要SSL连接,但客户端并没有。SSL连接的代码在哪里?我没有SSL连接的代码。我使用SoapClient在php中调用了相同的web服务,它工作了。我不太了解SoapClient,但在这段代码中我没有看到任何SSL握手。你试过SSL握手吗?