| What happened to IRest? [message #895672] |
Sat, 14 July 2012 11:32  |
Richard Moulton Messages: 78 Registered: August 2011 Location: Devon, UK |
Member |
|
|
At some point support for IRest has been removed from EDT; I think this may may have been removed from 0.81M3.
I used to be able to do the following ...
package client;
import org.eclipse.edt.rui.widgets.Div;
import org.eclipse.edt.rui.widgets.HTML;
handler test type RUIhandler{initialUI =[ui], onConstructionFunction = start, cssFile = "css/testirest.css", title = ""}
ui div{children =[result]};
result html{};
function start()
myIRest IRest?;
uri string = "http://www.eclipse.org/";
call myIRest.invokeGet(uri)
returning to gotpage
onException serviceExceptionHandler;
end
function gotpage(retResult string in)
result.text = retresult;
end
function serviceExceptionHandler(exp AnyException in)
s String = "An exception has occurred: " + exp.message + " <br>";
if(exp isa ServiceInvocationException)
s += "Detail1: " + (exp as serviceInvocationException).detail1 + " <br>";
s += "Detail2: " + (exp as serviceInvocationException).detail2 + " <br>";
s += "Detail3: " + (exp as serviceInvocationException).detail3 + " <br>";
end
SysLib.writeStdout(s);
end
end
I see that there have been changes to the service access within 0.81M3 and I've followed the link to http://wiki.eclipse.org/EDT:Resource_Binding_Services but I can't get the syntax right to perform the same function.
How would I now perform the http get?
Richard
|
|
|
| Re: What happened to IRest? [message #895943 is a reply to message #895672] |
Mon, 16 July 2012 11:28   |
Joseph Vincens Messages: 31 Registered: December 2011 Location: Prospect CT |
Member |
|
|
Hi Richard,
To do a function invocation: create a proxy function that represents the service end point.
In this case the end point is a REST service, accessed using an HTTP GET with a URL of http://www.eclipse.org/.
library ServiceInvocationLib
function invokeGetEclipse(){
@Resource {uri="binding:httpEclipse"}, //the egldd entry named httpEclipse defines the URL.
@REST{ //indicates a REST service endpoint
method = HttpMethod._GET //indicates that a http get is used to access the data
}
}
end
end
Create a new egldd Rest binding named httpEclipse with a baseURI = http://www.eclipse.org/
Here how you would use the proxy function to invoke the service.
function start1()
call ServiceInvocationLib.invokeGetEclipse()
returning to gotpage
onException serviceExceptionHandler;
end
regards,
Joe
[Updated on: Mon, 16 July 2012 11:29] Report message to a moderator
|
|
|
|
| Re: What happened to IRest? [message #895973 is a reply to message #895961] |
Mon, 16 July 2012 13:36   |
Dan Darnell Messages: 145 Registered: November 2011 Location: Arkansas |
Senior Member |
|
|
Use this proxy function instead:
function invokeGetEclipse() returns (string){
@Resource {uri="binding:httpEclipse"},
@REST{
method = HttpMethod._GET
}
}
end
Notice that it returns a string ... probably the result you are looking for.
--Dan
[Updated on: Mon, 16 July 2012 13:41] Report message to a moderator
|
|
|
|
| Re: What happened to IRest? [message #896566 is a reply to message #895978] |
Wed, 18 July 2012 19:08  |
Richard Moulton Messages: 78 Registered: August 2011 Location: Devon, UK |
Member |
|
|
Joe/Dan,
Many thanks that's working well.
I made a couple of slight tweaks. I'm building the uri on the fly and I couldn't see a way of doing that through a binding entry, so I ended up with the following library part ...
package client.libraries;
library ServiceInvocationLib
function invokeGet() returns(string)
{
@REST{ //indicates a REST service endpoint
method = HttpMethod._GET //indicates that a http get is used to access the data
}
}
end
end
... and the following code in my handler ...
// Retrieve summary data page for given sector csi
myBindingVariable IHttp? = new HttpRest{
request.uri = getSummaryURI + strLib.clip(sectorCSI)
};
call ServiceInvocationLib.invokeGet()
using myBindingVariable
returning to gotSectorSummary
onException serviceExceptionHandler;
Richard
|
|
|
Powered by
FUDForum. Page generated in 0.01814 seconds