In this tutorial we'll create and deploy a simple "hello world" service in the workbench module.
The workbench is a pre-configured module that allows scripts and services to be rapidly prototyped with no need for any additional NetKernel configuration.
At each step we'll describe what we are doing and why. Where necessary links are given to further reading.
We'll create a web page which is bound to a URL path on a HTTP port and which returns an XML document:
<hello>world</hello>
The XML document will be generated by a DPML (Declarative Processing Markup
Language) script.
1) Create a DPML script
In the workbench module create a new directory hello (the workbench
module is located on your filesystem at [install]/modules/workbench/ where [install] is the directory where you installed NetKernel).
In the new directory create a file world.idoc.
Cut and paste the following text to the file:
<idoc> <instr>
<type>copy</type>
<operand>
<hello>world</hello>
</operand>
<target>this:response</target>
</instr>
</idoc>
This script has one instruction that copies a literal XML document to the response. The instruction calls the
copy
accessor and copies a literal XML fragment (enclosed by the operand argument) to the response (this:response) of the DPML script.
For more information on the DPML language see here.
2) Execute
We are now ready to execute the script. The workbench module is configured such that it presents itself on a HTTP server on port 8080 and on a subpath of
/workbench/. It uses the file extensions of the URLs to find a language runtime to execute a script; so a .idoc is mapped
to execution by the DPML runtime service. Open your browser at http://localhost:8080/workbench/hello/world.idoc.
You should get returned to you the correct XML document.
Wrap up
Thats it! - you have now created your first service and executed it. You have learned how to use
the workbench to rapidly prototype. In the workbench there are some further examples which you might like to play with.
Here are some links to continue your exploration:
- My First Module - learn how to create and deploy modules. This trailmap takes
the service you have just created and packages it into its own module. Along the way you'll learn many of the
concepts that underpin NetKernel.
- Scripted Services - as an alternative to DPML, the scripting languages allow you to create functionality
with procedural scripting languages.