I am using cisco axl webservice to pull data from their database. The web service works fine when I execute it with curl. When I execute in Java, SOAP connection is returning null. I set up the TCP/IP monitor to view the data and it is printing garbage values(both request and response).
public SOAPMessage createSqlMessage(String cmdName, String sql) throws
Exception {
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage soapMessage = mf.createMessage();
MimeHeaders mh = soapMessage.getMimeHeaders();
mh.addHeader("SOAPAction", "CUCM:DB ver=11.5");
SOAPEnvelope envelope = soapMessage.getSOAPPart().getEnvelope();
SOAPBody bdy = envelope.getBody();
envelope.addNamespaceDeclaration("ns", "http://www.cisco.com/AXL/API/11.5");
SOAPBodyElement bodyElement = bdy.addBodyElement(envelope.createName(cmdName));
bodyElement.setPrefix("ns");
bodyElement.addAttribute(envelope.createName("sequence"),
String.valueOf(System.currentTimeMillis()));
bodyElement.addChildElement("sql").addTextNode(sql);
System.out.println("In createSqlMEssage");
return soapMessage;
}
public String getUrlEndpoint() {
return new String("https://" + "appUser1" + ":" + password + "@" + "localhost" + ":" + "9443" + "/axl/");
}
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;
}
Can anyone help me?