"function with the name (or a function containing the operationNmae " +
"annotation as) " + operationName + " already exists. ");
}
//We always assume that our operations are inout operations
AxisOperation axisOperation = new InOutAxisOperation(new QName(operationName));
Boolean safe = annotationParser.isSafe();
if (safe != null) {
Parameter safeParameter = new Parameter(WSDL2Constants.ATTR_WSDLX_SAFE, safe);
axisOperation.addParameter(safeParameter);
}
String httpLocation = annotationParser.getHttpLocation();
/*
If the user did not specify a httpLocation default it to operationName
cause this is the default that axis2 uses
*/
if (httpLocation != null) {
if (!httpLocation.startsWith("{{") && httpLocation.startsWith("{")) {
/*
We cannot extract parameters off the URL in situations such as
foo.httpLocation="{param}"; Rather it should be
foo.httpLocation="bar/{param}";
*/
throw new DeploymentException(
"The httpLocation Annotation of operation " + operationName +
" is invalid. The httpLocation found was \"" + httpLocation +
"\". The httpLocation should not start with a parameter. " +
"Please include a constant part at the start of the templete.");
}
} else {
httpLocation = operationName;
}
String httpMethod = annotationParser.getHttpMethod();
if (httpMethod == null) {
/*
If no httpMethod is specified we look for the safely annotation. If an operation
is marked as safe then the httpMethod defaults to GET else its POST
*/
if (safe != null && safe) {
httpMethod = HTTPConstants.HEADER_GET;
} else {
httpMethod = HTTPConstants.HEADER_POST;
}
}
/*
Calculate the values for input and output actions according to
http://www.w3.org/TR/ws-addr-wsdl/#defactionwsdl20
*/
String inputAction = "urn:" + operationName;
String outAction = "urn:" + operationName + Java2WSDLConstants.RESPONSE;
axisOperation.setSoapAction(inputAction);
axisOperation.setOutputAction(outAction);
// Create a default SOAP 1.1 Binding operation
AxisBindingOperation soap11BindingOperation =
createDefaultSOAP11BindingOperation(axisOperation, httpLocation, inputAction);
// Create a default SOAP 1.2 Binding operation
AxisBindingOperation soap12BindingOperation =
createDefaultSOAP12BindingOperation(axisOperation, httpLocation, inputAction);
// Create a default HTTP Binding operation
AxisBindingOperation httpBindingOperation =
createDefaultHTTPBindingOperation(axisOperation, httpLocation, httpMethod,
annotationParser.isIgnoreUncited());
/*
We need to extract a constant value from the httpLocation so that the
httpLocationBasedDispatcher can use that value to dispatch to the correct operation
*/
String httpLocationString =
WSDLUtil.getConstantFromHTTPLocation(httpLocation, httpMethod);
httpLocationTable.put(httpLocationString, axisOperation);
/*
set the org.wso2.carbon.mashup.javascript.messagereceiver.JavaScriptReceiver as the
MessageReceiver for this operation
*/
axisOperation.setMessageReceiver(new JavaScriptReceiver());
axisOperation.setStyle(WSDLConstants.STYLE_DOC);
axisOperation.setDocumentation(annotationParser.getDocumentation());
/*
This is needed in case the user used the "operationName" annoatation. for e.g if the
following was used, the WSDL will show bar but when a request come in we should be
executing foo instead.
foo.operationName="bar";
function foo () {};
*/
Parameter jsFunctionNameParamter =
new Parameter(MashupConstants.JS_FUNCTION_NAME, originalMethodName);
axisOperation.addParameter(jsFunctionNameParamter);
String[] params = extractInputParameters(engine, originalMethodName);
// Create the in and out axis messages for this operation
AxisMessage inMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
if (inMessage != null) {
Object inputTypes = annotationParser.getInputTypesNameObject();
inMessage.setName(method + Java2WSDLConstants.MESSAGE_SUFFIX);
createAxisBindingMessage(soap11BindingOperation, inMessage,
WSDLConstants.MESSAGE_LABEL_IN_VALUE);
createAxisBindingMessage(soap12BindingOperation, inMessage,
WSDLConstants.MESSAGE_LABEL_IN_VALUE);
createAxisBindingMessage(httpBindingOperation, inMessage,
WSDLConstants.MESSAGE_LABEL_IN_VALUE);
/*
Generate the input element for the input message using the "inputTypes'
annotation specified by the user
*/
XmlSchemaElement element = schemaGenerator
.createInputElement(inMessage, inputTypes, operationName, params, method);
if (element != null) {
inMessage.setElementQName(new QName(schemaTargetNamespace, element.getName()));
}
}
AxisMessage outMessage =
axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
Object outputType = annotationParser.getOutputTypeNameObject();
//we always assume return parameter as "return"
params = new String[]{"return"};
if (outMessage != null) {