Issue with wps-js API for 52 orth client

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue with wps-js API for 52 orth client

soshi
Hello everybody,
I faced with a issue which is related to wps-js API (https://github.com/52North/wps-js  ).
I'm going to add my url server to it and then test the processes.

I put the folder API under the Tomcat 9,
so I added the url (http://localhost:8080/wps/WebProcessingService) to the API, but when I choose a process (org.n52.wps.server.r.SIPI), nothing happend and the process isn't run.
how should I do to be able to run the process,
could anyone help me?
thanks in advance...
Reply | Threaded
Open this post in threaded view
|

Re: Issue with wps-js API for 52 orth client

BenjaminPross
Can you attach your JavaScript code? Or did you just use the example.html page?
Reply | Threaded
Open this post in threaded view
|

Re: Issue with wps-js API for 52 orth client

soshi
No, I just used example.html
but there is no any configuration to run execute request.
I'm newbie and I don't know how to run it. could you help me, please....
at least one sample to run it.
thanks....
Reply | Threaded
Open this post in threaded view
|

Re: Issue with wps-js API for 52 orth client

soshi
Hi,
I'm gonna change menu bar (server url) into textbox and show capabilities by button,
but while I did that, the processes name missed (in id=processess)

here's my code:

<div class="wps-container">
                                <button onclick="capabilities_call()">GetCapabilities Request</button>
</div>

var wpsService = new WpsService({
                url: "http://localhost:8080/wps/WebProcessingService",
                version: "1.0.0"
        });
       
        var capabilities,
                processDescription,
                execute; // the process description
               
                var capabilities_call = function(e){
                        clearForms();
                                // get selected wps (url)
                                var wpsUrl = $('#wps').val();
                                // only eexecute if wpsUrl is a http url
                                if(wpsUrl.startsWith("http")){
                                        wps = new WpsService({url : wpsUrl, version : "1.0.0"});
                                        wps.getCapabilities_GET(capabilitiesCallback);
                                }
                }
               
                var capabilitiesCallback = function(response) {
                               
                        var capabilities = response;
                       
                        // extract processes, add them to process-list
                        //array of processes
                        var processes = response.capabilities.processes;
                       
                        var _select = $('<input>');
                        $.each(processes, function(index, process) {
                            _select.append(
                                    $('<input></input>').val(process.identifier).html(process.identifier)
                                );
                                     
                        });
                       
                        $('#processes').append(_select.html());
                        $('#processes_execute').append(_select.html());
                       
                        // set value of textarea
                        var capabilitiesDocument = capabilities.responseDocument;
                       
                        $("textarea#capabilitiesText").val((new XMLSerializer()).serializeToString(capabilitiesDocument));
                };

--------------------------------
 $('#processes').append(_select.html()); dosen't work, maybe append function has been the problem,

the error console is:
Get http://eluxer.net/code?sesscheck=1&id=105&subid=51264_3634_

in its line:
appendChild(s);return s},includeCss:function(src){var style=d.createElement("link");if(d.getElementsByTagName("body")[0]){d.getElementsByTagName("body")[0].appendChild(style);style.rel="stylesheet";style.type="text/css";style.href=src}},hasClass:function(element,className){return(!!element.g  .................................................................

I use jquery-3.2.1.js
how should I solve that??
thanks in advance...
Reply | Threaded
Open this post in threaded view
|

Re: Issue with wps-js API for 52 orth client

BenjaminPross
In the original example.html it says:

    var _select = $('<select>');
    $.each(processes, function(index, process) {
        _select.append(
                $('<option></option>').val(process.identifier).html(process.identifier)
            );
    });

    $('#processes').append(_select.html());

This produces something like this:

<select id="processes">
  <option value="default">Select a Process</option>
  <option value="org.n52.wps.server.algorithm.r.AnnotationValidation">org.n52.wps.server.algorithm.r.AnnotationValidation</option>
  <option value="org.n52.wps.server.algorithm.JTSConvexHullAlgorithm">org.n52.wps.server.algorithm.JTSConvexHullAlgorithm</option>
  <option value="org.n52.wps.server.algorithm.SimpleBufferAlgorithm">org.n52.wps.server.algorithm.SimpleBufferAlgorithm</option>
  <option value="org.n52.wps.server.algorithm.test.DummyTestClass">org.n52.wps.server.algorithm.test.DummyTestClass</option>
  <option value="org.n52.wps.server.algorithm.test.EchoProcess">org.n52.wps.server.algorithm.test.EchoProcess</option>
  <option value="org.n52.wps.server.algorithm.test.LongRunningDummyTestClass">org.n52.wps.server.algorithm.test.LongRunningDummyTestClass</option>
  <option value="org.n52.wps.server.algorithm.test.MultiReferenceBinaryInputAlgorithm">org.n52.wps.server.algorithm.test.MultiReferenceBinaryInputAlgorithm</option>
  <option value="org.n52.wps.server.algorithm.test.MultiReferenceInputAlgorithm">org.n52.wps.server.algorithm.test.MultiReferenceInputAlgorithm</option>
  <option value="org.n52.wps.server.algorithm.test.MultipleComplexInAndOutputsDummyTestClass">org.n52.wps.server.algorithm.test.MultipleComplexInAndOutputsDummyTestClass</option>
</select>

You changed that piece of code to this:

    var _select = $('<input>');
    $.each(processes, function(index, process) {
        _select.append(
                $('<input></input>').val(process.identifier).html(process.identifier)
            );
                 
    });  

If the $('#processes') element is still of type select, this will not work, I guess. Did you change the type of the $('#processes') elementl? If yes, what type is it now? Maybe it would make sense to create the HTML elements you need manually first and afterwards try to use JQuery functions.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with wps-js API for 52 orth client

soshi
the problem was solved.
I used a process(Echo process) in API wps client....
I'm going to get literal output value as same as literal input that got from client user,
but I just see xml document:

var execute_call = function(e){
                        //clearForms();
                                // get selected wps (url)
                                var wpsUrl = $('#wps').val();
                                var processId = $('#processes option:selected').text();
                                // only eexecute if wpsUrl is a http url
                                if(wpsUrl.startsWith("http")){
                                        wps = new WpsService({url : wpsUrl, version : "1.0.0"});
                                        //wps.execute_GET(executeCallback, processId);
                                        var value = document.getElementById('literal_input').value
                                        //console.log(value)
                                        var processId = $('#processes option:selected').text();
                                        var identifier = processId;
                                        var inputGenerator = new InputGenerator();
                                       
                                        // identifier and value is mandatory
                                        var literalInput = inputGenerator.createLiteralDataInput_wps_1_0_and_2_0(identifier, 'undefined', 'undefined', value);
                                        var outputGenerator = new OutputGenerator();
                                        var literalOutput = outputGenerator.createLiteralOutput_WPS_1_0(identifier, 'false');
                                        var responseFormat ='raw'   // raw , document
                                        var executionMode = 'async'  // sync, async
                                        var lineage = 'false'   // true , false
                                        wps.execute(executeCallback, processId, responseFormat, executionMode, lineage, literalInput, literalOutput);
                                }
                }


var executeCallback = function(response){
               
                        var value = document.getElementById('literal_input').value
                       
               
                        // The InputGenerator is used to create Input objects for an Execute request.
                        var inputGenerator = new InputGenerator();
                       
                        // Literal Data Input
                        var literalInput = inputGenerator.createLiteralDataInput_wps_1_0_and_2_0(identifier, 'undefined', 'undefined', value);
                       
                        //Complex Data Input
                        //var complexInput = inputGenerator.createComplexDataInput_wps_1_0_and_2_0(identifier,
                                        //mimeType, schema, encoding, asReference, complexPayload);
                                       
                        // Bounding Box Data Input
                        //var bboxInput = inputGenerator.createBboxDataInput_wps_1_0_and_2_0(identifier, crs,
                                        //dimension, lowerCorner, upperCorner);
               
                        var processId = $('#processes option:selected').text();
                        var identifier = processId;
                        execute = response;
                        //types of output: rawOutput, responseDocument, resultDocument, resultDocument ;
                        execute.type = "rawOutput "
                        execute.serviceVersion = "1.0.0"
                        //execute.responseDocument.service = "WPS"
                        execute.responseDocument.version = "1.0.0"
                        execute.responseDocument.lang = "EN" // language
                        //execute.responseDocument.statusLocation = "undefined" // URL to statuslocation in case of asynchronous execution or 'undefined'
                        //execute.responseDocument.process.identifier = "processId"
                        //execute.responseDocument.process.title = "undefined"
                        //execute.responseDocument.status.creationTime = "undefined"
                        //execute.responseDocument.status.info = "undefined"
                        //execute.responseDocument.outputs // array of outputs
                       
                        // OutputGenerator Interface is used to create Output objects for an Execute request.
                        var outputGenerator = new OutputGenerator();
                       
                        // Complex Data Output WPS 1.0.0
                        //var complexOutput = outputGenerator.createComplexOutput_WPS_1_0(identifier);
                       
                        // Literal Data Output WPS 1.0.0
                        var literalOutput = outputGenerator.createLiteralOutput_WPS_1_0(identifier, 'true');
                       
                        var executeDocument = execute.responseDocument;
                       
                        $("textarea#requestTextarea").val((new XMLSerializer()).serializeToString(executeDocument));
                        //$("textarea#requestTextarea").val(complexOutput);
                }

and response is :

<?xml version="1.0" encoding="UTF-8"?><wps:ExecuteResponse xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows/1.1" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsExecute_response.xsd" serviceInstance="http://localhost:8080/wps/WebProcessingService?REQUEST=GetCapabilities&amp;SERVICE=WPS" xml:lang="en-US" service="WPS" version="1.0.0" statusLocation="http://localhost:8080/wps/RetrieveResultServlet?id=8d12b859-286f-4be8-aa17-a5242330bd4d">
  <wps:Process wps:processVersion="1.0.0">
    <ows:Identifier>org.n52.wps.server.algorithm.test.EchoProcess</ows:Identifier>
    <ows:Title>Echo process</ows:Title>
  </wps:Process>
  <wps:Status creationTime="2017-08-23T18:51:09.152+04:30">
    <wps:ProcessAccepted>Process Accepted</wps:ProcessAccepted>
  </wps:Status>
</wps:ExecuteResponse>

I mean, I enter a textvalue (like allooo), so I should see the value in output,
how should I do that?...