09-06-2015 08:53 PM
Hi Guys i was trying a axl codes. but i got problem at SOAP.
I use CUCM 9.1 and my user and password are operator.
here's my codes
package axl;
import java.io.*;
import java.net.*;
import javax.net.ssl.*;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
public class asd {
public static void main(String[] args) {
byte[] bArray = null; // buffer for reading response from
Socket socket = null; // socket to AXL server
OutputStream out = null; // output stream to server
InputStream in = null; // input stream from server
String sAXLSOAPRequest = "";
// HTTPS header and SOAP payload
String sAXLRequest = null; // will hold only the SOAP payload
String authorization = "operator" + ":" + "operator";
authorization = new sun.misc.BASE64Encoder().encode(authorization.getBytes());
// Form the http header
sAXLSOAPRequest = "POST /axl/ HTTP/1.0\r\n";
sAXLSOAPRequest += "Host:192.168.10.11:8443\r\n";
sAXLSOAPRequest += "Authorization: Basic " + authorization + "\r\n";
sAXLSOAPRequest += "Accept: text/*\r\n";
sAXLSOAPRequest += "Content-type: text/xml\r\n";
sAXLSOAPRequest += "SOAPAction: \"CUCM:DB ver=9.1\"\r\n";
sAXLSOAPRequest += "Content-length: ";
// Build the SOAP payload
sAXLRequest = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" ";
sAXLRequest += "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">";
sAXLRequest += "<SOAP-ENV:Body> <axl:getPhone xmlns:axl=\"http://www.cisco.com/AXL/1.0\" ";
sAXLRequest += " xsi:schemaLocation=\"http://www.cisco.com/AXL/1.0 http://axl/schema/AXLSoap.xsd\" ";
sAXLRequest += "sequence=\"1234\"> <phoneName>SEP000000000001</phoneName>";
sAXLRequest += "</axl:getPhone> </SOAP-ENV:Body> </SOAP-ENV:Envelope>";
// finish the HTTPS Header
sAXLSOAPRequest += sAXLRequest.length();
sAXLSOAPRequest += "\r\n\r\n";
// now add the SOAP payload to the HTTPS header, which completes the AXL
// SOAP request
sAXLSOAPRequest += sAXLRequest;
try {
asd axl = new asd();
// Implement the certificate-related stuffs required for sending request via https
X509TrustManager xtm = axl.new MyTrustManager();
TrustManager[] mytm = { xtm };
SSLContext ctx = SSLContext.getInstance("SSL");
ctx.init(null, mytm, null);
SSLSocketFactory sslFact = (SSLSocketFactory) ctx.getSocketFactory();
socket = (SSLSocket) sslFact.createSocket("192.168.10.11", Integer.parseInt("8443"));
in = socket.getInputStream();
// send the request to the server
// read the response from the server
StringBuffer sb = new StringBuffer(2048);
bArray = new byte[2048];
int ch = 0;
int sum = 0;
out = socket.getOutputStream();
out.write(sAXLSOAPRequest.getBytes());
while ((ch = in.read(bArray)) != -1) {
sum += ch;
sb.append(new String(bArray, 0, ch));
}
socket.close();
// output the response to the standard output
System.out.println(sb.toString());
} catch (UnknownHostException e) {
System.err.println("Error connecting to host: " + e.getMessage());
return;
} catch (IOException ioe) {
System.err.println("Error sending/receiving from server: " + ioe.getMessage());
// close the socket
} catch (Exception ea) {
System.err.println("Unknown exception " + ea.getMessage());
return;
}
finally{
try {
if (socket != null)
socket.close();
} catch (Exception exc) {
exc.printStackTrace();
System.err.println("Error closing connection to server: "+ exc.getMessage());
}
}
}
public class MyTrustManager implements X509TrustManager {
MyTrustManager() {
// create/load keystore
}
public void checkClientTrusted(X509Certificate chain[], String authType)
throws CertificateException {
}
public void checkServerTrusted(X509Certificate chain[], String authType)
throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
}
}
and this is my error
HTTP/1.1 200 OK
Set-Cookie: JSESSIONIDSSO=D2F8AE81113632D88A0B602FAE6412F6; Path=/; Secure; HttpOnly
Set-Cookie: JSESSIONID=AFB227E5DB040C4B262C4817A11F7BC3; Path=/axl/; Secure; HttpOnly
Content-Length: 335
Date: Mon, 07 Sep 2015 03:29:28 GMT
Connection: close
Server:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>VersionMismatch</faultcode><faultstring>There is a mismatch between the namespace specified in the envelope and namespace expected</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
Solved! Go to Solution.
09-17-2015 10:36 AM
Below is the raw request generated by the soapUI tool, based on the 9.1 WSDL (I executed it against a v10.5 CUCM, which worked). The placement and URI of the AXL namespace is different from what you have above, also note that the <phoneName> element should <name> - your XML may be from a previous AXL version..?
POST https://ds-ucm105.cisco.com:8443/axl/ HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "CUCM:DB ver=9.1 getPhone"
Content-Length: 272
Host: ds-ucm105.cisco.com:8443
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Authorization: Basic QWRtaW5pc3RyYXRvcjpjaXNjb3BzZHQ=
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/9.1">
<soapenv:Header/>
<soapenv:Body>
<ns:getPhone>
<name>CSFDSTAUDT</name>
</ns:getPhone>
</soapenv:Body>
</soapenv:Envelope>
09-10-2015 08:43 AM
This part looks incorrect: xmlns:axl=\"http://www.cisco.com/AXL/1.0\"
Try something like this: xmlns:axl=\"http://www.cisco.com/AXL/API/9.0\"
09-13-2015 09:09 PM
i tried xmlns:axl=\"http://www.cisco.com/AXL/API/9.0\" but it's stil showing error
HTTP/1.1 200 OK
Set-Cookie: JSESSIONIDSSO=ACEB1D999CE7DAD65B07E4734A6F0ABC; Path=/; Secure; HttpOnly
Set-Cookie: JSESSIONID=C265282A59E628279346479717AC44C2; Path=/axl/; Secure; HttpOnly
Content-Length: 335
Date: Mon, 14 Sep 2015 04:11:41 GMT
Connection: close
Server:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>VersionMismatch</faultcode><faultstring>There is a mismatch between the namespace specified in the envelope and namespace expected</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
09-14-2015 12:37 PM
Can you post the exact XML request? You don't need to post any of the Java code, just the XML you are sending.
09-14-2015 07:47 PM
These are my xml codes
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body> <axl:GetPhoneRes.java xmlns:axl="http://www.cisco.com/AXL/9.0 xsi:SchemaLocation=\"http://www.cisco.com/AXL/9.0 http://192.168.10.11/Schema/AXLSoap.xsd sequence="4321"> <phoneName>SEP000000000001</phoneName>";
</axl:GetPhoneRes.java> </SOAP-ENV:Body> </SOAP-ENV:Envelope>";
09-16-2015 07:43 AM
The version in the namespace needs to match the version submitted in the 'SOAPAction:' header - looking at the above you have '9.0' vs. '9.1'...
09-17-2015 09:00 AM
Hi dstaudt
actually i am still not understand why i got error <faultcode>VersionMismatch</faultcode>
i think my code must be work .
i tried 9.0 and 9.1
but it'still same and got this error
Connection: close
Server:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>VersionMismatch</faultcode><faultstring>There is a mismatch between the namespace specified in the envelope and namespace expected</faultstring></SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
here's my codes
String sAXLRequest = null; // will hold only the SOAP payload
String authorization = "operator" + ":" + "operator";
authorization = new sun.misc.BASE64Encoder().encode(authorization.getBytes());
// Form the http header
sAXLSOAPRequest = "POST /axl/ HTTP/1.0\r\n";
sAXLSOAPRequest += "Host:192.168.10.11:8443\r\n";
sAXLSOAPRequest += "Authorization: Basic " + authorization + "\r\n";
sAXLSOAPRequest += "Accept: text/*\r\n";
sAXLSOAPRequest += "Content-type: text/xml\r\n";
sAXLSOAPRequest += "SOAPAction: \"CUCM:DB ver=9.1\"\r\n";
sAXLSOAPRequest += "Content-length: ";
// Build the SOAP payload
sAXLRequest = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" ";
sAXLRequest += "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">";
sAXLRequest += "<SOAP-ENV:Body> <axl:getPhone xmlns:axl=\"http://www.cisco.com/AXL/9.1\" ";
sAXLRequest += " xsi:schemaLocation=\"http://www.cisco.com/AXL/9.1 http://axl/schema/AXLSoap.xsd\" ";
sAXLRequest += "sequence=\"1234\"> <phoneName>SEP000000000001</phoneName>";
sAXLRequest += "</axl:getPhone> </SOAP-ENV:Body> </SOAP-ENV:Envelope>";
notes
#my cucm is cucm 9.1
09-17-2015 10:36 AM
Below is the raw request generated by the soapUI tool, based on the 9.1 WSDL (I executed it against a v10.5 CUCM, which worked). The placement and URI of the AXL namespace is different from what you have above, also note that the <phoneName> element should <name> - your XML may be from a previous AXL version..?
POST https://ds-ucm105.cisco.com:8443/axl/ HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "CUCM:DB ver=9.1 getPhone"
Content-Length: 272
Host: ds-ucm105.cisco.com:8443
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Authorization: Basic QWRtaW5pc3RyYXRvcjpjaXNjb3BzZHQ=
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/9.1">
<soapenv:Header/>
<soapenv:Body>
<ns:getPhone>
<name>CSFDSTAUDT</name>
</ns:getPhone>
</soapenv:Body>
</soapenv:Envelope>
09-18-2015 01:30 AM
Ty dstaudt
it's finally success.
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