EagleML Web Service - Synchronous Request
Synchronous requests are usually used for data of small volume. To make a synchronous, request prepare a synchronous RunTaskRequest message and call the RunTaskRequestSync method.
The following GenerateSyncRunTaskRequest method should be added:
//create sync runtaskrequest message for making SMF extract
    private static eagleSvc.WSRunTaskRequest GenerateSyncRunTaskRequest()
    {
      //create WSRunTaskRequest object
      var runTaskRequest = new eagleSvc.WSRunTaskRequest();
      //create RunTaskRequest object
      var eagleML = new eagleSvc.RunTaskRequest();
      //create header section
      var header = new eagleSvc.RequestMessageHeader();
      //set messageId
      header.messageId = new eagleSvc.MessageId { Value = "ID:SYNCSMFEXTRACT01" };
      //set sendBy
      header.sentBy = new eagleSvc.MessageAddress { Value = "user" };
      //set sendTo , sendTo must be http://www.eagleinvsys.com/eagle_ml-2-0_default_cm_control_message
      header.sendTo = new eagleSvc.MessageAddress[1] { new eagleSvc.MessageAddress { Value = "http://www.eagleinvsys.com/eagle_ml-2-0_default_cm_control_message" } };
      //set timestamp
      header.creationTimestamp = DateTime.Now;
      eagleML.header = header;
      //create taskidentifier section
      var taskIdentifier = new eagleSvc.TaskIdentifier();
      //set correlationId, must be unique
      taskIdentifier.correlationId = new eagleSvc.CorrelationId { correlationIdScheme = "correlationIdScheme", Value = GenerateUID() };
      //set businessTaskId
      taskIdentifier.businessTaskId = new eagleSvc.CorrelationId { correlationIdScheme = "businessTaskIdScheme", Value = "SYNC_SMFIST_EXTRACT" };
      eagleML.taskIdentifier = taskIdentifier;
      //set TaskTypeEnum
      eagleML.taskTypeEnum = eagleSvc.TaskTypeEnum.LOAD;
      //create and set task parameters
      var taskParameters = new eagleSvc.TaskParameter[4];
      taskParameters[0] = new eagleSvc.TaskParameter { name = "ActionType", dataType = eagleSvc.DataTypeEnum.S, value = "EXTRACT" };
      taskParameters[1] = new eagleSvc.TaskParameter { name = "StreamName", dataType = eagleSvc.DataTypeEnum.S, value = "eagle_ml-2-0_default_out_q" };
      taskParameters[2] = new eagleSvc.TaskParameter { name = "FeedType", dataType = eagleSvc.DataTypeEnum.S, value = "SMFEXTRACT" };
      taskParameters[3] = new eagleSvc.TaskParameter { name = "fromdate", dataType = eagleSvc.DataTypeEnum.S, value = "2014-12-04 18-00-00" };
      eagleML.taskParameters = taskParameters;
      //set sync field to yes
      eagleML.synchronousExecution = "yes";
      runTaskRequest.EagleML = eagleML;
      return runTaskRequest;
    }
This method matches the method for an asynchronous request, only one parameter is added:
//set sync field to yes
      eagleML.synchronousExecution = "yes";
