Why does EK9 reject a service method that declares a return but has no implementation body?
← Web Services · Ref: Q1326
Services in EK9 are CONCRETE entry points - every endpoint method must supply a real implementation body. Declaring only the return (for example '<- response as HTTPResponse?') with no statements that build the response leaves the method effectively abstract, and EK9 raises E07740 because services cannot be abstract. The runtime must be able to invoke every route, so there is no such thing as an abstract service method.
The fix is to provide a body that materialises the HTTPResponse, typically a dynamic class implementing the HTTPResponse trait with overrides for content, status, contentType, cacheControl and contentLanguage.
E07740 differs from E07800: E07800 fires when there is no return declaration at all, whereas E07740 fires when the return is declared but no implementation is provided. See Q685 for service method body rules. See Q869 for the missing-return case (E07800).
Example
defines module qa.web.servicemethodbody defines service StatusService :/status open //CORRECT: the endpoint provides a concrete implementation body that //materialises an HTTPResponse. Leaving only the '<- response as HTTPResponse?' //declaration with no body would raise E07740 (services cannot be abstract). health() as GET for :/health <- response as HTTPResponse: () with trait HTTPResponse override content() <- rtn as String: `{"status": "healthy"}` override status() as pure <- rtn as Integer: 200 override contentType() as pure <- rtn as String: "application/json" override cacheControl() as pure <- rtn as String: "no-cache" override contentLanguage() as pure <- rtn as String: "en" default operator ? defines application StatusApp register StatusService() defines program ServiceMethodBodyDemo() stdout <- Stdout() stdout.println("Service registered with application") stdout.println("GET /status/health returns a concrete HTTPResponse")
Common mistakes
E07740 — Declaring only the return type with no statements that build the response leaves the service method without an implementation, which EK9 treats as abstract and rejects with E07740 because services cannot be abstract. Provide a concrete body that materialises the HTTPResponse (a dynamic class implementing the HTTPResponse trait). See ek9 -h E07740 for details.
Incorrect:
health() as GET for :/health <- response as HTTPResponse?
Correct:
health() as GET for :/health <- response as HTTPResponse: () with trait HTTPResponse override content() <- rtn as String: `{"status": "healthy"}` override status() as pure <- rtn as Integer: 200
Other ways to ask this
- What triggers E07740 - implementation not provided, services cannot be abstract?
- Why can't an EK9 service method be left abstract with just a return declaration?
- How do I fix 'implementation not provided' on a service endpoint in EK9?
Coming from another language?
Java (JAX-RS/Spring): a controller method can compile as an abstract or interface declaration with no body, deferring the implementation - the gap surfaces only at runtime wiring. Kotlin/C#: abstract handler signatures are equally legal in base classes. EK9: a service is a dedicated concrete entry-point construct, so a route declared without an implementation body is rejected at compile time with E07740 - there are no abstract service methods.
Keywords: body, method, concrete, endpoint, implementation, service, web, rest, E07740, abstract, HTTPResponse