cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1169
Views
25
Helpful
6
Replies

AXLToolKit - Bad Response - permissions?

verastar
Level 1
Level 1

I have recently found this tool and plan to use it to generate reports on the success of UI Automation.  I am however unable to connect.  There seems to be an issue with my login but I have rights in the front end.  Do I need different permissions to run this?

 

The script i'm using:

 

java -cp .\classes;.\lib\saaj-api.jar;.\lib\saaj-impl.jar;.\lib\mail.jar;.\lib\activation.jar;.\lib\jaxm-api.jar;.\lib\jaxm-runtime.jar;.\lib\xercesImpl.jar;.\lib\xml-apis.jar AxlSqlToolkit -username=MYCUCfrontendMLOGION -password=MYCUCMfrontPASSWORD -host=REDACTED

 

The return:

 

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/12.5"><SOAP-ENV:Header/><SOAP-ENV:Body><ns:executeSQLQuery sequence="1619192521581"><sql>select * from callmanager</sql></ns:executeSQLQuery></SOAP-ENV:Body></SOAP-ENV:Envelope>
---------------------
Apr 23, 2021 4:42:02 PM com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection post
SEVERE: SAAJ0008: Bad Response; Unauthorized
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (401Unauthorized
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
at AxlSqlToolkit.sendMessage(AxlSqlToolkit.java:150)
at AxlSqlToolkit.execute(AxlSqlToolkit.java:211)
at AxlSqlToolkit.main(AxlSqlToolkit.java:256)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (401Unauthorized
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
... 4 more

CAUSE:

com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (401Unauthorized
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
at AxlSqlToolkit.sendMessage(AxlSqlToolkit.java:150)
at AxlSqlToolkit.execute(AxlSqlToolkit.java:211)
at AxlSqlToolkit.main(AxlSqlToolkit.java:256)

CAUSE:

com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (401Unauthorized
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
at AxlSqlToolkit.sendMessage(AxlSqlToolkit.java:150)
at AxlSqlToolkit.execute(AxlSqlToolkit.java:211)
at AxlSqlToolkit.main(AxlSqlToolkit.java:256)
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (401Unauthorized
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
at AxlSqlToolkit.sendMessage(AxlSqlToolkit.java:150)
at AxlSqlToolkit.execute(AxlSqlToolkit.java:211)
at AxlSqlToolkit.main(AxlSqlToolkit.java:256)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (401Unauthorized
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
... 4 more

CAUSE:

com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (401Unauthorized
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
at AxlSqlToolkit.sendMessage(AxlSqlToolkit.java:150)
at AxlSqlToolkit.execute(AxlSqlToolkit.java:211)
at AxlSqlToolkit.main(AxlSqlToolkit.java:256)

CAUSE:

com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (401Unauthorized
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
at AxlSqlToolkit.sendMessage(AxlSqlToolkit.java:150)
at AxlSqlToolkit.execute(AxlSqlToolkit.java:211)
at AxlSqlToolkit.main(AxlSqlToolkit.java:256)

c:\axlcisco\axlsqltoolkit>

1 Accepted Solution

Accepted Solutions

dstaudt
Cisco Employee
Cisco Employee

The 401 response does seem to indicate the credentials/permissions are the issue.  Testing the toolkit sample just now it seems to work for me.

If the credentials are you usual 'full admin' set, then those should work - not sure what might be going on.  If not, check here to see if the correct role is assigned: https://developer.cisco.com/docs/axl/#!authentication/using-basic-authentication

View solution in original post

6 Replies 6

npetrele
Cisco Employee
Cisco Employee

I think you need to include a BASIC AUTH header, which is the base64 encoding of an application user's username and password (assuming the application user belongs to the right groups).

 

However, I have to ask, are you planning to build a Java application based on converting the WSDL to Java classes?  I don't recommend that at all. It's very difficult to use and prone to be slow and buggy.

 

It's much easier, if you need to use Java, to pass SOAP requests, etc. I think that's what you're already doing, but I just wanted to make sure.

 

npetrele
Cisco Employee
Cisco Employee

Here are samples I pulled from the web. Two are REST operations, but this should give you the basic idea that it's an http header thing.

 

public class TestClient {
 
    public static void main(String[] args) throws MalformedURLException {
        URL url = new URL("http://localhost:9993/ws/hello?wsdl");
        QName qname = new QName("http://authentication.jaxws.com/", "HelloWorldImplService");
  
        Service service = Service.create(url, qname);
        HelloWorldImpl hello = service.getPort(HelloWorldImpl.class);
        Map<String, Object> req_ctx =((BindingProvider)hello).getRequestContext();
        req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:9993/ws/hello?wsdl");
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        headers.put("Username",Collections.singletonList("Username"));
        headers.put("Password", Collections.singletonList("Password"));
        req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
        System.out.println(hello.sayHello("username"));
    }
     
}

 

String encoding = Base64Encoder.encode(user + ":" + pwd);
HttpPost httpPost = new HttpPost("http://host:post/test/login");
httpPost.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + encoding);

System.out.println("executing request " + httpPost.getRequestLine());
HttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Base64;


public class HttpBasicAuth {

    public static void main(String[] args) {

        try {
            URL url = new URL ("http://ip:port/login");
            String encoding = Base64.getEncoder().encodeToString(("test1:test1").getBytes(‌"UTF‌​-8"​));

            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setDoOutput(true);
            connection.setRequestProperty  ("Authorization", "Basic " + encoding);
            InputStream content = (InputStream)connection.getInputStream();
            BufferedReader in   = 
                new BufferedReader (new InputStreamReader (content));
            String line;
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
        } catch(Exception e) {
            e.printStackTrace();
        }

    }

}

Thank you.

dstaudt
Cisco Employee
Cisco Employee

The 401 response does seem to indicate the credentials/permissions are the issue.  Testing the toolkit sample just now it seems to work for me.

If the credentials are you usual 'full admin' set, then those should work - not sure what might be going on.  If not, check here to see if the correct role is assigned: https://developer.cisco.com/docs/axl/#!authentication/using-basic-authentication

Thank you.   That's done it - The AXL permissions on my service account weren't set.

 

Is there a resource that lists all the tables/view in the schema?  So that I can form my queries without trial and error.

For record, I've now foudn the Table list here : 14 CUCM Data Dictionary - AXL - Document - Cisco DevNet

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: