Extentrix Developer Network-Extentrix Web Services for Citrix Presentation Server
Extentrix Web Services Consumer using JavaScript
Introduction
Requirements
Application Source Code
How to Call Extentrix Web Services for Citrix Presentation Server API using JavaScript
Introduction
This sample shows how to invoke Extentrix Web Services for Citrix Presentation Server APIs using JavaScript. It invokes one of the APIs (launchApplicationWithParameter).
Requirements
- Any web browser.
- Security Requirements:
Enable Initialize and script ActiveX controls option. For Internet Explorer do the following:
A) From Internet Explorer, go to Tools >> Internet Options.
.png)
Figure 1
B) Select Security tab, go to Custom level.
.jpg)
Figure 2
C) Enable "Initialize and script ActiveX controls not marked as safe for scripting" option.

Figure 3
This is not an ASP.Net tutorial, so it will only briefly describe what the code does. We assumed the person who is reading this has a good knowledge of it.
Application Source Code
There are two main packages:
- JavaScript_Sample.htm
This page is the main page in this sample; it contains a link to the Administrator’s Guide file in a .pdf format.
It does the following:
(A) Firstly, it checks if the Acrobat Reader is installed on the client’s machine. If it is installed, then the Administrator’s Guide file will be opened using the installed Acrobat Reader on the client’s machine.
(B) If the Acrobat Reader does not exist, then we will connect to our Extentrix web services using JavaScript to use the Acrobat Reader published application on Citrix presentation server using ICA client.
webservice.htc
It is a JavaScript file that should be enabled in order to be able to connect with the web service.
How to Call Extentrix Web Services for Citrix Presentation Server API using JavaScript
- You need to enable connecting with the web service from any control using this property.
style="behavior:url(webservice.htc);"
- Create connection to Extentrix web services and name it as Service1.
- Create Credential class.
function Credentials(UserName,Password,Domain,Type,Method) { this.UserName=UserName; this.Password=Password; this.Domain=Domain; this.DomainType=Type; this.PasswordEncryptionMethod=Method; }
- Create Credential object, and set its members.
myusername = "citrixdesktop"; mypassword = "demo"; mydomain = "testdrive"; mytype = 0; mymethod = 0;
var credentials = new Credentials(myusername,mypassword,mydomain,mytype,mymethod);
- Invoke launchApplicationWithParameter API.
var iCallID = service.Service1.callService("LaunchApplicationWithParameter", application, filename,credentials, clientname, clientIP);
- Receiving API results using this property in the enabling control.
onresult="onmyresult()";
onmyresult function recieves the ica file content.
icaContent = event.result.value;
save it to a file on the client’s machine
array = icaContent.split('\n'); var Fs = new ActiveXObject("Scripting.FileSystemObject"); var Output = Fs.OpenTextFile(fileName,2,true); var content = array[0] + "\n"; for (i = 1; i < array.length; i++) { content += array[i] + "\n"; } Output.write(content); Output.close();
and run it using ICA client.
url = "file:///" +fileName; WSH=new ActiveXObject("WScript.Shell"); WSH.run(url);
service.useService("http://www.extentrix.com/webservices/1.0.0/ExtentrixWebServicesForCPS.asmx?WSDL","Service1");
// where service is the enabling control in the previous step