cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5398
Views
16
Helpful
30
Replies

Create Cutsom Java class that calls Rest Service in Cisco call studio

Hello,

I am new on cisco call studio. I want to create one java custom code that calls rest service and  want to use this code in cisco call studio application.Please let me know the steps for creating above scenerio. If you guys have some sample example or document it will be great

Thanks

30 Replies 30

Hello, Thanks for reply.

I have compile my java class  and put .class file under /deploy /java/application /classes. After that I restart my Call studio, but  I am not able to see my element under Elements / Local Elements.When I double click the .class file under /deploy /java/application /classes, it give me below error:


org.eclipse.core.runtime.CoreException: The class file is not on the classpath

at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.doSetInput(ClassFileEditor.java:664)

at org.eclipse.ui.texteditor.AbstractTextEditor$19.run(AbstractTextEditor.java:3200)

at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)

at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)

at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:759)

at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)

at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:756)

at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2649)

at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3218)

at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3245)

at org.eclipse.ui.internal.EditorManager.createSite(EditorManager.java:828)

at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:647)

at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)

at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)

at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)

at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)

at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)

at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)

at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)

at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1245)

at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1198)

at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1597)

at org.eclipse.ui.internal.PartStack.add(PartStack.java:493)

at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103)

at org.eclipse.ui.internal.PartStack.add(PartStack.java:479)

at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112)

at org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)

at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:225)

at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:213)

at org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:808)

at org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:707)

at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:666)

at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2942)

at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2850)

at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2842)

at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2793)

at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)

at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2789)

at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2773)

at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2764)

at org.eclipse.ui.ide.IDE.openEditor(IDE.java:651)

at org.eclipse.ui.ide.IDE.openEditor(IDE.java:610)

at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:355)

at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:164)

at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:249)

at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:228)

at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:275)

at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:251)

at org.eclipse.jdt.internal.ui.navigator.OpenAndExpand.run(OpenAndExpand.java:50)

at org.eclipse.ui.actions.RetargetAction.run(RetargetAction.java:221)

at org.eclipse.ui.navigator.CommonNavigatorManager$3.open(CommonNavigatorManager.java:185)

at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(OpenAndLinkWithEditorHelper.java:48)

at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:866)

at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)

at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)

at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)

at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:864)

at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1152)

at org.eclipse.ui.navigator.CommonViewer.handleOpen(CommonViewer.java:462)

at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(StructuredViewer.java:1256)

at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:275)

at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:269)

at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:309)

at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)

at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)

at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)

at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)

at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)

at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)

at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)

at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)

at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)

at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)

at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)

at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)

at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)

at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)

at org.eclipse.equinox.launcher.Main.run(Main.java:1410)

at org.eclipse.equinox.launcher.Main.main(Main.java:1386)

I am using Call Studio version 10.5

and Java for compiling 1.7.0_80.

Please suggest me on this.

Thanks

The Element will show up only when you're looking at that call studio app in the workspace. And it should display under Local Elements.

If not, look at Window / Show View / Call Studio Error log to see what studio doesn't like.

Sent from my Verizon 4G LTE smartphone

I am looking at that call studio app in the workspace only.And it is not showing there.

You may need to copy that same missing file jargon file into Eclipse/ com.audium.callstudio.library.common/lib and restart studio.

Sent from my Verizon 4G LTE smartphone

You may need to copy that same missing jar file into Eclipse/ com.audium.callstudio.library.common/lib and restart studio.

Sent from my Verizon 4G LTE smartphone

In studio, go to Window / Show View / Call Studio Error log...

It'll display at bottom of studio and tell you why studio won't display your element.

Sent from my Verizon 4G LTE smartphone

I checked the logs on ' Window / Show View / Call Studio', I found below error in the Call Studio Error log

An error was encountered while attempting to load the element "com.audium.server.controller.HttpDecisionElement". The exception was: java.lang.IllegalAccessException: Class com.audiumcorp.studio.builder.core.plugins.ElementsPlugin can not access a member of class com.audium.server.controller.HttpDecisionElement with modifiers "private"

Thanks

Can you post your java code? Is it a decision element?

Sent from my Verizon 4G LTE smartphone

Yes it is decision element. Below is the code;


package com.dec;


import com.audium.server.voiceElement.DecisionElementBase;

import com.audium.server.voiceElement.ElementInterface;

import com.audium.server.voiceElement.Setting;

import com.audium.server.voiceElement.ElementData;

import com.audium.server.voiceElement.ExitState;

import com.audium.server.voiceElement.ElementException;

import com.audium.server.session.DecisionElementData;

import com.audium.server.xml.DecisionElementConfig;


