0

I made the zoo-client-demo WPS Client strictly according to the [ZOO WPS Client Documentation][1]. The only changes I made were that I changed the request type of GetCapabilities and DescribeProcess to 'GET' instead of 'POST' that was initially defined, the version number to 2.0.0, the Identifier name to 'AddPy' (a test process I wrote) and the debug flag to true. I have also added logging statements to track the flow of the code.

I am working on Windows 10 and am using IIS to run the WPS.

On checking the console (Chrome developer tools) I see the following: (... has been used hide multiple lines where the same error caused an issue; I can supply that later if needed)

first.js:52 execute called from first.js
first-app.js:54 Execute called from first-app.js
zoo.js:344 execute called in zoo.js
zoo.js:207 convertParams called in zoo.js
zoo.js:210 ======== Execute AddPy
zoo.js:211 {identifier: "AddPy", dataInputs: Array(2), dataOutputs: Array(1), type: "POST", success: ƒ, …}
zoo.js:227 zoo_request_params from convertParams of zoo.js
zoo.js:228 {request: "Execute", service: "WPS", version: "2.0.0", Identifier: "AddPy", DataInputs: Array(2), …}
zoo.js:230 has ResponseDocument false
zoo.js:234 has Mode false
zoo.js:247 convertParams returned zoo_request_params
value:
zoo.js:248 {request: "Execute", service: "WPS", version: "2.0.0", Identifier: "AddPy", DataInputs: Array(2), …}
zoo.js:369 request called in zoo.js
zoo.js:266 buildRequest called in zoo.js
zoo.js:269 ======== REQUEST method=POST
zoo.js:270 {request: "Execute", service: "WPS", version: "2.0.0", Identifier: "AddPy", DataInputs: Array(2), …}DataInputs: (2) [{…}, {…}]DataOutputs: [{…}]Identifier: "AddPy"language: "en-US"request: "Execute"service: "WPS"version: "2.0.0"__proto__: Object
wps-payload.js:81 getPayload called in wps-payload
wps-payload.js:212 getPayload_Execute called from wps-payload.js
wps-payload.js:285 ==== OUTPUTS ====
wps-payload.js:289 {identifier: "Sum", type: "resultDocument"}identifier: "Sum"is_resultDocument: truetype: "resultDocument"__proto__: Object
wps-payload.js:296 Returned templates[id].render(params)
value:
wps-payload.js:297 <wps:Execute
    xmlns:wps="http://www.opengis.net/wps/2.0"
    xmlns:ows="http://www.opengis.net/ows/2.0"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.opengis.net/wps/2.0 ../wps.xsd"

    service="WPS"
    version="2.0.0"
    response="document"
    mode="sync">

    <ows:Identifier>AddPy</ows:Identifier>
        <wps:Input id="first_number">
            <wps:Data>21</wps:Data>
        </wps:Input>
        <wps:Input id="second_number">
            <wps:Data>21</wps:Data>
        </wps:Input>
      <wps:Output id="Sum" transmission="value" />
</wps:Execute>
zoo.js:288 ======== POST PAYLOAD ========
zoo.js:289 <wps:Execute
    xmlns:wps="http://www.opengis.net/wps/2.0"
    xmlns:ows="http://www.opengis.net/ows/2.0"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.opengis.net/wps/2.0 ../wps.xsd"

    service="WPS"
    version="2.0.0"
    response="document"
    mode="sync">

    <ows:Identifier>AddPy</ows:Identifier>
        <wps:Input id="first_number">
            <wps:Data>21</wps:Data>
        </wps:Input>
        <wps:Input id="second_number">
            <wps:Data>21</wps:Data>
        </wps:Input>
      <wps:Output id="Sum" transmission="value" />
