REST Web Services

REST Web Services don't have to be hard to build

A challenge when building REST Web Services is binding the web service endpoint to executable code. Various technologies offer binding at compile time or binding by file name convention.

Bi-Directional Binding

NetKernel 4 introduces a bi-directional grammar technology which parses and binds an in-bound request identifier to an endpoint and allows compiled code to dynamically construct a proper identifier for a remote service.

For example, the following grammar:

http://example.org/customer/<group name="id"><regex type="alphanum"</group>
will parse the identifier http://example.org/customer/42 and allow the customer identifier to be accessed with the following code:
String customerID = context.getThisRequest().getArgumentValue("id");
If the identifier syntax changes then the grammar can be changed; the compiled code continues to work correctly.

Likewise, compiled code can construct a proper identifier for a remote web service by using a grammar factory:

String grammarDefinition = ... // Grammar definition from an outside resource
Grammar grammar = Grammar.parse(grammarDefinition);
grammar.addArgument("id", customerID);
URI uri = grammar.getURI();

Benefits

Binding identifiers to code with a grammar decouples the code from external changes.

When developing code to implement a REST web service, decouple the external URI endpoint syntax from your compiled code. If changes occur in the syntax, simply change the grammar and not the compiled code.

If your code accesses a remote service, keep the grammar that describes the service endpoint syntax separate from the compiled (and deployed) code. If changes occur, simply change the grammar and not the code.

Learn More

To learn more about grammars and REST web service development, download NetKernel 4 and explore its documentation and tutorials.

"NetKernel dramatically reduces complexity. Our J2EE based system became too brittle to change. Introducing NetKernel into our J2EE system gave us critical flexibility and control."

- Martin Katchel
Chief Architect, Marketplatz Portal

Enterprise Trial Offer

Try NetKernel Enterprise free for 90 days.

Includes free access to the support portal where you can get help, submit and track questions, collaborate and document your project.

download now