pw.println(" }");
pw.println(" org.apache.axis.client.Call _call = createCall();");
// loop over paramters and set up in/out params
for (int i = 0; i < parms.list.size(); ++i) {
Parameter p = (Parameter) parms.list.get(i);
String mimeType = p.getMIMEType();
// Get the QName representing the parameter type
QName paramType = Utils.getXSIType(p);
// Set the javaType to the name of the type
String javaType = null;
if (mimeType != null) {
javaType = "javax.activation.DataHandler.class, ";
}
else {
javaType = p.getType().getName();
if (javaType != null) {
javaType += ".class, ";
} else {
javaType = "";
}
}
// Get the text representing newing a QName for the name and type
String paramNameText = Utils.getNewQName(p.getQName());
String paramTypeText = Utils.getNewQName(paramType);
// Generate the addParameter call with the
// name qname, typeQName, optional javaType, and mode
if (p.getMode() == Parameter.IN) {
pw.println(" _call.addParameter(" + paramNameText + ", "
+ paramTypeText + ", "
+ javaType + "javax.xml.rpc.ParameterMode.IN);");
}
else if (p.getMode() == Parameter.INOUT) {
pw.println(" _call.addParameter(" + paramNameText + ", "
+ paramTypeText + ", "
+ javaType + "javax.xml.rpc.ParameterMode.INOUT);");
}
else { // p.getMode() == Parameter.OUT
pw.println(" _call.addParameter(" + paramNameText + ", "
+ paramTypeText + ", "
+ javaType + "javax.xml.rpc.ParameterMode.OUT);");
}
}
// set output type
if (parms.returnParam != null) {
// Get the QName for the return Type
QName returnName = Utils.getXSIType(parms.returnParam);
// Get the javaType
String javaType = null;
if (parms.returnParam.getMIMEType() != null) {
javaType = "javax.activation.DataHandler";
}
else {
javaType = parms.returnParam.getType().getName();
}
if (javaType == null) {
pw.println(" _call.setReturnType(" +
Utils.getNewQName(returnName) + ");");
} else {
pw.println(" _call.setReturnType(" +
Utils.getNewQName(returnName) +
", " + javaType + ".class);");
}
}
else {
pw.println(" _call.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID);");
}
// SoapAction
if (soapAction != null) {
pw.println(" _call.setUseSOAPAction(true);");
pw.println(" _call.setSOAPActionURI(\"" + soapAction + "\");");
}
boolean hasMIME = Utils.hasMIME(bEntry, operation);
// Encoding: literal or encoded use.
int use = bEntry.getInputBodyType(operation.getOperation());
if (use == BindingEntry.USE_LITERAL) {
// Turn off encoding
pw.println(" _call.setEncodingStyle(null);");
// turn off XSI types
pw.println(" _call.setScopedProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);");
}
if (hasMIME || use == BindingEntry.USE_LITERAL) {
// If it is literal, turn off multirefs.
//
// If there are any MIME types, turn off multirefs.
// I don't know enough about the guts to know why
// attachments don't work with multirefs, but they don't.
pw.println(" _call.setScopedProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);");
}
// Style: document, RPC, or wrapped
int style = bEntry.getBindingStyle();
String styleStr = "rpc";
if (style == BindingEntry.STYLE_DOCUMENT) {
if (symbolTable.isWrapped()) {
styleStr = "wrapped";
} else {
styleStr = "document";
}
}
if (!hasMIME) {
pw.println(" _call.setOperationStyle(\"" + styleStr + "\");");
}
// Operation name
if (styleStr.equals("wrapped")) {
// We need to make sure the operation name, which is what we
// wrap the elements in, matches the Qname of the parameter
// element.
Map partsMap = operation.getOperation().getInput().getMessage().getParts();
Part p = (Part)partsMap.values().iterator().next();
QName q = p.getElementName();
pw.println(" _call.setOperationName(new javax.xml.namespace.QName(\"" + q.getNamespaceURI() + "\", \"" + q.getLocalPart() + "\"));" );
} else {
QName elementQName = Utils.getOperationQName(operation);
if (elementQName != null) {
pw.println(" _call.setOperationName(" +
Utils.getNewQName(elementQName) + ");" );
}
}
// Invoke the operation
pw.println();
pw.print(" java.lang.Object _resp = _call.invoke(");
pw.print("new java.lang.Object[] {");
// Write the input and inout parameter list
boolean needComma = false;
for (int i = 0; i < parms.list.size(); ++i) {
Parameter p = (Parameter) parms.list.get(i);
if (p.getMode() != Parameter.OUT) {
if (needComma) {
pw.print(", ");
}
else {
needComma = true;
}
String javifiedName = Utils.xmlNameToJava(p.getName());
if (p.getMode() != Parameter.IN) {
javifiedName += ".value";
}
if (p.getMIMEType() == null) {
javifiedName = Utils.wrapPrimitiveType(
p.getType(), javifiedName);
}
pw.print(javifiedName);
}
}
pw.println("});");
pw.println();
pw.println(" if (_resp instanceof java.rmi.RemoteException) {");
pw.println(" throw (java.rmi.RemoteException)_resp;");
pw.println(" }");
int allOuts = parms.outputs + parms.inouts;
if (allOuts > 0) {
pw.println(" else {");
if (allOuts == 1) {
if (parms.returnParam != null) {
writeOutputAssign(pw, "return ", parms.returnParam.getType(),
parms.returnParam.getMIMEType(), "_resp");
}
else {
// The resp object must go into a holder
int i = 0;
Parameter p = (Parameter) parms.list.get(i);
while (p.getMode() == Parameter.IN) {
p = (Parameter) parms.list.get(++i);
}
String javifiedName = Utils.xmlNameToJava(p.getName());
String qnameName = Utils.getNewQName(p.getQName());
pw.println(" java.util.Map _output;");
pw.println(" _output = _call.getOutputParams();");
writeOutputAssign(pw, javifiedName + ".value = ",
p.getType(), p.getMIMEType(),
"_output.get(" + qnameName + ")");
}
}
else {
// There is more than 1 output. Get the outputs from getOutputParams.
pw.println(" java.util.Map _output;");
pw.println(" _output = _call.getOutputParams();");
for (int i = 0; i < parms.list.size (); ++i) {
Parameter p = (Parameter) parms.list.get (i);
String javifiedName = Utils.xmlNameToJava(p.getName());
String qnameName = Utils.getNewQName(p.getQName());
if (p.getMode() != Parameter.IN) {
writeOutputAssign(pw, javifiedName + ".value = ",
p.getType(), p.getMIMEType(),
"_output.get(" + qnameName + ")");
}
}
if (parms.returnParam != null) {
writeOutputAssign(pw, "return ", parms.returnParam.getType(),