I am updating my Servoy 4 solution to run in Servoy 6. The code that works in Servoy 4 is :
var vPoster = plugins.http.getPoster('http://xxxx.dakim.com/pod/3548/xxxxxdb?action=rebuild-db');
return vPoster.doPost();
In Servoy 6, I have replaced it with this, but it does not work:
var vHTTPClient = plugins.http.createNewHttpClient();
var vPostRequest = vHTTPClient.createPostRequest('http://xxxx.dakim.com/pod/3548/xxxxxdb?action=rebuild-db');
var vResponse = vPostRequest.executeRequest();
return vResponse.getStatusCode();
If I run the method in the debugger, it seems that the http client is created, the post request is created, but vPostRequest.executeRequest() returns null. I have verified that the Servoy 4 code is working properly running from the same computer that is running Servoy 6. Any ideas why the post request does not seem to be executed?
Steve in L.A.
Servoy 6.1
Java 1.6 Update 34
It works fine for me in 6.1.2, the only difference is that I also use authentication and I post a file.
Try to move the GET parameter action=rebuild-db to a new line of code: vPostRequest.addParameter(‘action’,‘rebuild-db’), maybe the problem is that you post request doesn’t have any parameters or files. Just my 2 cents.
I changed the code to this:
var vHTTPClient = plugins.http.createNewHttpClient();
var vPostRequest = vHTTPClient.createPostRequest('http://xxxx.dakim.com/pod/3548/xxxxxdb');
vPostRequest.addParameter("action","rebuild-db");
var vResponse = vPostRequest.executeRequest();
return vResponse.getStatusCode();
Now, vResponse is getting set, but the response is not the response I expect to get from the rebuild-db action. Instead, I am getting the response that would be returned if the post url was only ‘http://xxxx.dakim.com/pod/3548/xxxxxdb’ without the parameter. Any ideas why the parameter is not added?
Steve in L.A.
Servoy 6.1
Java 1.6 Update 34
Nope, sorry.
I guess you will have to check you webserver log to see what’s going wrong.
BTW, why are you using a POST when you are passing only one GET parameter (in the URI)?
Try to use a GET instead of a POST, there’s nothing to hide in the URI in your scenario and there’s no size limit issue since you are only passing a few chars as parameter.
When I send the post request using the code that includes vPostRequest.addParameter(“action”,“rebuild-db”), the webserver logs reports that it receives the request, but the parameter is missing from the URL. If I go back to sending the post request with the parameter included in the URL, the webserver log does not show an entry at all.
I am using POST instead of GET because that is how the developer that wrote the HTTP code (not me) wrote it. This is code that gets called from other sources besides Servoy.
Was this something fixed in 6.1.2? I have been trying to avoid upgrading higher than 6.1 until I have been able to complete all of the rewriting needed to make a Servoy 4 solution compatible, but maybe I need to bite the bullet in this case.
Steve in L.A.
Servoy 6.1
Java 1.6 Update 34