Package org.sonar.api.server.ws
Interface WebService
-
- All Superinterfaces:
Definable<WebService.Context>
@ServerSide @ExtensionPoint public interface WebService extends Definable<WebService.Context>
Defines a web service.
The classes implementing this extension point must be declared byPlugin.
How to use
public class HelloWs implements WebService { @Override public void define(Context context) { NewController controller = context.createController("api/hello"); controller.setDescription("Web service example"); // create the URL /api/hello/show controller.createAction("show") .setDescription("Entry point") .setHandler(new RequestHandler() { @Override public void handle(Request request, Response response) { // read request parameters and generate response output response.newJsonWriter() .beginObject() .prop("hello", request.mandatoryParam("key")) .endObject() .close(); } }) .createParam("key").setDescription("Example key").setRequired(true); // important to apply changes controller.done(); } }Since version 5.5, a web service can call another web service to get some data. See
Request.localConnector()provided byRequestHandler.handle(Request, Response).- Since:
- 4.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classWebService.Actionstatic classWebService.Contextstatic classWebService.Controllerstatic classWebService.NewActionstatic classWebService.NewControllerstatic classWebService.NewParamstatic classWebService.Paramstatic classWebService.SelectionMode
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddefine(WebService.Context context)Executed once at server startup.
-
-
-
Method Detail
-
define
void define(WebService.Context context)
Executed once at server startup.- Specified by:
definein interfaceDefinable<WebService.Context>
-
-