Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Accessing a service"
(→Accessing a dedicated service) |
(→Accessing a dedicated service) |
||
Line 18: | Line 18: | ||
/* | /* | ||
− | * | + | * create a new EGL project for "web 2.0 application with services". |
− | * | + | * add the following |
+ | * type valid input into the first text box; for example: | ||
* 5, 12, 4 | * 5, 12, 4 | ||
*/ | */ | ||
Line 26: | Line 27: | ||
import server.MyServiceType; | import server.MyServiceType; | ||
− | |||
− | |||
− | |||
import org.eclipse.edt.rui.widgets.GridLayout; | import org.eclipse.edt.rui.widgets.GridLayout; | ||
import org.eclipse.edt.rui.widgets.TextField; | import org.eclipse.edt.rui.widgets.TextField; | ||
Line 35: | Line 33: | ||
import dojo.widgets.DojoTextField; | import dojo.widgets.DojoTextField; | ||
− | handler | + | handler Test type RUIhandler{initialUI =[ui], |
− | + | onConstructionFunction = start, | |
− | + | cssFile = "css/ProjectInEDT.7.css", | |
− | + | title = "MyHandler"} | |
− | + | ui GridLayout{columns = 3, rows = 4, cellPadding = 4, | |
− | + | children =[myResult, myButton, scores]}; | |
− | + | scores TextField{layoutData = | |
− | + | new GridLayoutData{row = 2, column = 2}}; | |
− | + | myButton DojoButton{layoutData = | |
− | + | new GridLayoutData{row = 4, column = 2}, | |
+ | text = "Calculate", | ||
+ | onClick ::= ui_onClick}; | ||
+ | myResult DojoTextField{layoutData = | ||
+ | new GridLayoutData{row = 4, column = 3}}; | ||
function start() | function start() | ||
Line 68: | Line 70: | ||
myList int[]; | myList int[]; | ||
while(myPosition < inputLength) | while(myPosition < inputLength) | ||
− | myToken = StringLib.getNextToken(scores.text, myPosition, | + | myToken = StringLib.getNextToken(scores.text, |
− | + | myPosition, myDelimiters); | |
if(myToken != null) | if(myToken != null) | ||
myList.appendElement(myToken as int); | myList.appendElement(myToken as int); | ||
Line 79: | Line 81: | ||
end | end | ||
end | end | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Revision as of 16:19, 9 February 2012
Contents
EDT version .7
In EDT version .7, a service is accessible only from a Rich UI application, and your task follows this pattern: declare a service-access variable and use it in a call statement.
Accessing a dedicated service
// use a Service or Interface type to declare the service-access variable myService MyServiceType?{@dedicatedService} // use the variable to call the service call myService.theOperation() returning to theCallBack onException theExceptionHandler; /* * create a new EGL project for "web 2.0 application with services". * add the following * type valid input into the first text box; for example: * 5, 12, 4 */ package client; import server.MyServiceType; import org.eclipse.edt.rui.widgets.GridLayout; import org.eclipse.edt.rui.widgets.TextField; import org.eclipse.edt.rui.widgets.GridLayoutData; import dojo.widgets.DojoButton; import dojo.widgets.DojoTextField; handler Test type RUIhandler{initialUI =[ui], onConstructionFunction = start, cssFile = "css/ProjectInEDT.7.css", title = "MyHandler"} ui GridLayout{columns = 3, rows = 4, cellPadding = 4, children =[myResult, myButton, scores]}; scores TextField{layoutData = new GridLayoutData{row = 2, column = 2}}; myButton DojoButton{layoutData = new GridLayoutData{row = 4, column = 2}, text = "Calculate", onClick ::= ui_onClick}; myResult DojoTextField{layoutData = new GridLayoutData{row = 4, column = 3}}; function start() end function theExceptionHandler(exp AnyException in) SysLib.writeStdOut(exp.message); end function theCallBack(retResult decimal(4, 2) in) myResult.text = retResult; end function ui_onClick(event Event in) inputLength int = scores.text.length(); myDelimiters string = ", "; myPosition int = 1; myToken string; myList int[]; while(myPosition < inputLength) myToken = StringLib.getNextToken(scores.text, myPosition, myDelimiters); if(myToken != null) myList.appendElement(myToken as int); end end myService MyServiceType?{@DedicatedService}; call myService.calculate(myList) returning to theCallBack onException theExceptionHandler; end end
Accessing an EGL REST-RPC service
Accessing a third-party REST service
EDT version .8
// From a a Access a dedicated service http HttpRest{request.uri="http:host\\myService"}; srvc IRest?; srvc = ServiceLib.completeBind(srvc, http);
Accessing HTTP request headers
http HttpRest{}; http.request.headers = new Dictionary { param1 = "a value to pass to my service" }; srvc IRest?{@Resource {}}; srvc = ServiceLib.completeBind(srvc, http);
HTTP request and response
function invokeDoSomething() call srvc.doSomething() returning to serviceCallback; end function serviceCallback(returnValueOne String, callbackHttp IHTTP in) // process callback request or response end