Examining the sample code

The Java sample source code contains two packages: com.enfocus.switchclientsdk.sample and com.enfocus.switchclientsdk.soapproxy.

The soapproxy package contains code that was generated using the Axis WSDL2Java tool. Using the butterfly.wsdl file as input, this tool generates any required Java classes to be able to communicate with the Switch Server over SOAP.

The sample package contains a single Main class, which contains the code of the Java sample. What follows is a list of the most important members of the Main class.

Member Description
Enfocus_ID A static String containing the Enfocus ID, which will be appended to the username when authenticating.
main() The program entry point. This function will parse the command-line parameters, create a new object of type Main, and start the application.
Main() The class constructor, which will check that the command-line parameters (which were parsed in the main() function) are valid.
run() The main application code: this function will establish and check the connection, check the username and password, and, after calling one of the functions below, close the connection. This uses the SOAP calls CheckConnect, CheckUserNameAndPass, and CloseConnection.
printSubmitPoints() Retrieves the list of submit points. This uses the SOAP calls GetFlowList, GetSubmitPoints, and GetSubmitPointName. The result, a list of submit points per flow, is formatted and printed to the console.
submitFile() Submits a job to the Switch Server. First, GetSubmitPointName is used to find out which metadata is required.  After filling the metadata, the job is zipped and sent to the Switch Server using SubmitFile10.
printCheckpoints() Retrieves the list of checkpoints. This uses the SOAP calls GetFlowList, GetFlowName, GetCheckPoints, and GetCheckPointName.  The result, a list of checkpoints per flow, is formatted and printed to the console.
printJobs() Retrieves the list of jobs present in a specific checkpoint. This uses GetCheckpointJobs10 to get the list of jobs, and GetCheckpointJobInfo to get information about each job (such as the connections to which it could be sent).
doJobAction() Pushes a checkpoint job to a specific connection. GetCheckpointJobInfo is used to get the list of possible connections, which is presented to the user.  After getting the required metadata, the job is sent to the selected connection using PushCheckpointJob.
replaceJob() Replaces a checkpoint job with the file chosen by the user and pushes the result to a specified connection. GetCheckpointJobInfo is used to get the list of possible connections and available metadata. After getting the required metadata, the new file replaces the original job and is sent to the selected connection using ReplaceFile.