02-08-2018 06:59 AM
Hello ,
I am new to cisco AXL. I am trying to execute AXL with java. Where it connects to AXL web service and pulls information from the CUCM database. The con.call(requestMessage,getURLEndpoint()) is returning null and throwing errors. using cucm 11.5.Can anyone help me to get this working. Thanks
Java Code
public SOAPMessage sendMessage(SOAPMessage requestMessage) throws Exception {
SOAPMessage reply = null;
try {
System.out.println("URL" + getUrlEndpoint());
reply = con.call(requestMessage, getUrlEndpoint());
System.out.println("After getting URL");
if (reply != null) {
System.out.println("Inside if");
SOAPPart replySP = reply.getSOAPPart();
SOAPEnvelope replySE = replySP.getEnvelope();
SOAPBody replySB = replySE.getBody();
if (replySB.hasFault()) System.out.println("ERROR: " + replySB.getFault().getFaultString());
String a = convertSOAPtoString(reply);
a=a.replaceAll("<row>","").replaceAll("</output>","").replaceAll("<output>","").replaceAll("</return>.*","").replaceAll(".*<return>","");
String[] split=a.split("</row>");
for(String e : split){
System.out.println(e);
if(e.toLowerCase().contains("broderick")) continue;
String[] input = e.split(",",-1);
System.out.println(input.length);
LogSQL.insertLog(input[0],input[1],input[2],input[3]);
}
}
}
catch (Exception e) {
System.out.println("return started here" + reply);
System.out.println(e);
e.printStackTrace();
throw e;
}
return reply;
}
In the above code con.call is returning null. I checked the web service URL from other browser it is working. Below are the errors:
Feb 08, 2018 9:26:01 AM com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection post
SEVERE: SAAJ0008: Bad Response; null
return started herenull
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (599null
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (599null
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:149)
at PhoneLocator.sendMessage(PhoneLocator.java:109)
at PhoneLocator.init(PhoneLocator.java:63)
at PhoneLocator.main(PhoneLocator.java:40)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (599null
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:264)
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:145)
... 3 more
CAUSE:
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (599null
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:264)
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:145)
at PhoneLocator.sendMessage(PhoneLocator.java:109)
at PhoneLocator.init(PhoneLocator.java:63)
at PhoneLocator.main(PhoneLocator.java:40)
CAUSE:
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (599null
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:264)
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:145)
at PhoneLocator.sendMessage(PhoneLocator.java:109)
at PhoneLocator.init(PhoneLocator.java:63)
at PhoneLocator.main(PhoneLocator.java:40)
Problem starts here
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (599null
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (599null
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:149)
at PhoneLocator.sendMessage(PhoneLocator.java:109)
at PhoneLocator.init(PhoneLocator.java:63)
at PhoneLocator.main(PhoneLocator.java:40)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (599null
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:264)
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:145)
... 3 more
CAUSE:
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (599null
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:264)
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:145)
at PhoneLocator.sendMessage(PhoneLocator.java:109)
at PhoneLocator.init(PhoneLocator.java:63)
at PhoneLocator.main(PhoneLocator.java:40)
CAUSE:
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (599null
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:264)
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:145)
02-12-2018 07:58 AM
Don't have any Java examples using that particular library - if you provide a complete sample project that demonstrates the issue that may help.
Here is a sample using just java.io and java.net that should at least show the needed HTTP info (URL, headers, etc.)
import java.io.*;
import java.net.*;
public class AXLSample {
public static void main(String[] args) throws Exception {
//AXL service URL on UC Manager host ds-ucm851.cisco.com
//Note this sample assumes the certificate for the host with subject
//name 'ds-ucm851.cisco.com' has been imported into the Java keystore
URL url = new URL("https://ds-ucm851.cisco.com:8443/axl/");
//Create a java.net URLConnection object to make the HTTP request
URLConnection conn = url.openConnection();
//setDoOutput=true causes the URLConnection to perform a POST operation
conn.setDoOutput(true);
//HTTP Basic authorization string - a base64 encoded string with username:password, in this case 'Administrator:cisco!123'
//This should be a UCM application user with Standard CCM Admin User and Standard AXL API Access roles
String authorization = "QWRtaW5pc3RyYXRvcjpjaXNjbyExMjM=";
conn.setRequestProperty("Authorization","Basic " + authorization);
//Set the SOAPAction header to 'CUCM:DB ver=8.5' for use with a UCM 8.5(1) host, request is 'getPhone'
conn.setRequestProperty("SOAPAction","\"CUCM:DB ver=8.5 getPhone\"");
//The request body will be in XML format
conn.setRequestProperty("Content-Type","text/xml");
//Build a string containing the contents of the AXL XML request - here 'getPhone'
String AXLRequest = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://www.cisco.com/AXL/API/8.5\">";
AXLRequest += "<soapenv:Body><ns:getPhone><name>SEP001B0CDBBE33</name></ns:getPhone></SOAP-ENV:Envelope>";
//Create an OutputStreamWriter for the URLConnection object and make the request
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
writer.write(AXLRequest);
writer.flush();
//Read the response
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
//Output the response to the console
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
//Cleanup the stream objects
writer.close();
reader.close();
}
}
03-01-2018 07:48 AM
Thanks for the reply. The error in my case was due to header property, it was checking for the database version and that version didn't exist. Corrected the version and it worked.
03-16-2018 12:06 PM
What DB version did you use. I am getting the same errors
03-16-2018 12:14 PM
I added a header in my code, which is looking for 11.5 version but i think it had 9.5 version. So I removed the header in my code, that way it goes and picks the available version.
Another way to debug, first check if the web service is working, not from java code. I was working on Linux ,in my case i used Curl to check that. execute it and see if it is bringing the result.
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