Controlling web services without using the API

You can publish a document specification file remotely without using the API.

Use the WSDL file from http://server:port/rpe/services/RPEService?wsdl, to generate a top-down web service client application. The following sample code publishes a document specification file remotely without using the API:

StatusResponse statusResponse = null;
Integer serviceRunResponse;
RPEServiceStub stub = new RPEServiceStub(http://localhost:8080/rpe/services/RPEService?wsdl);
stub._getServiceClient().getOptions().setProperty(Constants.Configuratio
n.ENABLE_MTOM, Constants.VALUE_TRUE);
stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(10000);
RunReportFile request = (RunReportFile)
RunReportFile.class.newInstance();
AttachmentType attachment = new AttachmentType();
Base64Binary base64Binary = new Base64Binary();

File docSpecFile = new File("c:/docSpec.dsx");

FileDataSource fileDataSource = new FileDataSource(docSpecFile);
DataHandler dataHandler = new DataHandler(fileDataSource);
base64Binary.setBase64Binary(dataHandler);

ContentType_type0 param = new ContentType_type0();
param.setContentType_type0(dataHandler.getContentType());
base64Binary.setContentType(param);
attachment.setFileName(docSpecFile.toURI().toString());
attachment.setBinaryData(base64Binary);
request.setRunReportFile(attachment);
serviceRunResponse =
Integer.valueOf(stub.runReportFile(request).getRunReportFileResponse());

RPEServiceStub.GetStatus getStatus = (RPEServiceStub.GetStatus)
RPEServiceStub.GetStatus.class.newInstance();

	getStatus.setGetStatus(serviceRunResponse);
	statusResponse =
stub.getStatus(getStatus).getGetStatusResponse();

// 2 = "engine running" status
while ((statusResponse.getEngineStatus() == 2) ||
(!statusResponse.getMessage().equalsIgnoreCase("no message")))
{
	Thread.sleep(1000);
	if (!statusResponse.getMessage().equalsIgnoreCase("no message"))
	{
		System.out.println(statusResponse.getMessage());
	}

	statusResponse =
stub.getStatus(getStatus).getGetStatusResponse();
}

// 3 = "engine finnished" status
if (statusResponse.getEngineStatus() == 3)
{
	RPEServiceStub.GetOutput getOutput = (RPEServiceStub.GetOutput)
RPEServiceStub.GetOutput.class.newInstance();
	getOutput.setGetOutput(serviceRunResponse);

stub.getOutput(getOutput).getGetOutputResponse();

	URL url = new URL("http://localhost:8080/rpe/services/ RPEService?wsdl");

	String remoteResultPageURL = url.getProtocol() + "://" + url.getHost() + ":" + url.getPort() + "/rpe/DownloadPage?reportID=" + String.valueOf(serviceRunResponse);
	System.out.println("URL of the result page: " + remoteResultPageURL);

	String remoteResult = url.getProtocol() + "://" + url.getHost() + ":" + url.getPort() + "/rpe/DownloadFile?reportID=" + String.valueOf(serviceRunResponse);
	System.out.println("URL of the result archive: " + remoteResult);

}

Feedback