</wps:Execute>
zoo.js:290 {request: "Execute", service: "WPS", version: "2.0.0", Identifier: "AddPy", DataInputs: Array(2), …}
zoo.js:299 ajax url: http://localhost/cgi-bin/zoo_loader.cgi
zoo.js:301 buildRequest returned {"url":url,"headers": headers,"data": payload,"type":type}
values:
zoo.js:302 {url: "http://localhost/cgi-bin/zoo_loader.cgi", headers: {…}, data: "<wps:Execute↵  xmlns:wps="http://www.opengis.net/wp…t id="Sum" transmission="value" />↵</wps:Execute>", type: "POST"}
jquery-1.11.0.min.js:4 OPTIONS http://localhost/cgi-bin/zoo_loader.cgi 400 (Bad request)
send @ jquery-1.11.0.min.js:4
ajax @ jquery-1.11.0.min.js:4
ZooProcess.request @ zoo.js:374
ZooProcess.execute @ zoo.js:346
...
jquery-1.11.0.min.js:4 OPTIONS http://localhost/cgi-bin/zoo_loader.cgi 400 (Bad request)
send @ jquery-1.11.0.min.js:4
ajax @ jquery-1.11.0.min.js:4
ZooProcess.request @ zoo.js:374
ZooProcess.execute @ zoo.js:346
...
index.html:1 Failed to load http://localhost/cgi-bin/zoo_loader.cgi: Response for preflight has invalid HTTP status code 400.
zoo.js:377 ALWAYS
zoo.js:383 ======== ERROR ========
xml2json.min.js:1 Uncaught TypeError: Cannot read property 'nodeType' of undefined
    at w (xml2json.min.js:1)
    at X2JS.xml2json (xml2json.min.js:1)
    at Object.<anonymous> (zoo.js:385)
    at j (jquery-1.11.0.min.js:2)
    at Object.fireWith [as rejectWith] (jquery-1.11.0.min.js:2)
    at x (jquery-1.11.0.min.js:4)
    at XMLHttpRequest.b (jquery-1.11.0.min.js:4)
w @ xml2json.min.js:1
X2JS.xml2json @ xml2json.min.js:1
...

It seems that there is some error when the request type is set to 'POST' as I can only see the base URL (http://localhost/cgi-bin/zoo_loader.cgi) being sent in the error response.

Here is the code for my first.js (keeping only the relevant portions):

requirejs.config({
    baseUrl: 'assets/js',
    paths: {
        jquery: 'lib/jquery/jquery-1.11.0.min',
        hogan: 'lib/hogan/hogan-3.0.2',
        xml2json: 'lib/xml2json/xml2json.min',
        queryString: 'lib/query-string/query-string',
        wpsPayloads: 'lib/zoo/payloads',
        wpsPayload: 'lib/zoo/wps-payload',
        utils: 'lib/zoo/utils',
        zoo: 'lib/zoo/zoo',
        domReady: 'lib/domReady',
        app: 'first-app',
    },
    shim: {
        wpsPayloads: {
            deps: ['hogan'],
        },
        wpsPayload: {
            deps: ['wpsPayloads'],
            exports: 'wpsPayload',
        },
        hogan: {
            exports: 'Hogan',
        },
        xml2json: {
          exports: "X2JS",
        },
        queryString: {
            exports: 'queryString',
        },
    },
});

requirejs.config({
    config: {
        app: {
            url: 'http://localhost/cgi-bin/zoo_loader.cgi',
            delay: 2000,
        }
    }
});

require(['domReady', 'app'], function(domReady, app) {
    domReady(function() {
        console.log("execute called from first.js");
        app.execute();

    });
});

and here is the code for first-app.js (again, only the relevant portions):

define([
    'module','zoo','wpsPayload'
], function(module, ZooProcess, wpsPayload) {

    console.log("myZooObject initialized in first-app.js");
    var myZooObject = new ZooProcess(
        {
        url: module.config().url,
        delay: module.config().delay,
    });

    var execute_app = function() {
        console.log("Execute called from first-app.js");
        myZooObject.execute({
           identifier: "AddPy",
           dataInputs: [{"identifier":"first_number", "value":21},{"identifier":"second_number", "value":21}],
           dataOutputs: [{"identifier":"Sum","type":"resultDocument"}],
           type: 'POST',
           success: function(data) {
                console.log(data);
                console.log("Data returned by Execute of first-app.js");
           },
           error: function(data){
                console.log(data);
                console.log("ERROR returned by Execute of first-app.js!");
           }
        });
    }

    // Return public methods
    return {
        execute: execute_app,
    };
});

The code for the rest of the elements is the same as that provided by wps-client on following the documentation. Is there something that I missed or a possible workaround? I should add that I am not too sure if this is an error in code or in the server (IIS) configuration.

0

I found that I was trying to run the program by executing the HTML script by double-clicking it instead of typing the URL on the browser. Executing by typing the required URL seems to have corrected the error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.