Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Client Java for testing the API

Client Java for testing the API 1 year 2 months ago #97396

  • nicola_86
  • nicola_86's Avatar
Hello!
I'm trying to develop a client in order to test the service to integrate in my system. I'd like to do that with Java. I'm trying using a standard httpclient of Apache.
I'm testing the method get_session_key insering my username and password of the server.
Here is the client: pastebin.com/6WPEMTuC
The answer is the following:
HTTP/1.1 200 OK [Date: Wed, 26 Jun 2013 06:53:16 GMT, Server: Apache/2.2.15 (CentOS), X-Powered-By: PHP/5.3.3, Set-Cookie: PHPSESSID=gvr28gs8eihjbpm7hj7fnl8i76; path=/; HttpOnly, Expires: Thu, 19 Nov 1981 08:52:00 GMT, Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, Pragma: no-cache, Content-Length: 0, Keep-Alive: timeout=15, max=100, Connection: Keep-Alive, Content-Type: text/html; charset=UTF-8]

I'm problably doing something wrong, can anyone help me?
Thanks
The administrator has disabled public write access.

Client Java for testing the API 1 year 2 months ago #97398

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6272
  • Thank you received: 800
  • Karma: 240
Not sure,

But think you have the session , then it great ?

Maybe some library to help you:
- json-rpc.org/implementations
- code.google.com/p/jsonrpc4j/

Denis
The administrator has disabled public write access.

Client Java for testing the API 1 year 2 months ago #97405

  • nicola_86
  • nicola_86's Avatar
Thanks for the answer.
Do you have any experience with that library: jsonrpc4j
I'm trying to understand how to use it. In the examples I've just found it:

JsonRpcHttpClient client = new JsonRpcHttpClient(new URL("example.com/UserService.json"));
User user = client.invoke("createUser", new Object[] { "bob", "the builder" }, User.class);

How I can use it for getting the session key? The api says it is a string Object.

thanks
The administrator has disabled public write access.

Client Java for testing the API 1 year 2 months ago #97407

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6272
  • Thank you received: 800
  • Karma: 240
"java dev experience" === NULL :)
The administrator has disabled public write access.

Client Java for testing the API 1 year 2 months ago #97408

  • nicola_86
  • nicola_86's Avatar
:( anyone else?
The administrator has disabled public write access.

Client Java for testing the API 1 year 2 months ago #97409

  • nicola_86
  • nicola_86's Avatar
Do you think that PHPSESSID=gvr28gs8eihjbpm7hj7fnl8i76; is the session key?
The administrator has disabled public write access.

Client Java for testing the API 1 year 2 months ago #97416

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6272
  • Thank you received: 800
  • Karma: 240
Yes, i think :)
The administrator has disabled public write access.

Client Java for testing the API 1 year 2 months ago #97451

  • nicola_86
  • nicola_86's Avatar
I've just check on the server side. On the log I've got this line:
[27/Jun/2013:11:29:25 +0200] 131.175.38.99 - 131.175.187.153 80 <url_of_the_server> 4386583 "POST /index.php/admin/remotecontrol/get_session_key HTTP/1.1" 200 - "-" "Apache-HttpClient/4.2.5 (java 1.5)" "-"

What do you think it happened?It seems to me that my post request wasn't well done.
The administrator has disabled public write access.

Client Java for testing the API 1 year 2 months ago #97452

  • mdekker
  • mdekker's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 341
  • Thank you received: 68
  • Karma: 38
The request needs to be a post, with content-type application/json otherwise there will be no response.
---
Menno Dekker
The administrator has disabled public write access.

Client Java for testing the API 1 year 2 months ago #97453

  • nicola_86
  • nicola_86's Avatar
As you can see its a POST and the content type is application/json: pastebin.com/9c7W21dN
What's wrong with that code? Any suggestion?
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.122 seconds
Donation Image