/**

This decision element compares 2 numbers and returns 'true' (or

'false') if the comparison is true (or false).

It returns 'error' if one of the input parameters can't be converted

to a number.

**/

public class NumberComparisonElement extends DecisionElementBase implements ElementInterface

{

/**

This is the name of the decision element which appears in Studio.

*/

public String getElementName()

{

return "NumberCompare";

}

/** Folder name containing the decision element in Studio **/

public String getDisplayFolderName()

{

return "Janines Number Elements";

}

/** Description of the decision element in Studio **/


public String getDescription()

{

return "Compare 2 numbers. " +

"Exit down the error path if they can't be compared. ";

}

/** The Settings for the decision element in Studio **/

public Setting[] getSettings() throws ElementException

{

Setting[] settingArray = new Setting[3];

/**Each setting array element must specify:

real name, display name, description,

required?, occurs only once?, substitution allowed?, setting type

**/

settingArray[0] = new Setting("num1", "First Number","This is the first number in the comparison.", true, // It is required

true, // It appears only once

true, // It does allow substitution

Setting.FLOAT);

settingArray[1] = new Setting("op", "Comparison Operator","This is the comparison.",

true, // It is required

true, // It appears only once

false, // It does NOT allow substitution

new String[] {"<","<=", ">", ">=", "==", "!="} );

settingArray[2] = new Setting("num2", "Second Number",

"This is the second number in the comparison.",

true, // It is required

true, // It appears only once

true, // It does allow substitution

Setting.FLOAT);

return settingArray;

}


/**

This method returns an array of ExitState objects representing all the

possible exit states the decision element can return. Here, the exit

states

reflect the three possible states of the day, morning, afternoon, and

evening.

*/

public ExitState[] getExitStates() throws ElementException

{

ExitState[] exitStateArray = new ExitState[3];

exitStateArray[0] = new ExitState("true", "true","");

exitStateArray[1] = new ExitState("false", "false","");

exitStateArray[2] = new ExitState("error", "error","");

return exitStateArray;

}


/**

This method returns an array of ElementData objects representing the

element data that this decision element creates.

If no element data created, return null

*/

public ElementData[] getElementData() throws ElementException

{

//ElementData[] elementDataArray = new ElementData[1];

//elementDataArray[0] = new ElementData("result", "The result of the decision");

return null;

}

/** This is the runtime code executed by VXML Server **/

public String doDecision(String name, DecisionElementData decisionData) throws ElementException

{

// Get the configuration

DecisionElementConfig config = decisionData.getDecisionElementConfig();


try {

//Get each setting from the config, using the setting's 'real name'

//as defined in the getSettings method above


float num1 = Float.valueOf(config.getSettingValue("num1",

decisionData)).floatValue();

String op = config.getSettingValue("op", decisionData);

float num2 = Float.parseFloat(config.getSettingValue("num2", decisionData));


//return the string 'true' or 'false'

//if(op.equals("<"true"; else return "false"; }

if(op.equals("<=")){ if(num1 <= num2) return "true"; else return "false"; }

if(op.equals(">")){ if(num1 > num2) return "true"; else return "false"; }

if(op.equals(">=")){ if(num1 >= num2) return "true"; else return "false"; }

if(op.equals("==")){ if(num1 == num2) return "true"; else return "false"; }

if(op.equals("!=")){ if(num1 != num2) return "true"; else return "false"; }


} catch (RuntimeException e) {

//If we couldn't retrieve the settings and turn the numbers into float's then

//print a stack trace in the error log and return down the 'error' exit state

e.printStackTrace();

return "error";

}//if the operation didn't equal any of those listed above, return 'error'

return "error";

}

}

Thanks

I don't see anything about rest in that example.

Sent from my Verizon 4G LTE smartphone

So if you add the class file for the Element you post into the studio app deploy / java / application / classes folder and then close /reopen the app, you don't see the element under Local Elements?

Sent from my Verizon 4G LTE smartphone

Hi Janine,


I have successfully run my rest service example. Now I want to use .class file in cisco call studio.For this,
I have created One sample application which Compare two number using Decision element. I have put my class file under deploy / java / application / classes folder then close /reopen the app, but  I am not able to see element under Local Elements.

Where I need to include the package directory structure in call studio?

Thanks for your help Janine.

remove the class file from I have put my class file under deploy / java / application / classes

And instead make it look like this:

I have put my class file under

appname/deploy / java / application / classes /com/dec/NumberComparisonElement

By the way, just re reading your earlier post, you can't double click a compiled class file and view it.

Sent from my Verizon 4G LTE smartphone

By the way, when you copy your class file into the studio app you must include the package directory structure. So you need appname / deploy /java /application /classes /com/dec/NumberComparisonElement.class

Sent from my Verizon 4G LTE smartphone