Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » EGL Development Tools » What happened to IRest?
What happened to IRest? [message #895672] Sat, 14 July 2012 15:32 Go to next message
Richard Moulton is currently offline Richard MoultonFriend
Messages: 92
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 15:28 Go to previous messageGo to next message
Joseph Vincens is currently offline Joseph VincensFriend
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 15:29]

Report message to a moderator

Re: What happened to IRest? [message #895961 is a reply to message #895943] Mon, 16 July 2012 16:27 Go to previous messageGo to next message
Gregory Testa is currently offline Gregory TestaFriend
Messages: 28
Registered: April 2012
Junior Member
When I try this syntax, I am getting an error, "The returning to or onException function gotpage requires 0 parameter(s)."
Re: What happened to IRest? [message #895973 is a reply to message #895961] Mon, 16 July 2012 17:36 Go to previous messageGo to next message
Dan Darnell is currently offline Dan DarnellFriend
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 17:41]

Report message to a moderator

Re: What happened to IRest? [message #895978 is a reply to message #895973] Mon, 16 July 2012 18:01 Go to previous messageGo to next message
Gregory Testa is currently offline Gregory TestaFriend
Messages: 28
Registered: April 2012
Junior Member
Just what I needed. Thanks, Dan!
Re: What happened to IRest? [message #896566 is a reply to message #895978] Wed, 18 July 2012 23:08 Go to previous message
Richard Moulton is currently offline Richard MoultonFriend
Messages: 92
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
Previous Topic:Form field parsing issue
Next Topic:MySQL table access
Goto Forum:
  


Current Time: Tue Apr 16 16:37:57 GMT 2024

Powered by FUDForum. Page generated in 1.81251 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top