The synchronousExecution field should be set to Yes to make a synchronous request.
Next, perform an EagleML call:
eagleSvc.WSTaskStatusResponse resExtract = myClient.RunTaskRequestSync(runTaskRequest);
The result of execution is a WS TaskStatusResponse object:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:eag="http://www.eagleinvsys.com/2011/wsdl/EagleML-2-0" xmlns:eag1="http://www.eagleinvsys.com/2011/EagleML-2-0">
<soapenv:Header/>
<soapenv:Body>
<eag:taskStatusResponse>
<EagleML eaglemlVersion="2-0" Â eaglemlType="TaskStatusResponse" xsi:type="eag1:TaskStatusResponse" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<eag1:header>
<eag1:messageId>B50CLF84H5QQYATH</eag1:messageId>
<eag1:inReplyTo></eag1:inReplyTo>
<eag1:sentBy>http://www.eagleinvsys.com/</eag1:sentBy>
</eag1:header>
<eag1:statusItem>
<eag1:taskIdentifier>
<eag1:correlationId correlationIdScheme="correlationIdScheme">797A9631BA32792A</eag1:correlationId>
</eag1:taskIdentifier>
<eag1:status>SUCCESS</eag1:status>
<eag1:reason>
<eag1:reasonCode></eag1:reasonCode>
<eag1:description></eag1:description>
<eag1:additionalData>
<eag1:string><![CDATA[<EagleML
 eaglemlVersion="2-0"
 eaglemlType="ReferenceTransactionMessage"
 eaglemlRevision="185"
 xsi:schemaLocation="http://www.eagleinvsys.com/2011/EagleML-2-0 eagleml-main-2-0.xsd"
 xsi:type="ReferenceTransactionMessage"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.eagleinvsys.com/2011/EagleML-2-0">
<header>
<messageId>B50CLF84HESQFXNH</messageId>
<sentBy>http://www.eagleinvsys.com/</sentBy>
<creationTimestamp>2015-01-22T14:28:47-05:00</creationTimestamp>
</header>
<referenceTransaction>
<header>
<objectType>GenericSMF</objectType>
</header>
<genericSMF>
<objectType>GenericSMF</objectType>
<objectId>SMF</objectId>
<objectDescription>SMF</objectDescription>
…..
</genericSMF>
</referenceTransaction>
</EagleML>
]]></eag1:string>
</eag1:additionalData
><eag1:workflowState>
<eag1:processCorrelationId correlationIdScheme="correlationIdScheme">797A9631BA32792A</eag1:processCorrelationId>
</eag1:workflowState>
</eag1:reason>
</eag1:statusItem>
</EagleML>
</eag:taskStatusResponse>
</soapenv:Body>
</soapenv:Envelope>
EagleML GenericSMF document is put under the EaglML/statusItem/reason/additionalData/string element as raw text.
To deserialize raw text to object we should create a getExtractObject method.
//declare serializer for reuse
  private static XmlSerializer serializer;
//get SMF Generic EagleML object
    private static object getExtractObject(eagleSvc.WSTaskStatusResponse res) {
      //get raw data of extract from TSR
      if (res != null && res.EagleML != null && res.EagleML.statusItem != null && res.EagleML.statusItem.Length > 0)
      {
        if (res.EagleML.statusItem[0] != null && res.EagleML.statusItem[0].reason != null && res.EagleML.statusItem[0].reason.Length > 0)
        {
          eagleSvc.Reason reason = res.EagleML.statusItem[0].reason[0];
            if (reason != null && reason.additionalData != null && reason.additionalData.Length > 0 && reason.additionalData[0] != null)
            {
              string data = reason.additionalData[0].Item as string;
             Â
              if (serializer == null)
              {
                XmlAttributes attrs = new XmlAttributes();
                // Creates an XmlElementAttribute instance to override the
                // field that returns ReferenceObject object. The overridden field
                // returns Expanded object instead.
                XmlElementAttribute attr = new XmlElementAttribute();
                attr.ElementName = "genericSMF";
                attr.Type = typeof(eagleSvc.GenericSMF);
                // Adds the element to the collection of elements.
                attrs.XmlElements.Add(attr);
                // Creates the XmlAttributeOverrides instance.
                XmlAttributeOverrides attrOverrides = new XmlAttributeOverrides();
                // Adds the type of the class that contains the overridden
                // member, as well as the XmlAttributes instance to override it
                // with, to the XmlAttributeOverrides.
                attrOverrides.Add(typeof(eagleSvc.ReferenceTransaction), "ReferenceBaseObject", attrs);
                //*/
                // create serializer with some overrides including root tag rename(new XmlRootAttribute("EagleML"))
                serializer = new XmlSerializer(typeof(eagleSvc.EagleDocument), attrOverrides, null, new XmlRootAttribute("EagleML"), "http://www.eagleinvsys.com/2011/EagleML-2-0");
              }
              TextReader sr = new StringReader(data);
              //deserialize extract string to ReferenceTransactionMessage object
              object refTrMess = serializer.Deserialize(sr);
              return refTrMess;
            }
         Â
        }
      }
      return null;
    }
At first we get raw text and then we prepare an xmlSerializer, set necessary properties and overrides and execute the Deserialize method to create a SMF Generic EagleML document object.