12-12-2019 01:48 PM
The library I use is following:
http-client-4.5.10.jar httpcore-4.4.12.jar httpmime-4.5.10.jar
Here is my custom java code
package com.mycompany.cvp.webservice; import java.io.File; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import com.audium.server.AudiumException; import com.audium.server.action.context.ApplicationModifier; import com.audium.server.session.ActionElementData; public class ItspWebServiceClient extends ApplicationModifier { @Override public String getElementName() { return "RestWebServiceClient"; } @Override public String getDisplayFolderName() { return "My Company Elements"; } @Override public void doAction(String name, ActionElementData actionData) throws AudiumException { String urlLink = (String)actionData.getSessionData("SpeechURL"); String filePath = actionData.getElementData("PolicyNumber", "filepath"); String filename = actionData.getElementData("PolicyNumber", "filename"); CloseableHttpClient client = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(urlLink + "/processFile"); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addBinaryBody("file", new File(filePath), ContentType.APPLICATION_OCTET_STREAM, filename); HttpEntity multipart = builder.build(); httpPost.setEntity(multipart); CloseableHttpResponse response; try { response = client.execute(httpPost); HttpEntity responseEntity = response.getEntity(); String result = EntityUtils.toString(responseEntity); actionData.addToLog("SpeechRecognition", result); client.close(); actionData.setSessionData("return", result); } catch (Exception e) { throw new AudiumException("Speech Recogniation exception"); } super.doAction(name, actionData); } }
The above code is taking the audio files and call the web service to recognize what user said, and based on the string that return back to perform following action.
However, when I deploy the whole project to VXMLServer, it complains following:
Error with admin application update,12/12/2019 16:27:58.085,An error has occurred. The error was: java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpUriRequest java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpUriRequest at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493) at java.lang.Class.getConstructor0(Class.java:2803) at java.lang.Class.newInstance(Class.java:345) at com.audium.server.controller.AudiumServerConfiguration.instantiateLocalElements(AudiumServerConfiguration.java:441) at com.audium.server.controller.AudiumServerConfiguration.<init>(AudiumServerConfiguration.java:216) at com.audium.server.controller.AudiumServerConfiguration.initialize(AudiumServerConfiguration.java:1049) at com.audium.server.controller.Admin.cmdUpdateApp(Admin.java:326) at com.audium.server.controller.Admin.executeCommand(Admin.java:244) at com.audium.server.controller.Admin.run(Admin.java:1520) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.ClassNotFoundException: org.apache.http.client.methods.HttpUriRequest at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 11 more
In server side I already put all the jar file into common folder, what else I need to do?
Solved! Go to Solution.
12-13-2019 09:17 AM
What I do:
12-13-2019 09:17 AM
What I do:
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide