I want to connect to a web-service which sends sms. I want to connect with SoapClient but it cannot even connect in server but working in local. What does cause this not to work?

My code was this:

libxml_disable_entity_loader(false);
try {
    $options = array(
        'cache_wsdl' => WSDL_CACHE_MEMORY,
        'trace' => 1,
        'stream_context' => stream_context_create(array(
            'ssl' => array(
                'verify_peer' => false,
                'verify_peer_name' => false,
                'allow_self_signed' => true
            ),
            'http' => array(
                'user_agent' => 'PHPSoapClient'
            ),
        ))
    );

    $wsdlUrl = 'http://example.com/SendService.svc?wsdl';
    $soapClientOptions = array(
        'stream_context' => $options,
        'cache_wsdl' => WSDL_CACHE_NONE
    );

    $client = new SoapClient($wsdlUrl, $soapClientOptions);

    return $client;
} catch (Exception $e) {
    die($e->getMessage());
}

But I changed the content of $options to:

'encoding' => 'UTF-8',
'exceptions' => 1,
'trace' => TRUE,
// This below is the one I've downloaded from https://curl.haxx.se
// But I have set it to /ssl.pem which is my own certificate
// none of them work!
'local_cert' => '/cacert.pem',
// 'passphrase' => $this->passphrase,
//'ssl_method' => SOAP_SSL_METHOD_SSLv2,
'authentication' => SOAP_AUTHENTICATION_DIGEST,
'soap_version'  => SOAP_1_2,
'cache_wsdl' => WSDL_CACHE_NONE,
'stream_context' => stream_context_create([
    'ssl' => [
        'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
    ]
])

I think the problem might be from that local_cert line or there should be a new line for cafile. Is the root path of local_cert and cafile from the root I've set in virtualhost? I mean my root is from /home/mysite/public_html or /home or something else?

What cause this and how can I fix it?

0 Answers