we want to periodically monitor a GWT web application by checking if its possible to login into the application via a shell script.
Is there a way to send a http post request with JSON data to a GWT servlet with wget?
we want to periodically monitor a GWT web application by checking if its possible to login into the application via a shell script.
Is there a way to send a http post request with JSON data to a GWT servlet with wget?
I have tried to call GWT webapp using Apache JMeter (so I think wget will be able to do the same thing EDIT. curl instead of wget, thanks to @Chris Lercher, see his comment). Presuming that your application uses GWT-RPC to call server side you can't use JSON. First of all you need to convert JSON into GWT-RPC proprietary format. The simplest way to do it is to catch necessary request from the actual application. You can catch it using Chrome Developer Tools (open your app, turn on preserving log on network tab of developer tools, then force your app to fire request and analyse request payload). It may looks something like this:
7|0|4|http://yourapp/|024F843AF926C69027FD016F55BAC7DF|com.mycompany.RPCProductService|getProducts|1|2|3|4|0|
Then you can try to call your app.
This request will fail after the moment when new version of the application will be deployed (even if corresponding endpoint will remain the same). There is some kind of security signature that is included in each request and that will be changed automatically.
Hope this helps.
It worked for me using the hint to use curl and the way maksym described:
curl -i -X POST <REQUEST URL> -H "<ALL HEADERS FROM CATCHED REQUEST>" -d @<FILENAME>
where FILENAME is the name of a file containing the post data from the catched request