cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4906
Views
2
Helpful
5
Replies

PHP and AXL CUCM

thanhduytran
Level 1
Level 1

Hi all,

I am using CUCM 10.6 and when i downloaded axlsqltoolkit from server, i show that's current version of AXL is 10.5.

I want to write a simple code to get FAC code by PHP.

I finded example in Dev Primer and this is my code:

<?php

    $host="10.15.30.101";

    $username="admin";

    $password="example";

    $client = new SoapClient("AXLAPI.wsdl",

        array('trace'=>true,

       'exceptions'=>true,

       'location'=>"https://".$host.":8443/axl",

       'login'=>$username,

       'password'=>$password

    ));

  function getFacInfo($client, $name) {

        $returnedTags = array("name"=>"","code"=>"","authorizationLevel"=>"");

        try {

            $response = $client->getFacInfo(array("name"=>$name),array("returnedTags"=>$returnedTags));

        }

        catch (SoapFault $sf) {

            echo "SoapFault: " . $sf . "<BR>";

        }

        catch (Exception $e) {

            echo "Exception: " . $e . "<BR>";

        }

        echo("Uuid: ".$response->return->facInfo->uuid."<br>");

        echo("Name: ".$response->return->facInfo->name."<br>");

        echo("Code: ".$response->return->facInfo->code."<br>");

        echo("Auth Level: ".$response->return->facInfo->authorizationLevel."<br>");

        echo("<hr>");

    }

  echo getFacInfo($client,"myname");

?>

And this is error:

SoapFault: SoapFault exception: [HTTP] Could not connect to host.

Anyone show me what is wrong?

"admin" is my application user and have "Standard AXL API Access" and "Standard CCM Admin User" roles. I put AXLAPI.wsdl in same location with this code files (root document).

I fiined another example in this link:

CUP API example on php

Need I login and get session id? or i need encrypt password to Base64 ???

thanks all.

1 Accepted Solution

Accepted Solutions

Yes, I ran it in our lab and it worked fine for me.  I'm also using XAMPP.  It shouldn't make a difference, but you can try using the server host name instead of an IP address.  Another quick question - how are you running your PHP script?  Via a browser and apache?  Via a browser and the php file?  At the command-line? 

Get Fac Info


Uuid: {62724065-ED78-EF16-E12D-BFB9A302F818}

Name: The Big Cheese FAC

Code: 1234

Auth Level: 200



View solution in original post

5 Replies 5

npetrele
Cisco Employee
Cisco Employee

You don't need to encrypt the username/password to Base64.

I only get that error if I'm not connected to the VPN (it's the only way for me to access to the server). In other words, make sure you can actually reach the server.  Try going to the server URL in your browser.  For example, navigate in your browser to:


https://servername.com:8443/axl


After you enter the admin username and password, you should see this:


Cisco CallManager: AXL Web Service

The AXL Web Service is working and accepting requests. Use HTTP POST to send a request.

If you don't see that in your browser, then there's a problem getting to your server.

As for your code, it looks fine to me, except for this line (but this wouldn't cause your problem):

  echo getFacInfo($client,"myname");


Just remove the "echo" part, so that it's this:


getFacInfo($client,"myname");

Did you remember to put AXLEnums.xsd and AXLSoap.xsd in the same directory?   Also, some people recommend putting these at the top, just before you define the $client:

ini_set('soap.wsdl_cache_enabled',0);
ini_set('soap.wsdl_cache_ttl',0);
ini_set('default_socket_timeout', 180);

Put a timeout in your client, too:

$client = new SoapClient("AXLAPI.wsdl",

     array('trace'=>true,

     'exceptions'=>true,

     'location'=>"https://".$host.":8443/axl",

     'login'=>$username,

     'password'=>$password,

     "connection_timeout"=>60

));

Also, make sure your PHP was compiled with openssl.  You can check your server configuration with:

phpinfo();

This command will display everything you want to know (and much more) when you navigate to the PHP page.  Make that the first command in your PHP script, or just write a simple PHP page with that command.

Hi Nicholas,

Thanks for your post.

follow your idea,i take some change from my code.

1/ phpinfo() : i am using XAMPP and support openSSL 1.0.

2/ I don't forget copy AXLEnums.xds and AXLSoap.xsd in this folder.

3/ When i open this link (https://servername.com:8443/axl) and login by $hostname and $password. It's successfully

Can you try run this code into your lab and show me the result?.

P/S: this's fully error message:

SoapFault: SoapFault exception: [HTTP] Could not connect to host in C:\xampp\htdocs\index.php:25 Stack trace: #0 [internal function]: SoapClient->__doRequest('__call('getFacInfo', Array) #2 C:\xampp\htdocs\index.php(25): SoapClient->getFacInfo(Array, Array) #3 C:\xampp\htdocs\index.php(42): getFacInfo(Object(SoapClient), 'myname') #4 {main}

Yes, I ran it in our lab and it worked fine for me.  I'm also using XAMPP.  It shouldn't make a difference, but you can try using the server host name instead of an IP address.  Another quick question - how are you running your PHP script?  Via a browser and apache?  Via a browser and the php file?  At the command-line? 

Get Fac Info


Uuid: {62724065-ED78-EF16-E12D-BFB9A302F818}

Name: The Big Cheese FAC

Code: 1234

Auth Level: 200



Quick answer:

i openning php  web via Web Brower.

i don't think this is the problem :-/

But i will try using server host name.

many thanks

Updated: Successfully. I will vote for you

Wonderful!  I'm happy that worked for you.  Have fun!