Working with jobs

Jobs are a central concept in Switch.  Using the Web Service SDK, we can submit, download, replace, lock and unlock, and push (i.e. move to a checkpoint’s connection(s)) jobs.

To send jobs through SOAP, Switch uses DIME, and all attachments must be stored in a zip archive.

The SubmitFile10 SOAP method takes a SubmitEntry and the file to submit. In the SubmitEntry, we specify the ID of the flow and submit point, as well as the job name and job origin:
  <soap:Body xmlns:butterfly="http://tempuri.org/butterfly.xsd">    
    <butterfly:SubmitFile10>
       <inEntry href="#id0"/>
       <inSubmitData href="CE0B4222945833ED125480C7C1D7F25D" xsi:type="xsd:base64Binary"/>    
    </butterfly:SubmitFile10>    
    <multiRef id="id0" soapenc:root="0"
    soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    xsi:type="butterfly:SubmitEntry" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
       <flowId>7</flowId>
       <submitPointId>1</submitPointId>
       <jobName>info.txt</jobName>
       <jobOrigin>/info.txt</jobOrigin>
       <metadataXmlStr/>    
    </multiRef>
  </soap:Body>    

Where CE0B4222945833ED125480C7C1D7F25D points to a DIME attachment of a zip file.

The response is a single, reserved string:
  <soap:Body xmlns:butterfly="http://tempuri.org/butterfly.xsd">    
    <butterfly:SubmitFile10Response>
       <outJobId/>    
    </butterfly:SubmitFile10Response>
  </soap:Body>  

Downloading or replacing a job is similar.

To push a job to a checkpoint’s connections, the PushCheckpointJob method is used.  This method requires the flow and checkpoint ID, the job ID, and the connection(s) to which to push the job.  To get the connection IDs, we use the GetCheckpointJobInfo call:
  <soapenv:Body xmlns:butterfly="http://tempuri.org/butterfly.xsd">    
    <butterfly:GetCheckpointJobInfo>
       <flowId>7</flowId>
       <checkPointId>4</checkPointId>
       <jobId>0006J</jobId>    
    </butterfly:GetCheckpointJobInfo>
  </soapenv:Body>  

The resulting JobStatus element contains the possible outgoing connections, e.g.:

  <soapenv:Body xmlns:butterfly="http://tempuri.org/butterfly.xsd">    
   <butterfly:GetCheckpointJobInfoResponse>
       <jobInfo>
         <jobAllowMultipleOutputs>false</jobAllowMultipleOutputs>
         <jobEnableReportViewing>false</jobEnableReportViewing>
         <jobAllowReplacingJob>false</jobAllowReplacingJob>
         <jobName>info.txt</jobName>
         <jobReportName/>
         <fullUserName>bens</fullUserName>
         <jobSize>52</jobSize>
         <jobSubmitTime>29.06.2011 15:57:18.967</jobSubmitTime>
         <jobWaitingTime>30.06.2011 17:29:14.456</jobWaitingTime>
         <connections>
           <connectionId>7</connectionId>
           <connectionName>Folder 2</connectionName>
         </connections>
         <jobRequiresMetadata>false</jobRequiresMetadata>
       </jobInfo>    
    </butterfly:GetCheckpointJobInfoResponse>
  </soap:Body>  

Now we can use these connection IDs to push the job:

  <soap:Body xmlns:butterfly="http://tempuri.org/butterfly.xsd">    
    <butterfly:PushCheckpointJob>
       <flowId>7</flowId>
       <checkPointId>4</checkPointId>
       <jobId>0006J</jobId>
       <jobInfo href="#id0"/>    
    </butterfly:PushCheckpointJob>    
        <multiRef id="id0" soapenc:root="0" 
       soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
       xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
         <metadataXmlStr/>
         <connectionIds>7</connectionIds>
         <jobName>info.txt</jobName>    
        </multiRef>
  </soap:Body>  

The response is a single, reserved integer:

  <soap:Body xmlns:butterfly="http://tempuri.org/butterfly.xsd">    
    <butterfly:PushCheckpointJobResponse>
       <param-5>0</param-5>    
    </butterfly:PushCheckpointJobResponse>
  </soap:Body>