ShanoirWs (2009)

ShanoirWs is a library that allows you to access to the Shanoir webservices.

Générer le projet à partir des sources

In this part is explained how to build a jar file.

Pre-requisite : maven, ant

  1. Firstly, you need to get the WSDL files from the Shanoir server. To do so, you can download the sources of Shanoir and then execute the Ant task “ant build-server-java”. This will create the wanted files in the directory ${INRIANEUROTK_SOURCES}/resources/WEB-INF/wsdl.
  2. Then you must define where are located the WSDL files in the “pom.xml” file. To do so, just modify the “wsdlSrcDir” property at the end of the pom.xml file.
  3. At last, execute the command line “mvn clean compile license:format license:check package” at the root of the ShanoirWs project. This will create a jar file into the “target” directory. To install it on your local maven repository, execute the command line “mvn install”. Or you can do both jar creation and install in repo with “mvn clean compile license:format license:check package install” (can be usefull to create an eclipse run configuration)

Générer des WSDL dans Shanoir

Webservices are created in the package org.shanoir.webservices. To automatically generate the associated WSDL, you just need to call the build-server-java Ant task described in the build.xml file of the Shanoir project. Pay attention : each webservice requires a wsgen Ant task in the build-server-java task. Sample for DownloadService :

<wsgen genwsdl="true" keep="true" verbose="true" destdir="${wsdl.dir}" sei="org.shanoir.webservices.impl.Downloader">
  <classpath>
    <pathelement path="${lib.dir}/ejb-api.jar" />
    <pathelement path="${lib.dir}/jboss-seam.jar" />
    <path location="${jar.dir}" />
  </classpath>
</wsgen>

If you get such error message :

[wsgen] D:\workspaces\ShaNoir\Shanoir\exploded-archives\Shanoir.jar\org\inria\neurotk\core\model\dataset\mr\MrDataset.class: warning: Cannot find annotation method 'name()' in type 'javax.persistence.Table': class file for javax.persistence.Table not found
    [wsgen] D:\workspaces\ShaNoir\Shanoir\exploded-archives\Shanoir.jar\org\inria\neurotk\core\model\dataset\mr\MrDataset.class: warning: Cannot find annotation method 'name()' in type 'javax.persistence.PrimaryKeyJoinColumn': class file for javax.persistence.PrimaryKeyJoinColumn not found
    [wsgen] D:\workspaces\ShaNoir\Shanoir\exploded-archives\Shanoir.jar\org\inria\neurotk\core\model\dataset\mr\MrDataset.class: warning: Cannot find annotation method 'fetch()' in type 'javax.persistence.ManyToOne': class file for javax.persistence.ManyToOne not found
    [wsgen] Problem encountered during annotation processing; 
    [wsgen] see stacktrace below for more information.
    [wsgen] com.sun.tools.ws.processor.modeler.ModelerException: [failed to localize] modeler.nestedGeneratorError(java.lang.NullPointerException)

You probably forgot to add a library, in the above case ejb3-persistence.jar is missing :

<pathelement path="${lib.dir}/ejb3-persistence.jar" />

Extend the ShanoirWs project

This project contains 3 packages :

  • org.shanoir.ws.custom : Webservice Access Classes with which we can specify on-the-run the address of the Shanoir Server.
  • org.shanoir.ws.generated : Generated Classes by the maven wsimport task
  • org.shanoir.ws.util : Utile Classes for the ShanoirWs project

In order to automatically generate theclasses and install the resulting jars ShanoirWs-version.jar in the local Maven repository, You just need to run the pom.xml file with clean install as parameter. Warning: the content of the jaxws-maven-plugin, located in the pom.xml, must be synchronized all the wsdl files from the org.shanoir.webservices package of the Shanoir project.

Comment ajouter un webservice ?

Vous pouvez vous inspirer du webservice DownloadService pour développer de nouveaux web services.

  • Créer une interface dans le package org.shanoir.webservices.interfaces
    • Annoter l'interface avec @Remote
  • Créer son implémentation dans le package org.shanoir.webservices.impl
    • Annoter la classe avec @WebService
    • Annoter les méthodes à exposer avec @WebMethod
  • Générer les fichiers d'interface en executant la tâche ant
    ant build-server-java

How to add a trusted Shanoir Server in the Web Service truststore ?

keytool -import -alias name_of_cert -file path_to_the_certificate -keystore path_to_the_truststore

Why my webservice crashes at runtime ?

If you get the following error trying to run a webservice:

Exception in thread "main" com.sun.xml.ws.protocol.soap.MessageCreationException: Couldn't create SOAP message due to exception: XML reader error: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
 at [row,col {unknown-source}]: [1,0]

with in the JBoss log (JBOSS_HOME/server/default/log/server.log):

2009-12-09 09:50:45,671 ERROR [org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS] SOAP request exception
java.lang.UnsupportedOperationException: setProperty must be overridden by all subclasses of SOAPMessage

It is more likely because JBoss doesn't have jboss-saaj.jar and jboss-jaxrpc.jar libraries in $JBOSS_HOME/lib/endorsed. You must copy them manually.


Personal Tools