PEAR has a few quite nice classes dealing with SOAP call, the SOAP_WSDL and SOAP_Client, I found out, are the most easy-to-use ones. However, when I try to use SOAP_WSDL to make a SSL connection, it really sucks. To make a SSL connection, PEAR::SOAP requires the cURL extension, which means a certain curl_options have to be set to for the certification reason. Although, both SOAP_WSDL and SOAP_Client expose their ways to allow users passing the curl_options. In my practice, SOAP_WSDL wont capture the curl options passed to it. :(.Luckly, the SOAP_Client works….Here are some of the comments.
1. To avoid the ‘SSL certificate problem, verify that the CA cert is OK. error:14090086:SSL.routines:SSL3_GET_SERVER_CERTIFICATE:certificate’

$soapClient->setOpt('curl', CURLOPT_SSL_VERIFYPEER, 0); 

2. To avoid the SSL: certificate subject name ‘www.domain1.com’ does not match target host name ‘www.domain2.com’


$soapClient->setOpt('curl', CURLOPT_SSL_VERIFYHOST, 0); 

3. Here are the full sample codes

[php]//reset the path to the PEAR package
ini_set(‘include_path’, ‘/usr/share/php’ . PATH_SEPARATOR . ini_get(‘include_path’));
require_once(‘SOAP/Client.php’);
$soapClient = new SOAP_Client(‘https://www.domain.net/SoapSSL.wsdl’, true, ”);
//set options of cURL for SSL connection
$soapClient->setOpt(‘curl’, CURLOPT_SSL_VERIFYPEER, 0);
$soapClient->setOpt(‘curl’, CURLOPT_SSL_VERIFYHOST, 0);
print “startingn”;
$cs_params = array( ‘Param1’ => ‘value1’, ‘Param2’ => ‘value2’, );
//Call the method defined at the SOAP endpoint
$res = $soapClient->call(‘methodName’, $cs_params);
if (PEAR::isError($res)) {
print “WARNING: an error occured in the SOAP call ” . $res . “n”;
print “message ” . $res->message . “n”;
} else {
print “INFO: SOAP call returned OKn”;
print_r($res);
}
[/php]

Dr. Gang Lu - Founder of TechNode. He's a Blogger, a Geek, a PhD and a Speaker, with passion in Tech, Internet and R'N'R.

Join the Conversation

2 Comments

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.