Passing Objects as Parameter Values

Below is the example of using the ForeExec operation to execute method with passing repository objects as parameter values. The request contains name of the executed method and moniker of the development environment object containing method implementation. Parameter values contain repository connection monikers and a repository object. The executed method has the following syntax:

Method

The C# example uses the FindObjectById function, which code is given in the Getting Object Description by Its Identifier example.

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>WorkWithObject</methodName>
<args>
<it>
  <k>1</k>
  <value>S1!M</value>
  </it>
<it>
  <k>2</k>
  <value>S1!M!S!E1</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="" />
  </ForeExecResult>
  </soapenv:Body>
  </soapenv:Envelope>

JSON request:

{
 "ForeExec" : 
  {
   "tFore" : 
    {
     "id" : "S1!M!7360"
    },
   "tArg" : 
    {
     "methodName" : "WorkWithObject",
     "args" : 
      {
       "it" : 
        [
          {
           "k" : "1",
           "value" : "S1!M"
          },
          {
           "k" : "2",
           "value" : "S1!M!S!E1"
          }
        ]
      }
    }
  }
}

JSON response:

{
 "ForeExecResult" : 
  {
   "result" : ""
  }
}
public static ForeExecResult ExecMethodWithObject(MbId mb, string assmId, string methodName, string objMoniker)
{
var somClient = new SomPortTypeClient(); //Proxy object for operation execution
//Operation execution parameters
var tExec = new ForeExec()
{
tArg = new ForeExecArg()
{
methodName = methodName,
//Monikers as parameters values
args = new OdArg[2]
{
new OdArg(){ k = 1, value = mb.id },
new OdArg(){ k = 2, value = objMoniker }
}
},
//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