Sure. Please let me know if you reach to a promising point;
On Fri, Aug 19, 2011 at 3:10 PM, Jody Garnett <jody.garnett@anonymised.com> wrote:
I am trying to document up process stuff; mind if I use your program as a
starting example?
--
Jody Garnett
On Friday, 19 August 2011 at 10:46 AM, Bahman Javadi wrote:
Hi
This is my WPS client in java with geotools:
----------------------------------
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import net.opengis.wps10.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.emf.common.util.EList;
import org.geotools.data.wps.WPSFactory;
import org.geotools.data.wps.WebProcessingService;
import org.geotools.data.wps.request.DescribeProcessRequest;
import org.geotools.data.wps.response.DescribeProcessResponse;
import org.geotools.ows.ServiceException;
import org.geotools.process.Process;
import org.geotools.process.ProcessException;
public class WPSClient {
/** The logger. */
private static final Log LOGGER = LogFactory.getLog(WPSClient.class);
static String PR1 = "gt:DoubleAddition";
static String PR2 = "";
static String SERVER =
"http://localhost:8080/geoserver/ows?service=wps&version=1.0.0&request=GetCapabilities";
// static String SERVER =
"http://localhost:8080/wps/WebProcessingService?Request=GetCapabilities&Service=WPS";
public static void main(String args){
System.out.println("WPS Client");
Map<String, String> r = getCapabilities();
}
/*
*
*/
public String getEndpoint() {
// return this.url + "/" + this.service + "/wps";
return " ";
}
// TODO get this method to work and replace getCapabilities() with this one.
public static Map<String, String> getCapabilities () {
//https://www2.landgate.wa.gov.au/ows/wfspublic_4283/wfs?service=wfs&version=1.0.0&request=GetCapabilities
// LOGGER.info("Getting Capabilities from endpoint - " + getEndpoint());
URL url = null;
try {
url = new URL(SERVER);
} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
WebProcessingService wps = null;
try {
wps = new WebProcessingService(url);
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
WPSCapabilitiesType capabilities = wps.getCapabilities();
String wpsCapabilitiesVersion = capabilities.getVersion();
System.out.println("WPS version: " + wpsCapabilitiesVersion);
// view a list of processes offered by the server
ProcessOfferingsType processOfferings =
capabilities.getProcessOfferings();
EList processes = processOfferings.getProcess();
System.out.println("Number of Processes:" + processes.size());
// create a WebProcessingService as shown above, then do a
full describe process on my process
DescribeProcessRequest descRequest = wps.createDescribeProcessRequest();
descRequest.setIdentifier(PR1); // describe the double addition
process
//
descRequest.setIdentifier("org.n52.wps.server.algorithm.SimpleBufferAlgorithm");
// send the request and get the ProcessDescriptionType bean to
create a WPSFactory
DescribeProcessResponse descResponse = null;
try {
descResponse = wps.issueRequest(descRequest);
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ProcessDescriptionsType processDesc = descResponse.getProcessDesc();
ProcessDescriptionType pdt = (ProcessDescriptionType)
processDesc.getProcessDescription().get(0);
WPSFactory wpsfactory = new WPSFactory(pdt, url);
// create a process
Process process = wpsfactory.create();
System.out.println("Process Descroption: "+ wpsfactory.getDescription());
// setup the inputs
Map<String, Object> map = new TreeMap<String, Object>();
Double d1 = 77.5;
Double d2 = 22.3;
map.put("input_a", d1);
map.put("input_b", d2);
// you could validate your inputs against what the process
expected by checking
// your map against the Parameters in wpsfactory.getParameterInfo(), but
// to keep this simple let's just try sending the request
without validation
Map<String, Object> results = null;
// ProgressListener
try {
results = process.execute(map, null);
} catch (ProcessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Double result = (Double) results.get("result");
System.out.println(result);
return null;
}
}
------------------------------------------
Please have a look.
Regards,
Bahman
On Thu, Aug 18, 2011 at 9:39 PM, Bahman Javadi <bahmanj@anonymised.com>
wrote:
Hi,
I am not sure about any changes in the WPS of the GeoServer. This is
my first try to work with GeoServer.
I used the same java code in the geotools website:
http://docs.geotools.org/latest/userguide/unsupported/wps.html
This client works for 52N and Deegree WPS servers. But has this
problem with GeoServer.
I also checked for other processes. It seems that the problem is with
LiteralData, where ComplexData
is ok. For example for Buffer which has one Double and one Geometry,
we got the error for Double number and Geometry is fine.
Thanks for your consideration.
Regards,
Bahman
On Thu, Aug 18, 2011 at 6:29 PM, Andrea Aime
<andrea.aime@anonymised.com> wrote:
On Thu, Aug 18, 2011 at 2:55 AM, Bahman Javadi
<bahmanj@anonymised.com> wrote:
Hi Andrea,
Thanks for your reply.
I installed Geoserver 2.1.1 and WPS-plugin 2.1.1 as well. But still I
have the same problem.
Any idea?
Is the output of DescribeProcess any different than before?
Do you happen to have a small, self contained java program
using the geotools library to connect to the WPS?
Cheers
Andrea
--
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf
-------------------------------------------------------
------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel
------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel