0

Automate AU request by raw http requests

asked 2016-01-03 17:48:46 +0800

Virticchio gravatar image Virticchio
1

Hi, I'm trying to made AU request requests against zkau service. Particularly I need to access some data using direct HTTP requests made by an android app without human interaction by a browser. Every time I send a command I receive this message "Illegal request: cmd required". My request contain all required cookies and post data has the correct dtid.

For example, sending a simple dummy command with http post data run into this issue:

cmd_0=dummy&dtid=z_8490&opt_0=1

Moreover http header contains ZK-SID but I select a random value because I don't understand how and where platform assign it (at least looking at http protocol analyzer results).

What's missing?

Thanks, Pino!

delete flag offensive retag edit

4 Answers

Sort by ยป oldest newest most voted
0

answered 2016-01-04 08:48:44 +0800

Darksu gravatar image Darksu
1991 1 4

Hello Virticchio,

Have you considered exposing the data you want to retrieve as a web service?

This way you would avoid using zk as an intermediate and access the data directly.

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2016-01-04 17:15:07 +0800

Virticchio gravatar image Virticchio
1

updated 2016-01-04 17:22:36 +0800

Hi Darksu, unfortunately I can't access web application because it's coded by our IT department and now there's no effort to implement changes to the application. The only way a small developer can do is getting by presentation layer directly.

link publish delete flag offensive edit
0

answered 2016-01-04 19:41:12 +0800

Darksu gravatar image Darksu
1991 1 4

Hello Virticchio,

Got it, another alternative would be to use unit testing automation with tools like Selenium.

But in this case the components should have a unique id so that you can create the automation scripts.

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2016-01-05 18:27:11 +0800

Virticchio gravatar image Virticchio
1

Hello, I'm continuing to experiment and I can say that I'm on the right track. I downloaded zk framework's source code looking for the method that rise the error Illegal request: cmd required.

This error is thrown in this method

DHtmlUpdateServlet.process

when parsing command

//parse commands
        final Configuration config = wapp.getConfiguration();
        final List<AuRequest> aureqs;
        boolean keepAlive = false;
        try {
            final boolean timerKeepAlive = config.isTimerKeepAlive();
            aureqs = audec.decode(request, desktop);
            for (AuRequest aureq: aureqs) {
                final String cmdId = aureq.getCommand();
                keepAlive = !(!timerKeepAlive && Events.ON_TIMER.equals(cmdId))
                    && !"dummy".equals(cmdId);
                    //dummy is used for PollingServerPush for piggyback
                if (keepAlive)
                    break; //done
            }
        } catch (Throwable ex) {
            log.warn("", ex);
            responseError(request, response, Exceptions.getMessage(ex));
            return;
        }

        if (aureqs.isEmpty()) {
            final String errmsg = "Illegal request: cmd required";
            log.debug(errmsg);
            responseError(request, response, errmsg);
            return;
        }

Shortly, when AUDecoder returns an empty AuRequest list, error is thrown.

List<AuRequest> aureqs = audec.decode(request, desktop);
if (aureqs.isEmpty())
final String errmsg = "Illegal request: cmd required";

What I can't understand is what command is missing. My http request contains all data:

  • POST data with dummy command: cmd0=dummy&dtid=z8490&opt_0=1
  • All cookies

My doubt is about http header ZK-SID but looking source code doesn't seem to be determinant.

Any ideas?

Thanks, Virticchio

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2016-01-03 17:48:46 +0800

Seen: 18 times

Last updated: Jan 05 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More