Introduction
This tutorial will show you how to publish a service written in Java.
Although InstantSOAP is highly configurable, in this case, we are going
to use the simplest defaults.
It assumes that you have installed Java, Tomcat and Maven, as described
in the
requirements
. If you have not
tried the
10 minute
introduction, you might like to start there.
Generate a Skeleton
InstantSOAP uses the maven tool for building. In this case, we are going
to use an "archetype" to generate the base structure. This is a matter
of typing the following command.
mvn archetype:create -DarchetypeGroupId=uk.ac.ncl.cs.instantsoap \
-DarchetypeArtifactId=archetype-escience-tool \
-DarchetypeVersion="2.0" \
-DgroupId=uk.org.your.url.here \
-DartifactId=your_service_name
Depending on your operating system you may have to type this in on one
line without the "\"'s. The last two lines should be replaced with
something specific to your service.
Customising the code
Find the file called
HelloWorldProcessor.java
. The exact
location will depend on the values you used in the last section. Find
this section.
// this is the guts of the processor -- in this case, it does very little.
public String process(String input) throws JobExecutionException
{
return "hello " + input;
}
Change this to:
// this is the guts of the processor -- in this case, it does very little.
public String process(String input) throws JobExecutionException
{
return "goodbye " + input;
}
Find the file called
HelloWorldProcessorTest.java
.
Replace this section:
public void testProcess() throws Exception
{
HelloWorldProcessor processor = new HelloWorldProcessor();
Assert.assertEquals("hello world", processor.process("world"));
}
with this:
public void testProcess() throws Exception
{
HelloWorldProcessor processor = new HelloWorldProcessor();
Assert.assertEquals("goodbye world", processor.process("world"));
}
You can just delete the test class if you prefer, although tests are
good practice.
Compile and Deploy
Move to the same directory as the file
pom.xml
. Now type
This should create a
war
in the directory
target
called
your_service_here.war
. You can
now deploy this as described
elsewhere
.
Finally, check that the service is running by navigating to:
http://localhost:8080/your_service_here-SNAPSHOT/services/instantsoap/applications?wsdl
Conclusions
Deploying a service should be relatively straight-forward. For many
users, the steps shown here should be sufficient for most purposes. The
files created in the first step have additional documentation describing
what each does for those who wish to configure InstantSOAP further.