+

Search Tips   |   Advanced Search

Submit batch jobs using the job scheduler web service interface

The job scheduler web service interface is used to programmatically submit and manipulate a batch job.

The job scheduler supports programmatic access to its functions over both an EJB interface for Java Platform, Enterprise Edition (Java EE) applications and a web service interface for both Java EE and non-Java EE applications. The Web Services Description Language (WSDL) describes the web service interface for the job scheduler.

Develop and install your batch applications.

This topic describes how to submit a batch job to the job scheduler. It includes a code example that demonstrates how to invoke the job scheduler web service interface.


Tasks

  1. Create a program for submitting batch work.

    The following example demonstrates how to invoke the job scheduler web service interface to submit a batch job.

    Some statements are split on multiple lines for printing purposes.

    import javax.xml.namespace.QName;
    	import javax.xml.rpc.Call;
    	import javax.xml.rpc.ParameterMode;
    	import javax.xml.rpc.Service;
    	import javax.xml.rpc.ServiceException;
    	import javax.xml.rpc.ServiceFactory;
    	import javax.xml.rpc.encoding.XMLType;
    
       	Call call = null;
    	String lrsHostName = "localhost";
    	String lrsPort = "9080";
    
    	private String readXJCL() throws FileNotFoundException, IOException {	
    		// Code to read xJCL file into a String
    	}
    
          public void submitJob() {
          	String endPoint = 
              "http://"+lrsHostName+":"+lrsPort+"/LongRunningJobSchedulerWebSvcRouter/
                services/JobScheduler";
          	try {
             		ServiceFactory serviceFactory = ServiceFactory.newInstance();
             		Service service = serviceFactory.createService(new 
                  QName("http://longrun.websphere.ibm.com", "JobSchedulerService"));
    
             		call = (Call) service.createCall();
          		call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, 
                "http://schemas.xmlsoap.org/soap/encoding/");
          		call.setProperty(Call.OPERATION_STYLE_PROPERTY, "wrapped");
          		call.setPortTypeName(new 
                QName("http://longrun.websphere.ibm.com", "JobSchedulerService"));
          		call.setTargetEndpointAddress(endPoint);     
          
          		//remove all parameters from call object
          		call.removeAllParameters();
          		call.setReturnType(XMLType.SOAP_STRING, null);
          		call.addParameter("arg", XMLType.SOAP_STRING, ParameterMode.IN);
          		call.setOperationName(new QName("http://longrun.websphere.ibm.com","submitJob"));
    
    			String xjcl = readXJCL(); // Method to read xJCL file into a string 
    
    	     		call.invoke(new Object[] {xjcl});
          	} catch (ServiceException se) {
          		System.out.println("Service Exception: " + se.getMessage());
          		se.printStackTrace();
          	} catch (java.rmi.RemoteException re) {
          		System.out.println("Remote Exception: " + re.getMessage());
          		re.printStackTrace();
          	}
          }
    

  2. Run the program to submit batch work.


Subtopics


Related:

  • Job logs
  • Submitting batch jobs using the job scheduler EJB interface