cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3585
Views
10
Helpful
13
Replies

How uccx can access custom java class

Hi,

I have uploaded a custom java class "jar file" to my document on the ipcc admin page

Then select it then reset the crs engine

On the script editor

Using SET step ,I modify the name of the object to the class name "testclass"

Then I successfuly find the method included in my class which named as "testmethod"

But the problem is that I don't know what to write in the expression editor to send the request to this method and get a response from it

This test is to send any string and to get 2000 "for test"

So, Do you see that I'm using the right path by using SET step

or please advise what can I do to send a variable and get a response from this java class

thanks

1 Accepted Solution

Accepted Solutions

Two things I see right off the bat:

  1. In your variable pane, you object variable should be of type TestClass, not Object.
  2. I'm surprised your Set step works, as it's not returning anything, which is a requirement of the Set step.  Anyway, you wont need this because you are going to instantiate your object from your class in the variable pane, when you fix #1.  In the future if you want to execute a step like that, and you don't plan on returning anything, use the Do step instead.

View solution in original post

13 Replies 13

I have found the testmethod name when replacing the object word with the class name

Now the method appear as:

String ?.testmethod(String)

the first string word mean that this exp will give a string

but i don't know what ? or the second string mean

Only i need to send this class a string and it'll respond with a string 2000

So please help in how to send the string and where to get the response ?

I have tried the following:

SET X = testclass.testmethod('Y')   : X the response , and Y is the input to the class BUT IT DIDN't WORK

SET X = testmethod('Y')    DIDN'T WORK

SET X = Y.testmethod()    DIDN't WORK

So please help in this how to send a string and to get back a response

thanks

Anthony Holloway
Cisco Employee
Cisco Employee

The first String is what gets returned; a String.

The ? represents an object of your class. E.g., if my class is TestClass then an object of my class would be created like so: TestClass testObject = new TestClass;

The .testmethod() is the method your class exposes publicly for you to call. Also called an instance method. It's called like this: testObject.testmethod().

The last String, inside of your method's parenthesis, is the type of input required: a String. So this would be valid: testObject.testmethod("hello"), and this would be invalid: testObject.testmethod(45)

Does that help?

Sent from Cisco Technical Support iPhone App

Hi Anthony,

thanks a lot for your kind reply

Will test and feed you back

Best Regards

Haitham

Hi Anthony,

I have tried with a java file that get an integer and respond with integer

When I make this command:

Testjava.testIntMethod(x)

I got that error

Exception,, not a static method: testIntMethod

so i searched google of how to call non static method and found that I need to create an instance of the class; then I can use that to call non-static methods that non static methods and fields are always instance members while static methods / static fields are always class members.

So can you help me how to call this non-static method or by other means how to have an instance to call on

Thanks & Best Regards

Haitham

If you have a static method, this is how you call it:

TestClass.staticMethod();

If you have an instance method, this is how you call it:

TestClass testObject = new TestClass();

testObject.instanceMethod();

The difference being, in the static method example, you do not need to create an object of your class, and in the instance example you do.

Which way you choose is up to you, and how you plan on using your TestClass.

NOTE:  In UCCX editor, to have an object in the global scope, meaning it can be referenced in any step in the script, create it in the variable pane first.

Have a look at this project I did, using custom Java classes in UCCX 5:

http://dl.dropbox.com/u/15705/www.avholloway.com-soap-project-offline.zip

Hi Anthony,

Thanks for your reply

I know that I should use an object to call the non-static method

I found on java sites something like the code you sent

But what is confusing me

Is how to write it in the expression editor of the CRS

Will I write it as java or need a special language ?

So as in the case below

I'll create a variable type object and its value will be as : TestClass testObject = new TestClass()

then using SET step to get the response on an integer X using this exp. : testObject.instanceMethod()

or using SET step and have all these in the expression editor:

{TestClass testObject = new TestClass();
testObject.instanceMethod();}

I have tried this, and a lot of other methods but always failed

Only I need to know how to use it with the expression editor, also if there is any doc help for the expression editor language guide,, that the scripting VOL3 doc on cisco was samples only with no codes help

Thanks a lot for your continous help

Best Regards

Your examples look correct.

Can you post a screen shot of your script editor steps and variables, and your error message or incorrect results.

Paste your java code here also.

Sent from Cisco Technical Support iPhone App

Hi Anthony,

Kindly find the attached java and error files

I'm trying with testIntMethod() method which return an integer value of 2000

I need to know if I should use pure java language in the expression editor or it is a special language ?

thanks a lot for your help

Best Regards

Haitham

Two things I see right off the bat:

  1. In your variable pane, you object variable should be of type TestClass, not Object.
  2. I'm surprised your Set step works, as it's not returning anything, which is a requirement of the Set step.  Anyway, you wont need this because you are going to instantiate your object from your class in the variable pane, when you fix #1.  In the future if you want to execute a step like that, and you don't plan on returning anything, use the Do step instead.

Hi Anthony,

Thanks alot for your help

Best Regards

Haitham

So, it's working?

yes i can receive a response now

Hi Anthony

I have problem same his.

I want upload custom java va class in to system. I do step by step.
Step 1: Complie java file to class file: javac SBDUtils.java
Step 2 : Build jar file: jar cf SBDUtils.jar SBDUtils.class
Step 3 : Upload jar file to menu Applications/Document Manager/default/classpath
Step 4: into tab System/Custom file configuration I move jar file from Available class path to Selected class path and click update
Step 5: Restart service UCCX Engine and UCCX Administration
Step 6: Restart CCX editor
I create new aef file, create new variable but I can not look type SBDUtils in combobox Variable type. But I look at variable type below
Please help me.
I use uccx 11.5 and jdk version 1.7.0_79. But Datasheet suggest 1.7.0_101
Untitled.png