Hi everyone!
I need some help to build a client for geoserver wps…
Let me explain to you the whole context. I created a process that receives a common json string (CDATA) and… process it… (for now, it is just sending the json string back).
I could test the process using the WPS Request Builder interface, and it worked very fine =)
Now, I’m trying to develop a Javascript client to send a json string to this wps process and get the string back… but it’s not working =/
Here is what I’m doing:
var jsonDescription = JSON.stringify(array); //Parsing a javascript array to json string.
var wpsRequest = new WPSRequest(“http://localhost:8080/geoserver/wps”,“gs:MyProcess”,“execute”,“POST”,jsonDescription); //Object to define the request.
var wpsInput = wpsRequest.wpsInput(); //build the request using jsonDescription
wpsRequest.request(wpsInput); //Does the request…
Now, if you look inside my object:
//My object definition
function WPSRequest(url,process,processMethod, method, data){
this.urlRequest = url;
this.process = process;
this.processMethod = processMethod;
this.method = method;
this.data = data;
this.wpsInput = buildInput;
this.request = doRequest;
}
//function that does the request
function doRequest(input){
var urlreq = this.urlRequest;
var reqType = this.method;
alert(input);
$(function() {
//The request using jquery ajax:
$.ajax({
type: reqType, //POST
url: urlreq, //http://localhost:8080/geoserver/wps
data: input
}).done(function(result){
alert(result);
});
});
}
function buildInput(){
switch(this.processMethod){
case “execute”:
var wpsBody = “<?xml version=\"1.0\" encoding=\"UTF-8\"?>”
- “<wps:Execute version="1.0.0" service="WPS" xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance\](http://www.w3.org/2001/XMLSchema-instance\)” xmlns="[http://www.opengis.net/wps/1.0.0\](http://www.opengis.net/wps/1.0.0\)" xmlns:wfs="[http://www.opengis.net/wfs\](http://www.opengis.net/wfs\)" xmlns:wps="[http://www.opengis.net/wps/1.0.0\](http://www.opengis.net/wps/1.0.0\)" xmlns:ows="[http://www.opengis.net/ows/1.1\](http://www.opengis.net/ows/1.1\)" xmlns:gml="[http://www.opengis.net/gml\](http://www.opengis.net/gml\)" xmlns:ogc="[http://www.opengis.net/ogc\](http://www.opengis.net/ogc\)" xmlns:wcs="[http://www.opengis.net/wcs/1.1.1\](http://www.opengis.net/wcs/1.1.1\)" xmlns:xlink="[http://www.w3.org/1999/xlink\](http://www.w3.org/1999/xlink\)" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 [http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd\](http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd\)“>”
- “ows:Identifier” + this.process + “</ows:Identifier>”
- “wps:DataInputs”
- “wps:Input”
- “ows:IdentifierjsonDescription</ows:Identifier>”
- “wps:Data”
- “<wps:ComplexData mimeType="application/json"></wps:ComplexData>”
- “</wps:Data>”
- “</wps:Input>”
- “</wps:DataInputs>”
- “wps:ResponseForm”
- “wps:RawDataOutput”
- “ows:Identifierresult</ows:Identifier>”
- “</wps:RawDataOutput>”
- “</wps:ResponseForm>”
- “</wps:Execute>”;
wpsBody = this.data;
return wpsBody;
break;
}
} //End of WPSRequest obj
When executing, I get the following error:
org.geoserver.platform.ServiceException: Could not determine geoserver request from http request org.geoserver.platform.AdvancedDispatchFilter$AdvancedDispatchHttpRequest@anonymised.com
Some details:
If I copy and paste the result of “alert(input);” (doRequest function) in Geoserver WPS Request Builder, the request works fine!
If I just change the URL from:
http://localhost:8080/geoserver/wps
to
http://localhost:8080/geoserver/ows?service=WPS&version=1.0.0&request=Execute&Identifier=gs:MyProcess
in my object definition, the request seens to work, once the error is: “Parameter jsonDescription is missing but has min multiplicity > 0”
I belive the second URL is a GET request, and, once the param is not in URL, the error is expected… this happens even if I keep the ajax type param = POST
The question is: Am I missing some thing to get the post request to work??
If someone knows a simple example showing how to do some request like this, it will help!
My next step will be to define a simple javascript ajax function to post to url http://localhost:8080/geoserver/wps
Any help will be appreciated!
Thanks!
–
Rodrigo C. Antonialli
Campinas - SP - Brasil
LinkedIn: http://www.linkedin.com/in/rcaprofile
Contato: (19) 8136-2347
rcantonialli@anonymised.com
Skype: rc_antonialli