package benchmark1.benchmarkws;
import java.io.*;
import java.util.List;
import java.util.Stack;
import java.util.ArrayList;
import com.dilanperera.rapidws.core.TypeHelper;
import com.dilanperera.rapidws.handlers.operation.ParameterExtractionResult;
import com.dilanperera.rapidws.handlers.operation.BaseOperationHandler;
/**
* Handles the 'ReceiveStrings' Web Service operation.
*/
public class ReceiveStringsOperationHandler extends BaseOperationHandler
{
// INSTANCE MEMBER VARIABLES - [standard contextual data]
/**
* The output of the operation.
*/
private String output = "";
/**
* Represents the stack describing the depth to which a parameter nests.
*/
private Stack nestingDepthStack = new Stack();
// INSTANCE MEMBER VARIABLES - [WS operation parameters]
/*
* Instance member variable representing parameter 'input' to the WS operation handled by this instance.
*/
private ArrayList<String> input = new ArrayList<String>();
/*
* Instance member variable representing parameter 'return' to the WS operation handled by this instance.
*/
private Integer __rws__returnValue;
// INSTANCE MEMBER VARIABLES - [WS parameter provision flags]
/*
* Instance member variable representing parameter flag 'input' to the WS operation handled by this instance.
*/
private boolean __rws__isInputNull = false;
/**
* Handles the operation.
*
* @param input the input to the operation.
* @return String the output of the operation.
* @throws Exception when an error occurs during the operation.
*/
protected final String handleOperation(String input) throws Exception
{
this.setInput(input);
// extract WS operation parameter data from SOAP request
this.deserializeInput();
// invoke WS operation
this.executeOperation();
// serialize output
this.serializeOutput();
return this.output;
}
/**
* Gets the return action.
*
* @return the return action.
*/
public String getReturnAction()
{
return "receiveStringsResponse";
}
/**
* Deserializes the input.
*
* @throws Exception when an error occurs during the operation.
*/
protected void deserializeInput() throws Exception
{
// reset positional pointer
this.resetCurrentPosition();
// read upto the first parameter
if (this.readToFirstParameter())
{
ParameterExtractionResult result = new ParameterExtractionResult();
// dummy to ensure searching commences
result.setExpectedParameterFound(true);
result = this.readPrimitiveParameterData("input", result);
if (result.wasExpectedParameterFound())
{
this.__rws__isInputNull = false;
if (!(result.isNil()))
{
this.input.add(String.valueOf(result.getParameterValue()));
}
while (true)
{
ParameterExtractionResult arrayResult = this.getNextArrayElement("input");
if (arrayResult.wasExpectedParameterFound())
{
if (!(arrayResult.isNil()))
{
this.input.add(String.valueOf(arrayResult.getParameterValue()));
}
}
else
{
break;
}
}
}
}
// reset positional pointer
this.resetCurrentPosition();
}
/**
* Executes the service operation.
*
* @throws Exception when an error occurs during the operation.
*/
protected void executeOperation() throws Exception
{
this.__rws__returnValue = new benchmark1.Benchmark1Impl().receiveStrings(
(this.__rws__isInputNull) ? null : TypeHelper.convert(input));
}
/**
* Serializes the output.
*
* @throws Exception when an error occurs during the operation.
*/
protected void serializeOutput() throws Exception
{
// build output
this.output += "<?xml version='1.0' encoding='UTF-8'?>";
this.output += "<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">";
this.output += "<soapenv:Body>";
this.output += "<ns:receiveStringsResponse xmlns:ns=\"http://benchmark1\">";
this.output += "<ns:return>" + this.__rws__returnValue.toString() + "</ns:return>";
this.output += "</ns:receiveStringsResponse>";
this.output += "</soapenv:Body>";
this.output += "</soapenv:Envelope>";
}
}