[Zoo-discuss] java service example 2

Fenoy Gerald gerald.fenoy at geolabs.fr
Tue Nov 25 06:15:23 PST 2014


Hi Andrea,
sorry for late reply.

My answer in the following.

> Le 20 nov. 2014 à 14:27, andrea antonello <andrea.antonello at gmail.com> a écrit :
> 
> Hi Gerald,
> 
> [...]
>>> Ok, so the inputs are always string. This means that each module has
>>> to do the conversion to its own datatype? I was expecting to have the
>>> declared type. Is that the same for the other languages or is it due
>>> to missing java support?
>> 
>> Indeed the inputs are always « string » (I quote the string cause it can contains binary content also which is not really a string, in such a case you will have the optional size attribute accessible for being able to read binary data). You are right, the service implementer have the responsibility  to define their own methods to convert those « strings » to  whatever is of use in their language. For the C language there are an API to read and write the output using OGR directly but this was never generalized to other languages and I have to admit that I do not see how the implementation can handle this on its own, as some may need to use OGR and other may prefer to use another library to parse the input.
>> 
>> I’m not sure about the declared type you speak about, if you search for mimeType, so yes you have access to this kind of information from the HashMap corresponding to your input. In other case I don’t know what do you expect here ?
> 
> No it is fine as it is. I was assuming that this might be the reason.
> It is ok. The hashmap contains the datatype I declare, so I will be
> able to implement the transformer needed.
> 
> [...]
>> I am interested a lot in having more informations about the messages you have when it crashed. Nevertheless, you should use the following syntaxe (based on your example request and  if I understood it well):
>> 
>> http://127.0.0.1/cgi-bin/zoo_loader.cgi?metapath=zoojavatest&Service=WPS&request=Execute&Version=1.0.0&Identifier=ZooJavaBuilder&DataInputs=inParameter=3.0;inPath=/mypath/dtm.asc
> 
> I tried that before, but it crashes. The debug apache log gives me:
> 
> Addr:127.0.0.1
> RequestMethod: (GET) -1 0
> Request: metapath=zoojavatest&Service=WPS&request=Execute&Version=1.0.0&Identifier=ZooJavaBuilder&DataInputs=inParameter=3.0;inPath=/mypath/dtm.asc
> ContentType:
> ContentLength: 138
> ((
> metapath
> zoojavatest
> ))((
> Service
> WPS
> ))((
> request
> Execute
> ))((
> Version
> 1.0.0
> ))((
> Identifier
> ZooJavaBuilder
> ))((
> DataInputs
> inParameter=3.0;inPath=/mypath/dtm.asc
> ))
> 

This sounds really strange to me. Is it possible that you were setting the DEBUG flag to activated when compiling your ZOO-Kernel ? If yes, I would like to invite you to build again without this flag. I would also like to know what is the version of ZOO-Kernel you are using, I suppose you tried with 1.4.0-rc1, isn’t it ?

> and the java core dump just tells me that it starts from the main cgi
> binary but nothing more:
> 
> Dynamic libraries:
> 08048000-08083000 r-xp 00000000 08:01 677982     /usr/lib/cgi-bin/zoo_loader.cgi
> 08083000-08084000 r--p 0003a000 08:01 677982     /usr/lib/cgi-bin/zoo_loader.cgi
> 08084000-08085000 rw-p 0003b000 08:01 677982     /usr/lib/cgi-bin/zoo_loader.cgi
> 08085000-08092000 rw-p 00000000 00:00 0
> 097fe000-09868000 rw-p 00000000 00:00 0          [heap]
> b1ba9000-b1dc5000 rw-p 00000000 00:00 0
> b1dc5000-b1dcd000 rw-s 00000000 08:01 782763     /tmp/hsperfdata_www-data/29744
> b1dcd000-b1df0000 r-xp 00000000 08:01 1053820
> /usr/lib/jvm/jdk1.7.0_71/jre/lib/i386/libjava.so
> ...
> 
> I committed everything to github. Can you have another check on the
> code. I first want to make sure that I have everything right in that
> spot.

Almost everything looks fine in the source code you committed on Github. 

When the service failed, so for instance on line 24 in ZooJavaWps.java [1], the ZOO-Kernel will then never try to access any output. So, in case of failure, you should use the message key of the [lenv] section of your conf HashMap to have access on the client side to the message you want to return. You should use something like the following:

HashMap<String, String> lenv = conf.get("lenv »);
lenv.set("message",e.getLocalizedMessage());

> 
>> 
>> So as you noticed, when you have more than one DataInputs, you should separate each input name by using semicolon (« ; »).
>> 
>> side-note: As explained in a different thread today, you can also use the prefixed service name: zoojavatest. ZooJavaBuilder as Identifier value in your request.
> 
> I tried that, but it doesn't load the main.cfg that is inside zoojavatest.

Indeed, in the 1.4.0-rc1 version there is no more need to multiply the location of the main.cfg, only the main.cfg which is in the same directory as the ZOO-Kernel will be read, it is the same for the JavaScript ZOO-API, so you may simply copy the main.cfg located in zoojavatest to the ZOO-Kernel directory.

> Also how to handle this in the case of a getCapabilities request? In
> that case you need the metapath to make sure you pick the right spot.

In the 1.4.0-rc1 version, it is now possible to have access to the whole list of available services even if they are located in a sub-directory of the ZOO-Kernel one. So for instance, if you have a sub-directory named ogr from the GetCapabilities you will have access to the ogr.XXX identifier where XXX is a name a service (so a ZCFG file) located in the or directory. Obviously, when you want to run this service, you simply have to keep the same Identifier as the one returned by the GetCapabiltiies.

> 
> Andrea

I hope this help and to hear back from you,
Bets regards,

[1] https://github.com/moovida/zoo-java-example-service/blob/master/ZooJavaMain/src/org/jgrasstools/ZooJavaWps.java#L24





Gérald Fenoy
http://wiki.osgeo.org/wiki/User:Djay



More information about the Zoo-discuss mailing list