0

I have written a client for experttexting web-service using C++ and gSOAP. Currently this client should call the SendSMS procedure and send a single sms text message to a number specified in place of 'TO' (please see cod below). The program runs smoothly but the sms text message is not delivered. Upon investigation I found that the line

int message_status_code=service.SendSMS("https://www.experttexting.com/exptapi/exptsms.asmx","SendSMS",request_packet,request_packet_response);

gives the error code which has a value equal to SOAP_SSL_ERROR.

To rectify this problem I used the flag -DWITH_OPENSSL while compiling using g++ but to no avail.

Please help me to debug this problem.

#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;
}
Syed Daniyal Shah
  • 193
  • 1
  • 2
  • 12
  • It seems that server is expecting SSL connection, but there is no one on client side. Where is your code for SSL connection? – Kahn Mar 02 '15 at 02:47
  • I don't have code for SSL connection. I called the same web service in php using SoapClient and it worked – Syed Daniyal Shah Mar 02 '15 at 04:35
  • I don't know much about SoapClient, but I don't see any SSL handshake in this code. Did you try SSL handshake? – Kahn Mar 02 '15 at 12:35

1 Answers1

0

You need to provide ssl context before making service call. If server does not require client authentication, you may use the code below, otherwise you need to provide client certificate and key.

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);
  }
Kahn
  • 755
  • 3
  • 11
  • 28