Esempio n. 1
0
  private String internal_call(String ws, String[] values) {
    logger.info("#" + index + "请求调用web service: " + ws);
    OWLValue output;
    try {
      mKB = OWLFactory.createKB();
      mKB.createOntology(null);
      Service service = mKB.readService(URI.create(ws));

      ValueMap<Input, OWLValue> inputs = new ValueMap<Input, OWLValue>();

      for (int i = 0; i < values.length; i++) {
        Input input = service.getProcess().getInputs().get(i);
        inputs.setValue(input, mKB.createDataValue(values[i]));
        logger.info("\t" + input.getLocalName() + "  :  " + values[i]);
      }

      ProcessExecutionEngine exec = OWLSFactory.createExecutionEngine();
      ValueMap<Output, OWLValue> outputs;
      outputs = exec.execute(service.getProcess(), inputs, mKB);

      output = outputs.getDataValue(service.getProcess().getOutput().getName());
      logger.info("Result : " + output);
      return output.toString();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (ExecutionException e) {
      e.printStackTrace();
    }
    return "";
  }
Esempio n. 2
0
  /**
   * Because the PipelineExecutor is synchronous, calling this method signals that the previous
   * PipelineExecutorJob has completed and 'pipelineJob' is the next one to perform.
   *
   * @param pipelineJob a new Job to execute (replacing the already-finished old Job).
   */
  public void setJob(PipelineExecutorJob pipelineJob) {
    job = pipelineJob;
    job.getJobStatus().setTotalServiceCount(job.getPipeline().size());

    if (job.getProvenanceLogging()) {
      pmlLogger = new PML2PipelineExecutionProvenanceLogger();
      provLogger = new PROVPipelineExecutionProvenanceLogger();

      String viskoQuery = job.getPipeline().getParentPipelineSet().getQuery().toString();
      pmlLogger.recordVisKoQuery(viskoQuery);
      provLogger.recordVisKoQuery(viskoQuery);
    }

    exec = OWLSFactory.createExecutionEngine();
    isScheduledForTermination = false;
  }
Esempio n. 3
0
  public void runTest() throws Exception {
    // create an OWL-S knowledge base
    final OWLKnowledgeBase kb = OWLFactory.createKB();

    // create an empty ontology in this KB
    ont = kb.createOntology(URIUtils.standardURI(baseURI));

    // create an execution engine
    final ProcessExecutionEngine exec = OWLSFactory.createExecutionEngine();

    // load two services
    final Service s1 = kb.readService(ExampleURIs.BOOK_FINDER_OWLS12);
    final Service s2 = kb.readService(ExampleURIs.BN_BOOK_PRICE_OWLS12);

    // put the services in a list
    final List<Service> services = new ArrayList<Service>();
    services.add(s1);
    services.add(s2);

    // create a new service as a sequence of the list
    final Service s = createSequenceService(services);

    // print the description of new service to standard output
    ont.write(System.out, baseURI);
    System.out.println();

    // get the process of the new service
    final Process process = s.getProcess();
    // initialize the input values to be empty
    ValueMap<Input, OWLValue> inputs = new ValueMap<Input, OWLValue>();
    // get the parameter using the local name
    inputs.setValue(process.getInputs().get(0), kb.createDataValue("City of Glass"));

    // execute the service
    System.out.print("Executing...");
    ValueMap<Output, OWLValue> outputs = exec.execute(process, inputs, kb);
    System.out.println("done");

    // get the output parameter using the index
    final OWLIndividual outValue = outputs.getIndividualValue(process.getOutput());

    // display the result
    System.out.println("Book Price = ");
    System.out.println(Utils.formatRDF(outValue.toRDF(true, true)));
    System.out.println();
  }
Esempio n. 4
0
  public RunService() {
    // create an execution engine
    exec = OWLSFactory.createExecutionEngine();

    // Attach a listener to the execution engine
    exec.addExecutionListener(
        new ProcessExecutionListener() {

          public void setCurrentExecuteService(Process p) {
            System.out.println("Start executing process " + p);
          }

          public void printMessage(String message) {}

          public void finishExecution(int retCode) {
            System.out.println(
                "Finished execution "
                    + ((retCode == ProcessExecutionListener.EXEC_ERROR)
                        ? "with errors"
                        : "successfully"));
          }
        });
  }
 public MessageMapList getOutputMap() {
   return OWLSFactory.createMessageMapList(getProperties(FLAServiceOnt.upnpOutputMapping));
 }