1

大家好,我想将流程上传到 52 north wps Web 服务器,我的代码在此:(如(https://wiki.52north.org/bin/view/Processing/TutorialProcessDevelopmentKit))

package my.algorithm.sample;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.n52.wps.io.data.GenericFileData;
import org.n52.wps.io.data.IData;
import org.n52.wps.io.data.binding.complex.GenericFileDataBinding;
import org.n52.wps.server.AbstractSelfDescribingAlgorithm;

/*
 * This is a sample 52North WPS Process Class.
 * It inherits from AbstractSelfDescribingAlgorithm to automcatically create the     ProcessDescription document.
 */
   public class SampleProcess extends AbstractSelfDescribingAlgorithm{

/*
 * Method to retrieve the identifiers for the input data elements.
 * The ProcessDescription is automatically created with this data. 
 * 
 * @return List of input identifiers
 */
@Override
public List<String> getInputIdentifiers() {
    List<String> identifiers = new ArrayList<String>();
    identifiers.add("Layer1");
    return identifiers;
}

/*
 * Method to retrieve the identifiers for the output data elements.
 * The ProcessDescription is automatically created with this data. 
 * 
 * @return List of output identifiers
 */
@Override
public List<String> getOutputIdentifiers() {
    List<String> identifiers = new ArrayList<String>();
    identifiers.add("result");
    return identifiers;
}


/*
 * This method returns the Class of the accepted Inputdata format.
 * It is used to determine a suitable parser and automatically announce accepted datatypes for input data in the DescribeProcess response.
 * 
 * @param identifier Identifier of the Inputdata element (see ProcessDescription)
 * @return Class of the accepted Inputdata format based on the given identifier.
 */
@Override
public Class getInputDataType(String identifier) {
    if(identifier.equals("Layer1")){
        return GenericFileDataBinding.class;
    }
throw new RuntimeException("Error: Wrong identifier");
}

/*
 * This method returns the Class of the accepted Outputdata format.
 * It is used to determine a suitable generator and automatically announce provided datatypes for output data in the DescribeProcess response.
 * 
 * @param identifier Identifier of the Outputdata element (see ProcessDescription)
 * @return Class of the accepted Oututdata format based on the given identifier.
 */
@Override
public Class getOutputDataType(String identifier) {
    if(identifier.equals("result")){
            return GenericFileDataBinding.class;
    }
    throw new RuntimeException("Error: Wrong identifier");
}

/*
 * Main method to perform the processing.
 * All business logic shall go in this method.
 * 
 *    
 * @param inputMap Parsed inputdata identified by the identifiers provided in the getInputIdentifiers()  method and automatically announced in the DescribeProcess response
 * @return Map containing the output data as IData identified by the identifiers given in getOutputIdentifiers().
 */
@Override
public Map<String, IData> run(Map<String, List<IData>> inputMap) {
    //Get Input for the identifier "Layer1"
    List<IData> layer1List = inputMap.get("Layer1");
    //Check that actually data is delivered
    if(layer1List.size()==0){
        throw new RuntimeException("Invalid Input Parameters");
    }
    //take the first one. Note: There might be more.
    IData layer1 = layer1List.get(0);

    //Get the payload, which is the actual data used for processing. In this case a GenericFileData binding (Type can be looked up with method .getSupportedClass() or is known because of this.getInputDataType(...)
    GenericFileData inputData = (GenericFileData) layer1.getPayload();
    //do something with it e.g. extract the file
    File file = inputData.getBaseFile(false);

    //DO SOMETHING
    //...
    //DO SOMETHING

    //create the response. In this case a GenericFileDataBinding is used (see this.getOutputDataType(...)
    IData result = new GenericFileDataBinding(inputData);

    //new Map created
    Map<String, IData> resultMap = new HashMap<String, IData>();

    //created response added to corresponding identifier (see this.getOutputIdentifiers())
    resultMap.put("result", result);
    return resultMap;
}
}

运气喜欢(https://wiki.52north.org/bin/view/Processing/TutorialCustomJavaProcess)我浏览 sampleprocess.java 并输入包名称并点击提交按钮。之后,我通过 url 请求DescribeProcesshttp://localhost:8080/wps/WebProcessingService?Request=DescribeProcess&Service=WPS&IDENTIFIER=my.algorithm.sample.SampleProcess : 但此错误出现在浏览器上:

<ns:ExceptionReport xmlns:ns="http://www.opengis.net/ows/1.1">
<ns:Exception exceptionCode="InvalidParameterValue" locator="parameter: identifier |  value: r.surf.idw">
<ns:ExceptionText>Algorithm does not exist: my.algorithm.sample.SampleProcess</ns:ExceptionText>
</ns:Exception>
<ns:Exception exceptionCode="JAVA_StackTrace">
<ns:ExceptionText>
org.n52.wps.server.request.DescribeProcessRequest.call:157    org.n52.wps.server.handler.RequestHandler.handle:345    org.n52.wps.server.WebProcessingService.doGet:233  javax.servlet.http.HttpServlet.service:617  org.n52.wps.server.WebProcessingService.service:303  javax.servlet.http.HttpServlet.service:717  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter:290  org.apache.catalina.core.ApplicationFilterChain.doFilter:206  org.apache.catalina.core.StandardWrapperValve.invoke:233  org.apache.catalina.core.StandardContextValve.invoke:191  org.apache.catalina.core.StandardHostValve.invoke:127  org.apache.catalina.valves.ErrorReportValve.invoke:102  org.apache.catalina.core.StandardEngineValve.invoke:109  org.apache.catalina.connector.CoyoteAdapter.service:293  org.apache.coyote.http11.Http11Processor.process:859  org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process:602  org.apache.tomcat.util.net.JIoEndpoint$Worker.run:489 java.lang.Thread.run:-1
 </ns:ExceptionText>
 </ns:Exception>
<ns:Exception exceptionCode="JAVA_RootCause"/>
</ns:ExceptionReport>

请告诉我我该怎么办?

4

0 回答 0