Fore Method Execution

Below is the example of using the ForeExec operation to execute the method implemented in the Fore unit or assembly. The request contains name of the method to be executed and moniker of the development environment object that contains method's implementation. The response contains method execution result.

SOAP request:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ForeExec xmlns="http://www.fsight.ru/PP.SOM.Som">
<tFore xmlns=" ">
  <id>S1!M!7360</id>
  </tFore>
<tArg xmlns=" ">
  <methodName>Sum</methodName>
<args>
<it>
  <k>1</k>
  <value>100</value>
  </it>
<it>
  <k>2</k>
  <value>200</value>
  </it>
  </args>
  </tArg>
  </ForeExec>
  </s:Body>
  </s:Envelope>

SOAP response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ForeExecResult xmlns="http://www.fsight.ru/PP.SOM.Som" xmlns:q1="http://www.fsight.ru/PP.SOM.Som" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <result xmlns=" ">300.000000</result>
  </ForeExecResult>
  </soapenv:Body>
  </soapenv:Envelope>

JSON request:

{
 "ForeExec" : 
  {
   "tFore" : 
    {
     "id" : "S1!M!7360"
    },
   "tArg" : 
    {
     "methodName" : "Sum",
     "args" : 
      {
       "it" : 
        [
          {
           "k" : "1",
           "value" : "100"
          },
          {
           "k" : "2",
           "value" : "200"
          }
        ]
      }
    }
  }
}

JSON response:

{
 "ForeExecResult" : 
  {
   "result" : "300.000000"
  }
}
public static ForeExecResult ExecMethod(MbId mb, string assmId, string methodName, OdArg[] methodArgs)
{
var somClient = new SomPortTypeClient(); //Proxy object for operation execution
//Operation execution parameters
var tExec = new ForeExec()
{
tArg = new ForeExecArg()
{
methodName = methodName,
args = methodArgs
},
//Moniker of development environment object with method implementation
tFore = new ForeId()
{
id = mb.id + "!" + FindObjectById(mb, assmId).k
}
};
//Execute method
var result = somClient.ForeExec(tExec);
return result;
}

See also:

ForeExec: Operation