10-19-2017 05:51 AM
Hey I'm struggling to establish a connection to cucm using PHP. Ive basically just copy pasted the PHP code on the getting started page but I keep getting the following error:
SoapFault: SoapFault exception: [HTTP] Could not connect to host in /Users/matt/Documents/cucm/CreateUserCUCM.php:33
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'https://10.10.2...', 'CUCM:DB ver=9.0...', 1, 0)
#1 /Users/matt/Documents/cucm/CreateUserCUCM.php(17): SoapClient->__call('getPhone', Array)
#2 {main}
I can connect to the server just fine so I know its not a reachability issue. Its gotta be with the soap request itself. I am running PHP 7 on my Mac, connected to a cisco sandbox. Tried v11 and 11.5. Using the latest wsdl I got from plugins page on CUCM and ive got the other two xsd files in same directory as my script too. The script I'm running is
<?php
$host="10.10.20.1";
$username="administrator";
$password="ciscopsdt";
$context = stream_context_create(array('ssl'=>array('allow_self_signed'=>true )));
$client = new SoapClient("./AXLAPI.wsdl",
array('trace'=>true,
'exceptions'=>true,
'location'=>"https://".$host.":8443/axl",
'login'=>$username,
'password'=>$password,
'stream_context'=>$context //Ive tried removing this option
));
try {
$response = $client->getPhone(array("name"=>"CSFUSER001"));
}
catch (SoapFault $sf) {
echo "SoapFault: " . $sf . "<BR>";
exit();
}
catch (Exception $e) {
echo "Exception: ". $e ."<br>";
exit();
}
?>
I can get it to work using a soap plugin for Chrome, albeit it was very picky about the xmlns. getPhone would only work when namespaces were specified as below... How can I check PHP is applying the namespaces correctly?:
<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:axl="http://www.cisco.com/AXL/API/11.0">
<x:Header/>
<x:Body>
<axl:getPhone>
<name>CSFUSER001</name>
</axl:getPhone>
</x:Body>
</x:Envelope>
Anyway I would really appreciate the help, i seriously cant figure it out! Thanks guys!
Solved! Go to Solution.
10-19-2017 10:23 AM
My suspicion would be that the hostname present in the certificate does not match the host name you are including in your URL, i.e. '10.10.2.x'. Assuming your CUCM is configured with a name as hostname, modifying your URL to use the CUCM hostname may fix it.
Or, if you want to also ignore host name checking, you can use some additional values in the stream context:
$context = stream_context_create([
'ssl' => [
// set some SSL/TLS specific options
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]);
or, even better, download the CUCM cert, and use it for a secure connection: PHP: SoapClient::SoapClient - Manual
10-19-2017 10:23 AM
My suspicion would be that the hostname present in the certificate does not match the host name you are including in your URL, i.e. '10.10.2.x'. Assuming your CUCM is configured with a name as hostname, modifying your URL to use the CUCM hostname may fix it.
Or, if you want to also ignore host name checking, you can use some additional values in the stream context:
$context = stream_context_create([
'ssl' => [
// set some SSL/TLS specific options
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]);
or, even better, download the CUCM cert, and use it for a secure connection: PHP: SoapClient::SoapClient - Manual
10-20-2017 02:59 PM
Perfect! Thanks heaps!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide