cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
780
Views
3
Helpful
10
Replies
Highlighted
Beginner

How can I use AXL from Delphi program?

I want to create an AXL client using Delphi language. I have seen sample apps using PHP and JAVA but not using Delphi.

Can somebody help me?

Everyone's tags (2)
10 REPLIES 10
Highlighted
Beginner

Re: How can I use AXL from Delphi program?

Hi,

To use AXL API from Delphi as follows

1) Drop the TIdHTTP and TIdSSLIOHandlerSocketOpenSSL components to your form.

2) If you would like to list Phone By Description, you need to do as follows

var

  AXmlPost, AResponse: TStringStream;

  Temp, CUCMVersion: AnsiString;

begin

    AXmlPost := TStringStream.Create('');

    AResponse := TStringStream.Create('');

    CUCMVersion := 'CUCMB ver=8.0'; //If the version is 10 or 11 then you will set 'CUCMB ver=10.0' or 'CUCMB ver=11.0'

                                //In this case my version is 8.6

   try

     IdHttp1.Disconnect;

     IdHttp1.Request.Clear;

     IdHttp1.Request.Accept := 'text/xml';

     IdHttp1.Request.ContentType := 'text/xml';

     IdHttp1.Request.ContentEncoding := 'utf-8';

     IdHttp1.Request.BasicAuthentication := True;

     IdHttp1.Request.Authentication := TIdBasicAuthentication.Create;

     IdHttp1.Request.Authentication.Username := UserNameOfCUCM

     IdHttp1.Request.Authentication.Password := PasswordOfCUCM

     IdHttp1.Request.Method := 'POST';

     IdHttp1.Request.CustomHeaders.Clear;

     Temp := IdHttp1.Request.Authentication.Authentication;

     IdHttp1.Request.CustomHeaders.AddValue('Authorization', Temp);

     IdHttp1.Request.CustomHeaders.AddValue('SOAPAction', );

     AXmlPost.WriteString('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/8.0">');  //If your version is 10 or 11, you need to change 8.0 to 10.0 or 11.0

      AXmlPost.WriteString('<soapenv:Header/>');

      AXmlPost.WriteString('<soapenv:Body>');

      AXmlPost.WriteString('<ns:listPhone sequence="1">');

      AXmlPost.WriteString('  <searchCriteria>');

      AXmlPost.WriteString('    <description>' + DescriptionNameOfDeviceorPhone + '</description>'); //Description is a case Sensitive

      AXmlPost.WriteString('  </searchCriteria>');

      AXMLPost.WriteString('<returnedTags><name/><description/><callingSearchSpaceName/><dndOption/><dndStatus/></returnedTags>');

      AXmlPost.WriteString('</ns:listPhone>');

      AXmlPost.WriteString('</soapenv:Body>');

      AXmlPost.WriteString('</soapenv:Envelope>');

      IdHttp1.Post(Edit1.Text, AXmlPost, AResponse);

      Result := IdHttp1.ResponseCode = 200;

      if Result then

      begin

        Memo1.Lines.Add('Request ->');

        Memo1.Lines.Add(AXmlPost.DataString);

        AResponse.Seek(0, soFromBeginning); //Reset your stream position

        Memo1.Lines.Add('');

        Memo1.Lines.Add('Response ->');

        Memo1.Lines.Text := Memo1.Lines.Text + AResponse.DataString;

     end;

  except

      On E: Exception do

           Memo1.Lines.Add('Error: ' + E.Message);

end;

///////////////////////////////

This is a sample for listing phone by description. Hope it would help you.

Regards

Thuy Doan

Highlighted
Beginner

Re: How can I use AXL from Delphi program?

Hi,

Thank you for your answer. I have a question:

In your code one parameter is missing: IdHttp1.Request.CustomHeaders.AddValue('SOAPAction', ); I had thought that I must give here the URL of the Cisco. Am I right? I have tried it, but I got the error message: Error: Unknown Protocol

Highlighted
Beginner

Re: How can I use AXL from Delphi program?

Hi,

I am sorry to miss something in the source code (IdHttp1.Request.CustomHeaders.AddValue('SOAPAction', );

To rectify this as follow:

IdHttp1.Request.CustomHeaders.AddValue('SOAPAction', 'CUCMB ver=8.0');

Note:

CUCMB ver=8.0  -----> This is used for the CUCM version 8.0

If you have the CUCM version 10, it would be CUCM:DB ver=10.0

You can check the CUCM DB version at web site below.

https://developer.cisco.com/site/axl/discover/versioning/index.gsp

Hope, it would help you.

Regards,

Thuy Doan

Highlighted
Beginner

Re: How can I use AXL from Delphi program?

What is the reason my answer is rejected by the moderator?

Highlighted
Beginner

Re: How can I use AXL from Delphi program?

The only problem was a mistyping.

The wrong version is:

IdHttp1.Request.CustomHeaders.AddValue('SOAPAction', 'CUCMB ver=8.0');

The correct version is:

IdHttp1.Request.CustomHeaders.AddValue('SOAPAction', 'CUCM:DB ver=8.0');

It works!!!!!


Thank you!

Highlighted
Contributor

Re: How can I use AXL from Delphi program?

Hi,

Which Delphi version are you running? I've used Delphi's WSDLImporter to consume the CUCM WSDL to create classes for many years. That way you do not have to build the XML manually. There are some quirks in Delphi though, so I need to know which version you are using to help you properly.

Kind Regards,

//Dan

Highlighted
Beginner
Beginner

Re: How can I use AXL from Delphi program?

Hi,

I am also trying to access the cisco cucm AXL service from delphi but can’t get any results since days.

I am using Delphi 10 Seattle and CUCM Version 10.5.

I imported the cisco axl WDSL from the toolkit, put a THTTPRio component on the form and then called a service.

But it seems that delphi does not send the needed soap information…

I am just getting an error and the HTML text in the response I would get calling the url from the browser:

Exception: Documentelement http://schemas.xmlsoap.org/soap/envelope/:Envelope expected, :html found

Response:

<html><head><title>Cisco CallManager: AXL Web Service</title></head><body>

<h1>Cisco CallManager: AXL Web Service</h1>

<p>The AXL Web Service is working and accepting requests.

Use HTTP POST to send a request.</p></body></html>

Here is a code snipped of what I tried so far:

var

  strURL : string;

  objAXLService : AXLPort;

  objSQLQuery : executeSQLQuery;

  objSQLQueryResponse : executeSQLQueryResponse;

begin

  // initialize connection

  strURL := 'https://testserver.xyz.test:8443/axl';

  m_strUser := 'AXL-TEST';

  m_strPassword := 'password';

  oHTTPRio.HTTPWebNode.UserName := m_strUser;

  oHTTPRio.HTTPWebNode.Password := m_strPassword;

  oHTTPRio.HTTPWebNode.SoapAction := 'CUCM:DB ver=10.0';

  // get Service fom WDSL-Unit

  objAXLService := GetAXLPort(False, strURL, oHTTPRio);

  // create SQL query

  objSQLQuery := executeSQLQuery.Create;

  objSQLQuery.sql := 'select d.name, d.description, n.dnorpattern as DN, rp.name as partition' +

                     ' from device as d, numplan as n, devicenumplanmap as dnpm, routepartition as rp' +

                     ' where dnpm.fkdevice = d.pkid' +

                     ' and dnpm.fknumplan = n.pkid' +

                     ' and rp.pkid = n.fkroutepartition' +

                     ' and d.tkclass = 1';

  objSQLQueryResponse := objAXLService.executeSQLQuery(objSQLQuery);

///////////////////////////////

Has anybody getting this working and an idea what is missing?

Kind Regards

Highlighted
Cisco Employee

Re: How can I use AXL from Delphi program?

Haven't used Delphi in, lo, these many years...but the HTML message you are receiving seems to be the one AXL returns when an HTTP GET is received instead of an HTTP POST.  If you can force the request to use POST, might help...

Highlighted
Contributor

Re: How can I use AXL from Delphi program?

No, I get mocked a lot for using Delphi, but it is actually great as a swiss army knife for a non-programmer voice engineer :-) I can write various automation code for CUCM in minutes, often on-site when need for CUCM reconfiguration occurs. Much faster and better than Bulk Administration Tool and it's hidious Excel template.

Highlighted
Contributor

Re: How can I use AXL from Delphi program?

Hi,

It looks OK at first glance. I never specify SoapAction since that is automatically handled, but apart from that it looks like something I would write.

Try using URL 'https://testserver.xyz.test:8443/axl/', i.e add a "/" after "axl".

Kind Regards,

//Dan