[Zoo-discuss] java service example 2
andrea antonello
andrea.antonello at gmail.com
Thu Nov 20 04:36:59 PST 2014
Hi Gerald,
sorry for the late reply, couldn't get on this until now.
[...]
>> Can you double-check the syntax please? It should really be ok now.
>
> In the code, on line 9 [1], you have conf, inputs and outputs defined as HashMap<String,HashMap<String,String>>.
>
> So when you access the inputs named inPath, on line 12 you will have access to a HashMap<String,String> instance. Same for outPath on line 15.
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?
Anyways I did the changes in the example and added also a double
parameter in order to make this clear.
Rigth now I am not able to run the process because I do not know the
url syntax to use to add a second parameter.
If I do:
http://127.0.0.1/cgi-bin/zoo_loader.cgi?ServiceProvider=&metapath=zoojavatest&Service=WPS&request=Execute&Version=1.0.0&Identifier=ZooJavaBuilder&DataInputs=inPath=/mypath/dtm.asc&DataInputs=inParameter=3.0
it complains about inParameter missing. And if I do:
http://127.0.0.1/cgi-bin/zoo_loader.cgi?ServiceProvider=&metapath=zoojavatest&Service=WPS&request=Execute&Version=1.0.0&Identifier=ZooJavaBuilder&DataInputs=inParameter=3.0&DataInputs=inPath=/mypath/dtm.asc
it crashes. Which would be the proper syntax?
[...]
> No, it is not necessary. You can but don’t have to define all the informations about dataType, mimeType or any other informations. The ZOO-Kernel
> is filling the data structures (so the conf, input and output HashMap in this case) prior to call your service, so everything should be correctly
> set for you. You can still override any value in your service code.
ok
> I’ve just updated the sample Java service source code [3] to illustrate the proper way to set the result in a Java
> service (without setting all metadata informations already set by the ZOO-Kernel before invoking your service). Note that
> you should only override the value field of your output HashMap.
ok, that helped.
>> And will the same be always available in the input hashmaps? This
>> might be helpful to check on the inputs before processing?
>
> The HashMap of each inputs will contain the metadata informations defined in the ZCFG (as shown here [4]). This means that for each inputs provided in the request but not present in the ZCFG, you won’t have access to any metadata informations attached to the input.
>
> You can use the inRequest field in the input HashMap to know if a value was present in the request or not.
ok, thanks.
Andrea
>
>>
>> Thanks,
>> Andrea
>>
>
> I hope this helps.
>
> Best regards,
>
> [1] https://github.com/moovida/zoo-java-example-service/blob/master/ZooJavaMain/src/org/jgrasstools/ZooJavaWps.java#L9
> [2] http://www.zoo-project.org/trac/browser/trunk/zoo-project/zoo-services/hello-java/HelloJava.java#L31
> [3] http://www.zoo-project.org/trac/changeset/537
> [4] http://zoo-project.org/docs/services/howtos.html#inputs
>
>
>
> Gérald Fenoy
> http://wiki.osgeo.org/wiki/User:Djay
>
More information about the Zoo-discuss
mailing list