[HelpOnLanguages] [TitleIndex] [WordIndex]

Use Case Scenario for Open Modeller Web Services API

This document describes a typical workflow using the OWSI in order to compose and execute a model on a remote OWSI server. See also OpenModeller Standard Web Services API The WSDL is available for your interest to be read in conjunction with this document.

Illustration

The following diagram is a useful reference for the discussion below. The original diagram is available in kivio format here : owsi_workflow_example.flw

Part 1: Model definition

Part 2: Model projection

Example program using soap bindings

/!\ Note: This example is still under construction:

#include <iostream>
#include "OpenModellerWrapperSoapBinding.nsmap"
#include "soapOpenModellerWrapperSoapBindingProxy.h"
int main(int argc, char *argv[])
{
  std::cout << "hello world\n";
  OpenModellerWrapperSoapBinding w;
  std::string request, result;
  //test the ping method
  std::cout << "calling pingModel" << std::endl;
  if (w.ns1__ping(result) == SOAP_OK)
  {
    std::cout << result << std::endl;
  }
  else
  {
    soap_print_fault(w.soap, stderr);
  }
  //test the create model method
  std::cout << "calling createModel" << std::endl;
  request = "dummy";
  if (w.ns1__createModel(request, result) == SOAP_OK)
  {
    std::cout << result << std::endl;
  }
  else
  {
    soap_print_fault(w.soap, stderr);
    return 0;
  }
  // poll the ws until the job is done
  std::cout << "calling getProgress until job is done" << std::endl;
  // result from createModel call should be the jobid that we are waiting on for completion
  std::string jobId = result;
  float progress=-999.0; //undefined state!

  //             undefined        queued      completed
  while (progress==-999.0 || progress==-1 || progress!=100)
  {
    if (w.ns1__getProgress(jobId, progress) == SOAP_OK)
    {
      std::cout << "Progress of Job " << jobId << " is " << progress  << std::endl;
    }
    else
    {
      soap_print_fault(w.soap, stderr);
      return 0;
    }
  }
  //get the log messages for this job
  std::cout << "calling getLog" << std::endl;
  if (w.ns1__getLog(jobId, result) == SOAP_OK)
  {
    std::cout << "Log of Job " << jobId << " is: " << std::endl;
    std::cout << "-----------------------------------------------" << std::endl;
    std::cout << result << std::endl;
    std::cout << "-----------------------------------------------" << std::endl;
  }
  else
  {
    soap_print_fault(w.soap, stderr);
    return 0;
  }
  //check if the model failed / or aborted
  if (progress=-2)
  {
     //model was aborted, so bail out
     std::cout << "Model was aborted on server, quitting....." << std::endl;
  }

  // now that the model is done, we can get the model result
  std::cout << "calling getModel" << std::endl;
  std::string model;
  if (w.ns1__getModel(jobId, model) == SOAP_OK)
  {
    std::cout << "Model of Job " << jobId << " is: " << std::endl;
    std::cout << "-----------------------------------------------" << std::endl;
    std::cout << model << std::endl;
    std::cout << "-----------------------------------------------" << std::endl;
  }
  else
  {
    soap_print_fault(w.soap, stderr);
    return 0;
  }

  //test the projtect model method
  std::cout << "calling projectModel " << std::endl;
  request = result;
  std::string envlayers = "<Environment></Environment>";
  if (w.ns1__projectModel(model, envlayers, jobId) == SOAP_OK)
  {
    std::cout << result << std::endl;
  }
  else
  {
    soap_print_fault(w.soap, stderr);
    return 0;
  }
  // poll the ws until the job is done
  // result from createModel call should be the jobid that we are waiting on for completion

  //             undefined        queued      completed
  while (progress==-999.0 || progress==-1 || progress!=100)
  {
    if (w.ns1__getProgress(jobId, progress) == SOAP_OK)
    {
      std::cout << "Progress of Job " << jobId << " is " << progress  << std::endl;
    }
    else
    {
      soap_print_fault(w.soap, stderr);
      return 0;
    }
  }
  //get the log messages for this job
  if (w.ns1__getLog(jobId, result) == SOAP_OK)
  {
    std::cout << "Log of Job " << jobId << " is: " << std::endl;
    std::cout << "-----------------------------------------------" << std::endl;
    std::cout << result << std::endl;
    std::cout << "-----------------------------------------------" << std::endl;
  }
  else
  {
    soap_print_fault(w.soap, stderr);
    return 0;
  }
  //check if the model failed / or aborted
  if (progress=-2)
  {
     //model was aborted, so bail out
     std::cout << "Model was aborted on server, quitting....." << std::endl;
  }


  return 0;

}


2014-08-13 10:46