Hello, I'm trying my hardest right now to try and call a RESTful web service from GRAILS.
I have a service set up with the Google app engine api, which is basically a dummy service that mocks a service my company uses internally.
The service is simple, it takes 2 parameters, username and password and returns some json that says either { "authenticated" : "true" } or { "authenticated" :"false" }
obviously the official one will be more secure, but anyway, the data is passed as http://serviceurl/{username}?password={password}&format=json
the user and password is sent in the url, and the format desired.
Point being, it works fine in a browser, but when I try to open the same url from a grails service it throws an IO exception
Now, I've tried grails add-proxy and set-proxy they didn't help.Code:java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.0 404 Not Found"
my method of calling via grails is such:
Alternately I tried setting the proxy by changing the openConnection line to:Code:def url = new URL('http://serviceurl/${username}?password=${password}&format=json') //Where ${username} and ${password} are of course defined. URLConnection connection = url.openConnection() connection.setDoOutput(true) connection.setRequestProperty('method','GET') connection.connect()
and still this did nothing to help me.Code:URLConnection connection = url.openConnection(new Proxy(Proxy.Type.HTTP,new InetSocketAddress('proxyurl',${proxyport})))
Many thanks.


Reply With Quote