Creating a Webservice
From WebLichtWiki
(4 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
+ | (Deprecated) | ||
This tutorial presents a workflow for creating a webservice for TCF processing. It assumes you have the following software installed: | This tutorial presents a workflow for creating a webservice for TCF processing. It assumes you have the following software installed: | ||
* [http://netbeans.org/ NetBeans IDE 7.1.2] | * [http://netbeans.org/ NetBeans IDE 7.1.2] | ||
− | * wget command line tool (available by default on Linux/Unix machines) | + | * wget command line tool (optional) (available by default on Linux/Unix machines) |
=== Importing a Maven Archetype=== | === Importing a Maven Archetype=== | ||
Line 25: | Line 26: | ||
In "Maven Repository Browser window expand the "Clarin Repo" you've just added. You'll see a list of available artifacts. | In "Maven Repository Browser window expand the "Clarin Repo" you've just added. You'll see a list of available artifacts. | ||
Find a group named "eu.clarin.weblicht". In this group there is an artifact called "weblicht-webservice-archetype". | Find a group named "eu.clarin.weblicht". In this group there is an artifact called "weblicht-webservice-archetype". | ||
− | Download this artifact by right clicking | + | Download this artifact by right clicking its most recent version number and selecting "Download" in the menu. |
[[File:download-archetype.png]] | [[File:download-archetype.png]] | ||
+ | |||
+ | === Creating a Project from an Archetype === | ||
Once the archetype has been downloaded, we can start using it at once. | Once the archetype has been downloaded, we can start using it at once. | ||
Line 47: | Line 50: | ||
[[File:my-first-webservice.png]] | [[File:my-first-webservice.png]] | ||
− | Of course you would probably like to | + | === Testing Webservices === |
+ | |||
+ | The most straightforward way to test a webesrvice is to use wget command line tool: | ||
+ | |||
+ | <nowiki> wget --post-file=input.xml --header='Content-Type: text/tcf+xml' http://localhost:8080/myfirstwebservice/mytool</nowiki> | ||
+ | |||
+ | Make sure you actually have a file named "input.xml" in the current directory. This file is located under "Web Pages" in your project, just copy it to your current directory. | ||
+ | |||
+ | === What's next? === | ||
+ | |||
+ | Of course you would probably like to customize the provided code. Let's take a look at the files we have in the project: | ||
* MyService.java - is the application definition, use it to define the path to your application and/or add more resources. | * MyService.java - is the application definition, use it to define the path to your application and/or add more resources. |
Latest revision as of 08:48, 13 December 2012
(Deprecated) This tutorial presents a workflow for creating a webservice for TCF processing. It assumes you have the following software installed:
- NetBeans IDE 7.1.2
- wget command line tool (optional) (available by default on Linux/Unix machines)
Contents |
Importing a Maven Archetype
Open a maven repository browser by openning:
Window -> Other -> Maven Repository Browser
Go to the "Maven Repository Browser" window and click "Add Repository", then fill in the following information:
- Repository ID: clarin
- Repository Name: Clarin Repo
- Repository Type: Remote
- Repository URL: http://catalog.clarin.eu/ds/nexus/content/repositories/Clarin/
Finish by pressing "Add"
In "Maven Repository Browser window expand the "Clarin Repo" you've just added. You'll see a list of available artifacts. Find a group named "eu.clarin.weblicht". In this group there is an artifact called "weblicht-webservice-archetype". Download this artifact by right clicking its most recent version number and selecting "Download" in the menu.
Creating a Project from an Archetype
Once the archetype has been downloaded, we can start using it at once. Press the "New Project" button in the menu bar and select: Maven -> Project From Archetype
In the next screen expand the "Archetypes from Local Repository" branch and then select "WebLicht Webservice Archetype"
Provide a name for your project, a directory to store it in as you would normally do with any NetBeans project. In addition you have a possibility to provide a group name for your maven artifact and a package name you would like to use.
That's it! You have just created a WebLicht webservice.
Testing Webservices
The most straightforward way to test a webesrvice is to use wget command line tool:
wget --post-file=input.xml --header='Content-Type: text/tcf+xml' http://localhost:8080/myfirstwebservice/mytool
Make sure you actually have a file named "input.xml" in the current directory. This file is located under "Web Pages" in your project, just copy it to your current directory.
What's next?
Of course you would probably like to customize the provided code. Let's take a look at the files we have in the project:
- MyService.java - is the application definition, use it to define the path to your application and/or add more resources.
- MyResource.java - is the definition of a resource, in case more resources are required you can use it as a template for any further resources. (Don't forget to add them to the MyService.java)
- MyTool.java - is the place where an actual implementation of a tool resides. In this template a simple tokenizer implementation is provided.