Create a program for submitting batch work. The
following example demonstrates how to invoke the job scheduler web
services 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();
}
}