axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ow...@apache.org
Subject cvs commit: xml-axis-wsif/java/src/org/apache/wsif/providers/java WSIFOperation_Java.java
Date Tue, 25 Jun 2002 10:46:22 GMT
owenb       2002/06/25 03:46:22

  Modified:    java/src/org/apache/wsif/providers/ejb
                        WSIFOperation_EJB.java
               java/test/shop ShoppingCartTest.java
               java/src/org/apache/wsif/providers/java
                        WSIFOperation_Java.java
  Log:
  Fixed problem with correctly populating output message when in-out parameters are used
  
  Revision  Changes    Path
  1.5       +262 -157  xml-axis-wsif/java/src/org/apache/wsif/providers/ejb/WSIFOperation_EJB.java
  
  Index: WSIFOperation_EJB.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/ejb/WSIFOperation_EJB.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WSIFOperation_EJB.java	24 Jun 2002 13:11:20 -0000	1.4
  +++ WSIFOperation_EJB.java	25 Jun 2002 10:46:22 -0000	1.5
  @@ -73,20 +73,17 @@
   import javax.wsdl.BindingInput;
   import javax.wsdl.BindingOperation;
   import javax.wsdl.BindingOutput;
  -import javax.wsdl.Definition;
  +import javax.wsdl.Message;
   import javax.wsdl.Operation;
   import javax.wsdl.OperationType;
   import javax.wsdl.Part;
  -import javax.wsdl.Port;
   import javax.xml.namespace.QName;
   
   import org.apache.wsif.WSIFConstants;
   import org.apache.wsif.WSIFException;
   import org.apache.wsif.WSIFMessage;
  -import org.apache.wsif.WSIFMessageFactory;
   import org.apache.wsif.WSIFOperation;
   import org.apache.wsif.base.WSIFDefaultOperation;
  -import org.apache.wsif.base.WSIFServiceImpl;
   import org.apache.wsif.logging.MessageLogger;
   import org.apache.wsif.logging.Tr;
   import org.apache.wsif.wsdl.extensions.ejb.EJBOperation;
  @@ -101,8 +98,8 @@
    * @author Jeremy Hughes <hughesj@apache.org>
    */
   public class WSIFOperation_EJB
  -        extends WSIFDefaultOperation
  -        implements WSIFOperation {
  +    extends WSIFDefaultOperation
  +    implements WSIFOperation {
   
       protected javax.wsdl.Port fieldPortModel;
       protected WSIFPort_EJB fieldPort;
  @@ -111,7 +108,7 @@
       protected Method fieldMethod = null;
       protected Method[] fieldAllMethods = null;
       protected String[] fieldInParameterNames = null;
  -    protected Map fieldOutParameterNames = new HashMap();
  +    protected String[] fieldOutParameterNames = null;
       // key: position, value: name
   
       protected String fieldOutputMessageName = null;
  @@ -129,7 +126,10 @@
           String fieldFormatType;
           // Note: In Java fault messages contain only one part: the Java exception
   
  -        FaultMessageInfo(String messageName, String partName, String formatType) {
  +        FaultMessageInfo(
  +            String messageName,
  +            String partName,
  +            String formatType) {
               fieldMessageName = messageName;
               fieldPartName = partName;
               fieldFormatType = formatType;
  @@ -137,10 +137,10 @@
       }
   
       public WSIFOperation_EJB(
  -            javax.wsdl.Port portModel,
  -            BindingOperation bindingOperationModel,
  -            WSIFPort_EJB port)
  -            throws WSIFException {
  +        javax.wsdl.Port portModel,
  +        BindingOperation bindingOperationModel,
  +        WSIFPort_EJB port)
  +        throws WSIFException {
           Tr.entry(this, portModel, bindingOperationModel, port);
   
           fieldPortModel = portModel;
  @@ -149,7 +149,10 @@
   
           try {
               fieldEJBOperationModel =
  -                (EJBOperation) fieldBindingOperationModel.getExtensibilityElements().get(0);
  +                (EJBOperation) fieldBindingOperationModel
  +                    .getExtensibilityElements()
  +                    .get(
  +                    0);
           } catch (Exception e) {
               throw new WSIFException(
                   "Unable to resolve EJB binding for operation '"
  @@ -187,12 +190,16 @@
       public WSIFOperation_EJB copy() throws WSIFException {
           Tr.entry(this);
           WSIFOperation_EJB woe =
  -            new WSIFOperation_EJB(fieldPortModel, fieldBindingOperationModel, fieldPort);
  +            new WSIFOperation_EJB(
  +                fieldPortModel,
  +                fieldBindingOperationModel,
  +                fieldPort);
           Tr.exit(woe);
           return woe;
       }
   
  -    protected static Class getClassForName(String classname) throws WSIFException {
  +    protected static Class getClassForName(String classname)
  +        throws WSIFException {
           Class cls = null;
   
           if (classname == null) {
  @@ -220,14 +227,22 @@
                       cls = double.class;
                   } else {
                       cls =
  -                        Class.forName(classname, true, Thread.currentThread().getContextClassLoader());
  +                        Class.forName(
  +                            classname,
  +                            true,
  +                            Thread.currentThread().getContextClassLoader());
                   }
               } else {
                   cls =
  -                    Class.forName(classname, true, Thread.currentThread().getContextClassLoader());
  +                    Class.forName(
  +                        classname,
  +                        true,
  +                        Thread.currentThread().getContextClassLoader());
               }
           } catch (ClassNotFoundException ex) {
  -            throw new WSIFException("Could not instantiate class '" + classname + "'", ex);
  +            throw new WSIFException(
  +                "Could not instantiate class '" + classname + "'",
  +                ex);
           }
   
           return cls;
  @@ -265,7 +280,9 @@
                   Object formatType = fieldTypeMaps.get(part.getTypeName());
                   if (formatType == null) {
                       throw new WSIFException(
  -                        "formatType for typeName '" + part.getName() + "' not found in document");
  +                        "formatType for typeName '"
  +                            + part.getName()
  +                            + "' not found in document");
                   }
   
                   if (formatType instanceof Vector) {
  @@ -293,7 +310,8 @@
   
       protected String getInputMessageName() throws WSIFException {
           if (fieldInputMessageName == null) {
  -            BindingInput bindingInputModel = fieldBindingOperationModel.getBindingInput();
  +            BindingInput bindingInputModel =
  +                fieldBindingOperationModel.getBindingInput();
               if (bindingInputModel != null) {
                   fieldInputMessageName = bindingInputModel.getName();
               }
  @@ -331,7 +349,9 @@
                           continue;
                   } else {
                       if (retType != null && retClass != null) {
  -                        if (!((Class) retClass).getName().equals(retType.getName()))
  +                        if (!((Class) retClass)
  +                            .getName()
  +                            .equals(retType.getName()))
                               continue;
                       }
                   }
  @@ -354,7 +374,9 @@
                               break;
                           }
                       } else {
  -                        if (!((Class) obj).getName().equals(params[j].getName())) {
  +                        if (!((Class) obj)
  +                            .getName()
  +                            .equals(params[j].getName())) {
                               match = false;
                               break;
                           }
  @@ -389,7 +411,11 @@
   
           // Get the TypeMappings from the binding
           Iterator bindingIterator =
  -            this.fieldPortModel.getBinding().getExtensibilityElements().iterator();
  +            this
  +                .fieldPortModel
  +                .getBinding()
  +                .getExtensibilityElements()
  +                .iterator();
           while (bindingIterator.hasNext()) {
               try {
                   typeMapping = (TypeMapping) bindingIterator.next();
  @@ -435,14 +461,16 @@
           // so deal with null BindingInputs or BindingOutputs
           String inputName = null;
           try {
  -            inputName = this.fieldBindingOperationModel.getBindingInput().getName();
  +            inputName =
  +                this.fieldBindingOperationModel.getBindingInput().getName();
           } catch (NullPointerException e) {
               inputName = null;
           }
   
           String outputName = null;
           try {
  -            outputName = this.fieldBindingOperationModel.getBindingOutput().getName();
  +            outputName =
  +                this.fieldBindingOperationModel.getBindingOutput().getName();
           } catch (NullPointerException e) {
               outputName = null;
           }
  @@ -467,11 +495,13 @@
                   // A returnPart has been specified so check that this method has the correct
                   // return type
                   Part returnPart =
  -                    getOperation().getOutput().getMessage().getPart(returnPartString);
  +                    getOperation().getOutput().getMessage().getPart(
  +                        returnPartString);
   
                   // If there is no returnPart specified then not interested in return value
                   if (returnPart != null) {
  -                    Object obj = this.fieldTypeMaps.get(returnPart.getTypeName());
  +                    Object obj =
  +                        this.fieldTypeMaps.get(returnPart.getTypeName());
                       if (obj instanceof Vector) {
                           Vector v = (Vector) obj;
                           Vector argv = new Vector();
  @@ -483,13 +513,17 @@
                           methodReturnClass = argv;
                       } else {
                           methodReturnClass =
  -                            getClassForName((String) fieldTypeMaps.get(returnPart.getTypeName()));
  +                            getClassForName(
  +                                (String) fieldTypeMaps.get(
  +                                    returnPart.getTypeName()));
                       }
                   } else {
                       // If we get here then the return part specified on the java operation was not
                       // in the output message
                       throw new Exception(
  -                        "returnPart '" + returnPartString + "' was not in the output message");
  +                        "returnPart '"
  +                            + returnPartString
  +                            + "' was not in the output message");
                   }
               }
               // returnPart attribute was not present so return methodReturnClass as default null
  @@ -535,7 +569,8 @@
               string part names.
               */
               if (parameterOrder == null) {
  -                List partList = operation.getInput().getMessage().getOrderedParts(null);
  +                List partList =
  +                    operation.getInput().getMessage().getOrderedParts(null);
                   parameterOrder = new Vector();
                   Iterator partListIterator = partList.iterator();
                   while (partListIterator.hasNext()) {
  @@ -570,9 +605,12 @@
               Iterator parameterIterator = parameterOrder.iterator();
               while (parameterIterator.hasNext()) {
                   String param = (String) parameterIterator.next();
  -                Part part = (Part) operation.getInput().getMessage().getPart(param);
  +                Part part =
  +                    (Part) operation.getInput().getMessage().getPart(param);
                   if (part == null) {
  -                    part = (Part) operation.getOutput().getMessage().getPart(param);
  +                    part =
  +                        (Part) operation.getOutput().getMessage().getPart(
  +                            param);
                   }
                   if (part == null)
                       throw new Exception(
  @@ -594,7 +632,9 @@
                       }
                       argTypes.add(argv);
                   } else {
  -                    argTypes.add(getClassForName((String) this.fieldTypeMaps.get(partType)));
  +                    argTypes.add(
  +                        getClassForName(
  +                            (String) this.fieldTypeMaps.get(partType)));
                   }
   
               }
  @@ -612,15 +652,28 @@
               // Deal with output parts if operation is Request-Response
               if (operation.getStyle().equals(OperationType.REQUEST_RESPONSE)) {
                   argNames = new ArrayList();
  +                // Get the returnPart attribute if it exists
  +                String returnPart = fieldEJBOperationModel.getReturnPart();
  +                Message outputMessage = operation.getOutput().getMessage();
                   Iterator outputPartsIterator =
  -                    operation.getOutput().getMessage().getOrderedParts(null).iterator();
  +                    outputMessage.getOrderedParts(null).iterator();
                   while (outputPartsIterator.hasNext()) {
                       Part part = (Part) outputPartsIterator.next();
  -                    argNames.add((String) part.getName());
  +                    String partName = part.getName();
  +                    if (partName != null
  +                        && returnPart != null
  +                        && partName.equals(returnPart)) {
  +                        // Put return part first in the list
  +                        argNames.add(0, partName);
  +                    } else {
  +                        argNames.add((String) part.getName());
  +                    }
                   }
   
  +                // Populate an array of output message part names
  +                fieldOutParameterNames = new String[argNames.size()];
                   for (int i = 0; i < argNames.size(); i++) {
  -                    fieldOutParameterNames.put(Integer.toString(i), (String) argNames.get(i));
  +                    fieldOutParameterNames[i] = (String) argNames.get(i);
                   }
               }
           } catch (Exception ex) {
  @@ -637,7 +690,9 @@
       // Turns an array of arguments into a form compatible with a method
       // If they are compatible, the object array is populated
       // otherwise returns null
  -    protected Object[] getCompatibleArguments(Class[] parmTypes, Object[] args) {
  +    protected Object[] getCompatibleArguments(
  +        Class[] parmTypes,
  +        Object[] args) {
           // Go through each argument checking it's compatability with the method arg
           // creating a compatible set along the way.
           // In essence this just converts from String to Character when necessary
  @@ -748,43 +803,39 @@
   
               Object[] arguments = null;
               Object part = null;
  -            if ((fieldInParameterNames != null) && (fieldInParameterNames.length > 0)) {
  +            if ((fieldInParameterNames != null)
  +                && (fieldInParameterNames.length > 0)) {
                   arguments = new Object[fieldInParameterNames.length];
                   for (int i = 0; i < fieldInParameterNames.length; i++) {
  -                    part = input.getObjectPart(fieldInParameterNames[i]);
  -                    if (part != null) {
  +                    try {
  +                        part = input.getObjectPart(fieldInParameterNames[i]);
                           arguments[i] = part;
                           foundInputParameter = true;
  -                    } else {
  -                        String paramName = fieldInParameterNames[i];
  -                        Iterator partsIterator = input.getPartNames();
  -                        while (partsIterator.hasNext()) {
  -                            String partName = (String) partsIterator.next();
  -                            if (partName == null || paramName == null)
  -                                break;
  -                            if (partName.equals(paramName)) {
  -                                arguments[i] = null;
  -                                foundInputParameter = true;
  -                            }
  -                        }
  -                        if (!foundInputParameter) {
  -                            if (fieldOutParameterNames.size() > 0) {
  -                                String outParameterName = null;
  -                                for (int j = 1; j <= arguments.length; j++) {
  -                                    outParameterName = (String) fieldOutParameterNames.get(Integer.toString(j));
  -                                    if ((outParameterName != null)
  -                                        && (outParameterName.equals(fieldInParameterNames[i]))) {
  -                                        arguments[i] = (methods[0].getParameterTypes()[i]).newInstance();
  -                                        foundInputParameter = true;
  -                                        usedOutputParam = true;
  -                                    }
  +                    } catch (WSIFException e) {
  +                        if (fieldOutParameterNames.length > 0) {
  +                            String outParameterName = null;
  +                            for (int j = 0;
  +                                j < fieldOutParameterNames.length;
  +                                j++) {
  +                                outParameterName = fieldOutParameterNames[j];
  +                                if ((outParameterName != null)
  +                                    && (outParameterName
  +                                        .equals(fieldInParameterNames[i]))) {
  +                                    arguments[i] =
  +                                        (methods[0].getParameterTypes()[i])
  +                                            .newInstance();
  +                                    foundInputParameter = true;
  +                                    usedOutputParam = true;
                                   }
                               }
                           }
                       }
                       if (!foundInputParameter) {
                           throw new WSIFException(
  -                            this +" : Could not set input parameter '" + fieldInParameterNames[i] + "'");
  +                            this
  +                                + " : Could not set input parameter '"
  +                                + fieldInParameterNames[i]
  +                                + "'");
                       }
                   }
               }
  @@ -798,12 +849,17 @@
                       try {
                           // Get a set of arguments which are compatible with the ctor
                           Object[] compatibleArguments =
  -                            getCompatibleArguments(methods[a].getParameterTypes(), arguments);
  +                            getCompatibleArguments(
  +                                methods[a].getParameterTypes(),
  +                                arguments);
                           // If we didn't get any arguments then the parts aren't compatible with the ctor
                           if (compatibleArguments == null)
                               break;
                           // Parts are compatible so invoke the ctor with the compatible set
  -                        result = methods[a].invoke(fieldPort.getEjbHome(), compatibleArguments);
  +                        result =
  +                            methods[a].invoke(
  +                                fieldPort.getEjbHome(),
  +                                compatibleArguments);
                           fieldPort.setEjbObject((EJBObject) result);
                           fieldMethod = methods[a];
                           invokedOK = true;
  @@ -814,13 +870,18 @@
                       // Side effect: Initialize port's object reference 
                   } else {
                       if (usedOutputParam) {
  -                        for (int i = 0; i < fieldInParameterNames.length; i++) {
  +                        for (int i = 0;
  +                            i < fieldInParameterNames.length;
  +                            i++) {
                               String outParameterName = null;
  -                            for (int j = 1; j <= arguments.length; j++) {
  -                                outParameterName = (String) fieldOutParameterNames.get(Integer.toString(j));
  +                            for (int j = 0; j < fieldOutParameterNames.length; j++) {
  +                                outParameterName = fieldOutParameterNames[j];
                                   if ((outParameterName != null)
  -                                    && (outParameterName.equals(fieldInParameterNames[i]))) {
  -                                    arguments[i] = (methods[a].getParameterTypes()[i]).newInstance();
  +                                    && (outParameterName
  +                                        .equals(fieldInParameterNames[i]))) {
  +                                    arguments[i] =
  +                                        (methods[a].getParameterTypes()[i])
  +                                            .newInstance();
                                   }
                               }
                           }
  @@ -829,19 +890,25 @@
                       try {
                           // Get a set of arguments which are compatible with the ctor
                           Object[] compatibleArguments =
  -                            getCompatibleArguments(methods[a].getParameterTypes(), arguments);
  +                            getCompatibleArguments(
  +                                methods[a].getParameterTypes(),
  +                                arguments);
                           // If we didn't get any arguments then the parts aren't compatible with the ctor
                           if (compatibleArguments == null)
                               break;
                           // Parts are compatible so invoke the ctor with the compatible set
  -                        result = methods[a].invoke(fieldPort.getEjbObject(), compatibleArguments);
  +                        result =
  +                            methods[a].invoke(
  +                                fieldPort.getEjbObject(),
  +                                compatibleArguments);
                           invokedOK = true;
                           fieldMethod = methods[a];
   
                           String outParameterName = null;
  -                        if (fieldOutParameterNames.size() > 0) {
  +                        if (fieldOutParameterNames.length > 0) {
                               output.setName(getOutputMessageName());
  -                            outParameterName = (String) fieldOutParameterNames.get("0");
  +                            outParameterName =
  +                                (String) fieldOutParameterNames[0];
                               if (outParameterName != null) {
                                   output.setObjectPart(
                                       outParameterName,
  @@ -850,10 +917,27 @@
                               }
   
                               if (arguments != null) {
  -                                for (int i = 1; i <= arguments.length; i++) {
  -                                    outParameterName = (String) fieldOutParameterNames.get(Integer.toString(i));
  +                                for (int i = 1;
  +                                    i < fieldOutParameterNames.length;
  +                                    i++) {
  +                                    outParameterName =
  +                                        fieldOutParameterNames[i];
                                       if (outParameterName != null) {
  -                                        output.setObjectPart(outParameterName, arguments[i - 1]);
  +                                        try {
  +                                            for (int r = 0;
  +                                                r < fieldInParameterNames.length;
  +                                                r++) {
  +                                                if (outParameterName
  +                                                    .equals(fieldInParameterNames[r])) {
  +                                                    output.setObjectPart(
  +                                                        outParameterName,
  +                                                        arguments[r]);
  +                                                    break;
  +                                                }
  +                                            }
  +                                        } catch (WSIFException e) {
  +                                            //ignore
  +                                        }
                                       }
                                   }
                               }
  @@ -866,7 +950,9 @@
               }
               if (!invokedOK)
                   throw new WSIFException(
  -                    "Failed to invoke method '" + fieldEJBOperationModel.getMethodName() + "'");
  +                    "Failed to invoke method '"
  +                        + fieldEJBOperationModel.getMethodName()
  +                        + "'");
           } catch (InvocationTargetException ex) {
               Throwable invocationFault = ex.getTargetException();
               String className = invocationFault.getClass().getName();
  @@ -874,7 +960,8 @@
               FaultMessageInfo faultMessageInfo =
                   (FaultMessageInfo) faultMessageInfos.get(className);
   
  -            if ((faultMessageInfo != null) && (faultMessageInfo.fieldPartName != null)) {
  +            if ((faultMessageInfo != null)
  +                && (faultMessageInfo.fieldPartName != null)) {
                   // Found fault
                   Object faultPart = invocationFault;
                   // Should we use the class of the method signature here ?
  @@ -899,7 +986,9 @@
                               found = true;
                               Object faultPart = invocationFault;
                               // Should we use the class of the method signature here ?
  -                            fault.setObjectPart(faultMessageInfo.fieldPartName, faultPart);
  +                            fault.setObjectPart(
  +                                faultMessageInfo.fieldPartName,
  +                                faultPart);
                               fault.setName(faultMessageInfo.fieldMessageName);
                               operationSucceeded = false;
                           }
  @@ -910,21 +999,29 @@
                   if (!found) {
                       // Log message
                       MessageLogger messageLog =
  -                        MessageLogger.newMessageLogger("WSIF", "org.apache.wsif.catalog.Messages");
  +                        MessageLogger.newMessageLogger(
  +                            "WSIF",
  +                            "org.apache.wsif.catalog.Messages");
                       messageLog.message(
                           WSIFConstants.TYPE_ERROR,
                           "WSIF.0005E",
  -                        new Object[] { "EJB", fieldEJBOperationModel.getMethodName()});
  +                        new Object[] {
  +                            "EJB",
  +                            fieldEJBOperationModel.getMethodName()});
                       messageLog.destroy();
                       // End message
  -                    throw new WSIFException("Operation failed!", invocationFault);
  +                    throw new WSIFException(
  +                        "Operation failed!",
  +                        invocationFault);
                   }
               }
   
           } catch (Exception ex) {
               // Log message
               MessageLogger messageLog =
  -                MessageLogger.newMessageLogger("WSIF", "org.apache.wsif.catalog.Messages");
  +                MessageLogger.newMessageLogger(
  +                    "WSIF",
  +                    "org.apache.wsif.catalog.Messages");
               messageLog.message(
                   WSIFConstants.TYPE_ERROR,
                   "WSIF.0005E",
  @@ -933,7 +1030,10 @@
               // End message
   
               throw new WSIFException(
  -                this +" : Could not invoke '" + fieldEJBOperationModel.getMethodName() + "'",
  +                this
  +                    + " : Could not invoke '"
  +                    + fieldEJBOperationModel.getMethodName()
  +                    + "'",
                   ex);
           }
   
  @@ -941,7 +1041,8 @@
           return operationSucceeded;
       }
   
  -    public void executeInputOnlyOperation(WSIFMessage input) throws WSIFException {
  +    public void executeInputOnlyOperation(WSIFMessage input)
  +        throws WSIFException {
   
           Tr.entry(this, input);
   
  @@ -961,30 +1062,23 @@
   
               Object[] arguments = null;
               Object part = null;
  -            if ((fieldInParameterNames != null) && (fieldInParameterNames.length > 0)) {
  +            if ((fieldInParameterNames != null)
  +                && (fieldInParameterNames.length > 0)) {
                   arguments = new Object[fieldInParameterNames.length];
                   for (int i = 0; i < fieldInParameterNames.length; i++) {
  -                    part = input.getObjectPart(fieldInParameterNames[i]);
  -                    if (part != null) {
  +                    try {
  +                        part = input.getObjectPart(fieldInParameterNames[i]);
                           arguments[i] = part;
                           foundInputParameter = true;
  -                    } else {
  -                        String paramName = fieldInParameterNames[i];
  -                        Iterator partsIterator = input.getPartNames();
  -                        while (partsIterator.hasNext()) {
  -                            Object partName = (Object) partsIterator.next();
  -                            if (partName == null || paramName == null)
  -                                break;
  -                            if (partName.equals(paramName)) {
  -                                arguments[i] = part;
  -                                foundInputParameter = true;
  -                            }
  -                        }
  +                    } catch (WSIFException e) {
                       }
   
                       if (!foundInputParameter) {
                           throw new WSIFException(
  -                            this +" : Could not set input parameter '" + fieldInParameterNames[i] + "'");
  +                            this
  +                                + " : Could not set input parameter '"
  +                                + fieldInParameterNames[i]
  +                                + "'");
                       }
                   }
               }
  @@ -998,12 +1092,17 @@
                       try {
                           // Get a set of arguments which are compatible with the ctor
                           Object[] compatibleArguments =
  -                            getCompatibleArguments(methods[a].getParameterTypes(), arguments);
  +                            getCompatibleArguments(
  +                                methods[a].getParameterTypes(),
  +                                arguments);
                           // If we didn't get any arguments then the parts aren't compatible with the ctor
                           if (compatibleArguments == null)
                               break;
                           // Parts are compatible so invoke the ctor with the compatible set
  -                        result = methods[a].invoke(fieldPort.getEjbHome(), compatibleArguments);
  +                        result =
  +                            methods[a].invoke(
  +                                fieldPort.getEjbHome(),
  +                                compatibleArguments);
                           fieldPort.setEjbObject((EJBObject) result);
                           fieldMethod = methods[a];
                           invokedOK = true;
  @@ -1016,12 +1115,17 @@
                       try {
                           // Get a set of arguments which are compatible with the ctor
                           Object[] compatibleArguments =
  -                            getCompatibleArguments(methods[a].getParameterTypes(), arguments);
  +                            getCompatibleArguments(
  +                                methods[a].getParameterTypes(),
  +                                arguments);
                           // If we didn't get any arguments then the parts aren't compatible with the ctor
                           if (compatibleArguments == null)
                               break;
                           // Parts are compatible so invoke the ctor with the compatible set
  -                        result = methods[a].invoke(fieldPort.getEjbObject(), compatibleArguments);
  +                        result =
  +                            methods[a].invoke(
  +                                fieldPort.getEjbObject(),
  +                                compatibleArguments);
                           fieldMethod = methods[a];
                           invokedOK = true;
                           break;
  @@ -1032,11 +1136,15 @@
               }
               if (!invokedOK)
                   throw new WSIFException(
  -                    "Failed to invoke method '" + fieldEJBOperationModel.getMethodName() + "'");
  +                    "Failed to invoke method '"
  +                        + fieldEJBOperationModel.getMethodName()
  +                        + "'");
           } catch (InvocationTargetException ex) {
               // Log message
               MessageLogger messageLog =
  -                MessageLogger.newMessageLogger("WSIF", "org.apache.wsif.catalog.Messages");
  +                MessageLogger.newMessageLogger(
  +                    "WSIF",
  +                    "org.apache.wsif.catalog.Messages");
               messageLog.message(
                   WSIFConstants.TYPE_ERROR,
                   "WSIF.0005E",
  @@ -1053,7 +1161,9 @@
           } catch (Exception ex) {
               // Log message
               MessageLogger messageLog =
  -                MessageLogger.newMessageLogger("WSIF", "org.apache.wsif.catalog.Messages");
  +                MessageLogger.newMessageLogger(
  +                    "WSIF",
  +                    "org.apache.wsif.catalog.Messages");
               messageLog.message(
                   WSIFConstants.TYPE_ERROR,
                   "WSIF.0005E",
  @@ -1062,7 +1172,10 @@
               // End message
   
               throw new WSIFException(
  -                this +" : Could not invoke '" + fieldEJBOperationModel.getMethodName() + "'",
  +                this
  +                    + " : Could not invoke '"
  +                    + fieldEJBOperationModel.getMethodName()
  +                    + "'",
                   ex);
           }
   
  @@ -1079,18 +1192,18 @@
        * @return a WSIFMessage instance
        * @see WSIFOperation#createInputMessage(String)
        */
  -// defect 131672 and disable compiled msg support for now
  -//    public WSIFMessage createInputMessage(String name) {
  -//        Tr.entry(this, name);
  -//        Definition d = (fieldPort == null) ? null : fieldPort.getDefinition();
  -//        String ns = (d == null) ? "" : d.getTargetNamespace();
  -//        WSIFMessageFactory mf = WSIFServiceImpl.getMessageFactory();
  -//        WSIFMessage msg = mf.createMessage(ns, name + "Message");
  -//        if (msg != null)
  -//            msg.setName(name);
  -//        Tr.exit(msg);
  -//        return msg;
  -//    }
  +    // defect 131672 and disable compiled msg support for now
  +    //    public WSIFMessage createInputMessage(String name) {
  +    //        Tr.entry(this, name);
  +    //        Definition d = (fieldPort == null) ? null : fieldPort.getDefinition();
  +    //        String ns = (d == null) ? "" : d.getTargetNamespace();
  +    //        WSIFMessageFactory mf = WSIFServiceImpl.getMessageFactory();
  +    //        WSIFMessage msg = mf.createMessage(ns, name + "Message");
  +    //        if (msg != null)
  +    //            msg.setName(name);
  +    //        Tr.exit(msg);
  +    //        return msg;
  +    //    }
   
       /**
        * Creates a new input WSIFMessage. This overrides the 
  @@ -1102,18 +1215,18 @@
        * @return a WSIFMessage instance
        * @see WSIFOperation#createInputMessage(String)
        */
  -// defect 131672 and disable compiled msg support for now
  -//    public WSIFMessage createOutputMessage(String name) {
  -//        Tr.entry(this, name);
  -//        Definition d = (fieldPort == null) ? null : fieldPort.getDefinition();
  -//        String ns = (d == null) ? "" : d.getTargetNamespace();
  -//        WSIFMessageFactory mf = WSIFServiceImpl.getMessageFactory();
  -//        WSIFMessage msg = mf.createMessage(ns, name + "Message");
  -//        if (msg != null)
  -//            msg.setName(name);
  -//        Tr.exit(msg);
  -//        return msg;
  -//    }
  +    // defect 131672 and disable compiled msg support for now
  +    //    public WSIFMessage createOutputMessage(String name) {
  +    //        Tr.entry(this, name);
  +    //        Definition d = (fieldPort == null) ? null : fieldPort.getDefinition();
  +    //        String ns = (d == null) ? "" : d.getTargetNamespace();
  +    //        WSIFMessageFactory mf = WSIFServiceImpl.getMessageFactory();
  +    //        WSIFMessage msg = mf.createMessage(ns, name + "Message");
  +    //        if (msg != null)
  +    //            msg.setName(name);
  +    //        Tr.exit(msg);
  +    //        return msg;
  +    //    }
   
       public String deep() {
           String buff = "";
  @@ -1122,29 +1235,16 @@
               buff += "portModel:" + Tr.brief(fieldPortModel);
               buff += " wsifPort_EJB:" + fieldPort;
   
  -            buff += " bindingOperationModel:" + Tr.brief(fieldBindingOperationModel);
  +            buff += " bindingOperationModel:"
  +                + Tr.brief(fieldBindingOperationModel);
               buff += " EJBOperation:"
  -                + (fieldEJBOperationModel == null ? "null" : fieldEJBOperationModel.toString());
  -            buff += " method:" + (fieldMethod == null ? "null" : fieldMethod.toString());
  +                + (fieldEJBOperationModel == null
  +                    ? "null"
  +                    : fieldEJBOperationModel.toString());
  +            buff += " method:"
  +                + (fieldMethod == null ? "null" : fieldMethod.toString());
               buff += Tr.brief("inParameterNames", fieldInParameterNames);
  -
  -            if (fieldOutParameterNames == null) {
  -                buff += " outParameterNames:null";
  -            } else {
  -                buff += " outParameterNames: size:" + fieldOutParameterNames.size();
  -                Iterator it = fieldOutParameterNames.keySet().iterator();
  -                int i = 0;
  -                while (it.hasNext()) {
  -                    String key = (String) it.next();
  -                    buff += " outParameterNames["
  -                        + i
  -                        + "]:"
  -                        + key
  -                        + " "
  -                        + fieldOutParameterNames.get(key);
  -                    i++;
  -                }
  -            }
  +            buff += Tr.brief("outParameterNames", fieldOutParameterNames);
   
               buff += " outputMessageName:" + fieldOutputMessageName;
               buff += " inputMessageName:" + fieldInputMessageName;
  @@ -1175,7 +1275,12 @@
                   int i = 0;
                   while (it.hasNext()) {
                       QName key = (QName) it.next();
  -                    buff += " typeMaps[" + i + "]:" + key + " " + fieldTypeMaps.get(key);
  +                    buff += " typeMaps["
  +                        + i
  +                        + "]:"
  +                        + key
  +                        + " "
  +                        + fieldTypeMaps.get(key);
                       i++;
                   }
               }
  
  
  
  1.2       +18 -53    xml-axis-wsif/java/test/shop/ShoppingCartTest.java
  
  Index: ShoppingCartTest.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/shop/ShoppingCartTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ShoppingCartTest.java	6 Jun 2002 08:28:59 -0000	1.1
  +++ ShoppingCartTest.java	25 Jun 2002 10:46:22 -0000	1.2
  @@ -61,7 +61,10 @@
   import java.util.HashMap;
   import java.util.Iterator;
   
  +import junit.framework.Test;
   import junit.framework.TestCase;
  +import junit.framework.TestSuite;
  +
   import org.apache.wsif.WSIFMessage;
   import org.apache.wsif.WSIFOperation;
   import org.apache.wsif.WSIFPort;
  @@ -117,15 +120,13 @@
        * @param args an array of command-line arguments
        */
       public static void main(java.lang.String[] args) {
  +	   TestUtilities.startListeners();	
  +	   junit.textui.TestRunner.run (suite());
  +	   TestUtilities.stopListeners();
  +    }
   
  -        try {
  -            ShoppingCartTest ft = new ShoppingCartTest("ShoppingCartTest");
  -            ft.setUp();
  -            ft.testWSDL_Java();
  -            ft.testWSDL_EJB();
  -        } catch (Exception e) {
  -            e.printStackTrace();
  -        }
  +    public static Test suite() {
  +        return new TestSuite(ShoppingCartTest.class);
       }
   
       public ShoppingCartTest(String arg0) {
  @@ -166,14 +167,6 @@
       public void testWSDL_Java() throws Exception {
           debug("\n*** TEST JAVA BINDING ***");
   
  -        // Let WSIFServiceImpl use DynamicWSIFProvider_Java 
  -        //        WSIFServiceImpl.setDynamicWSIFProvider(
  -        //            "http://schemas.xmlsoap.org/wsdl/java/",
  -        //            new WSIFDynamicProvider_Java());
  -        //WSIFServiceImpl.addExtensionRegistry(new JavaExtensionRegistry());
  -        //WSIFServiceImpl.addExtensionRegistry(new FormatExtensionRegistry());
  -        //WSIFServiceImpl.addExtensionRegistry(new EJBExtensionRegistry());
  -
           WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
               WSIFService service =
                   factory
  @@ -255,7 +248,7 @@
           inputMessage.setObjectPart("itemNumber", tempString);
   
           item = new Item();
  -        inputMessage.setObjectPart("item", item);
  +        //inputMessage.setObjectPart("item", item);
   
           tempString = "Pocket calculator";
           inputMessage.setObjectPart("itemName", tempString);
  @@ -272,10 +265,8 @@
           assertTrue("addItem test failed", operationSucceeded);
   
           if (operationSucceeded) {
  -            assertEquals(
  -                "Item returned is not the one passed in!!",
  -                (String) outputMessage.getObjectPart("item"),
  -                "100123");
  +			assertTrue("Part is not an Item!!!",
  +				outputMessage.getObjectPart("item") instanceof Item);
               debug(outputMessage.getObjectPart("item"));
           } else {
               // Cannot get here since test would have already failed!
  @@ -441,14 +432,6 @@
   
           debug("\n*** TEST EJB BINDING ***");
   
  -        // Let WSIFServiceImpl use WSIFDynamicProvider_EJB
  -        //        WSIFServiceImpl.setDynamicWSIFProvider(
  -        //            "http://schemas.xmlsoap.org/wsdl/ejb/",
  -        //            new WSIFDynamicProvider_EJB());
  -        //WSIFServiceImpl.addExtensionRegistry(new JavaExtensionRegistry());
  -        //WSIFServiceImpl.addExtensionRegistry(new EJBExtensionRegistry());
  -        //WSIFServiceImpl.addExtensionRegistry(new FormatExtensionRegistry());
  -
           WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
               WSIFService service =
                   factory.getService(wsdlPath + "ShoppingCartAll.wsdl", // WSDL file
  @@ -677,14 +660,6 @@
       public void testWSDL_Java_InputOnly() throws Exception {
           debug("\n*** TEST INPUT ONLY OPERATION USING JAVA BINDING ***");
   
  -        // Let WSIFServiceImpl use DynamicWSIFProvider_Java 
  -        //        WSIFServiceImpl.setDynamicWSIFProvider(
  -        //            "http://schemas.xmlsoap.org/wsdl/java/",
  -        //            new WSIFDynamicProvider_Java());
  -        //WSIFServiceImpl.addExtensionRegistry(new JavaExtensionRegistry());
  -        //WSIFServiceImpl.addExtensionRegistry(new FormatExtensionRegistry());
  -        //WSIFServiceImpl.addExtensionRegistry(new EJBExtensionRegistry());
  -
           WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
               WSIFService service =
                   factory
  @@ -762,10 +737,9 @@
           assertTrue("addItem test failed", operationSucceeded);
   
           if (operationSucceeded) {
  -            assertEquals(
  -                "Item returned is not the one passed in!!",
  -                (String) outputMessage.getObjectPart("item"),
  -                "100123");
  +        	assertTrue(
  +                "addItemOperation (EJB) did not return an Item Object!!",
  +                outputMessage.getObjectPart("item") instanceof Item);
               debug(outputMessage.getObjectPart("item"));
               debug("Current total = " + outputMessage.getObjectPart("currentTotal"));
           } else {
  @@ -810,10 +784,9 @@
           assertTrue("addItem test failed", operationSucceeded);
   
           if (operationSucceeded) {
  -            assertEquals(
  -                "Item returned is not the one passed in!!",
  -                (String) outputMessage.getObjectPart("item"),
  -                "100123");
  +            assertTrue(
  +                "addItemOperation (EJB) did not return an Item Object!!",
  +                outputMessage.getObjectPart("item") instanceof Item);                
               debug(outputMessage.getObjectPart("item"));
               debug("Current total = " + outputMessage.getObjectPart("currentTotal"));
           } else {
  @@ -829,14 +802,6 @@
               return;
   
           debug("\n*** TEST INPUT ONLY OPERATION USING EJB BINDING ***");
  -
  -        // Let WSIFServiceImpl use WSIFDynamicProvider_EJB
  -        //       WSIFServiceImpl.setDynamicWSIFProvider(
  -        //           "http://schemas.xmlsoap.org/wsdl/ejb/",
  -        //           new WSIFDynamicProvider_EJB());
  -        //WSIFServiceImpl.addExtensionRegistry(new JavaExtensionRegistry());
  -        //WSIFServiceImpl.addExtensionRegistry(new EJBExtensionRegistry());
  -        //WSIFServiceImpl.addExtensionRegistry(new FormatExtensionRegistry());
   
           WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
               WSIFService service =
  
  
  
  1.5       +52 -71    xml-axis-wsif/java/src/org/apache/wsif/providers/java/WSIFOperation_Java.java
  
  Index: WSIFOperation_Java.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/java/WSIFOperation_Java.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WSIFOperation_Java.java	24 Jun 2002 13:11:18 -0000	1.4
  +++ WSIFOperation_Java.java	25 Jun 2002 10:46:22 -0000	1.5
  @@ -113,8 +113,7 @@
       protected Map fieldFaultMessageInfos = null;
       // key: class name, value: FaultMessageInfo instance
       
  -    protected Map fieldOutParameterNames = new HashMap();
  -    // key: position, value: name
  +    protected String[] fieldOutParameterNames = null;
       
       protected String fieldOutputMessageName = null;
       protected String fieldInputMessageName = null;
  @@ -662,15 +661,25 @@
               // Deal with output parts if operation is Request-Response
               if (operation.getStyle().equals(OperationType.REQUEST_RESPONSE)) {
                   argNames = new ArrayList();
  +                // Get the returnPart attribute if it exists
  +                String returnPart = fieldJavaOperationModel.getReturnPart();                
                   Iterator outputPartsIterator =
                       operation.getOutput().getMessage().getOrderedParts(null).iterator();
                   while (outputPartsIterator.hasNext()) {
                       Part part = (Part) outputPartsIterator.next();
  -                    argNames.add((String) part.getName());
  -                }
  +                    String partName = part.getName();
  +                    if (partName != null && returnPart != null && partName.equals(returnPart)) {
  +                    	// Put return part first in the list of output parts
  +                    	argNames.add(0, partName);
  +                    } else {                    
  +                        argNames.add((String) part.getName());
  +                    }
  +                }                               
   
  +                // Populate an array of output message part names
  +				fieldOutParameterNames = new String[argNames.size()];
                   for (int i = 0; i < argNames.size(); i++) {
  -                    fieldOutParameterNames.put(Integer.toString(i), (String) argNames.get(i));
  +                    fieldOutParameterNames[i] = (String) argNames.get(i);
                   }
               }
           } catch (Exception ex) {
  @@ -859,33 +868,24 @@
               if ((fieldInParameterNames != null) && (fieldInParameterNames.length > 0)) {
                   arguments = new Object[fieldInParameterNames.length];
                   for (int i = 0; i < fieldInParameterNames.length; i++) {
  -                    part = input.getObjectPart(fieldInParameterNames[i]);
  -                    if (part != null) {
  +                    try {
  +                        part = input.getObjectPart(fieldInParameterNames[i]);
                           arguments[i] = part;
                           foundInputParameter = true;
  -                    } else {
  -                        String paramName = fieldInParameterNames[i];
  -                        Iterator partsIterator = input.getPartNames();
  -                        while (partsIterator.hasNext()) {
  -                            String partName = (String) partsIterator.next();
  -                            if (partName == null || paramName == null)
  -                                break;
  -                            if (partName.equals(paramName)) {
  -                                arguments[i] = null;
  -                                foundInputParameter = true;
  -                            }
  -                        }
  -                        if (!foundInputParameter) {
  -                            if (fieldOutParameterNames.size() > 0) {
  -                                String outParameterName = null;
  -                                for (int j = 1; j <= arguments.length; j++) {
  -                                    outParameterName = (String) fieldOutParameterNames.get(Integer.toString(j));
  -                                    if ((outParameterName != null)
  -                                        && (outParameterName.equals(fieldInParameterNames[i]))) {
  -                                        arguments[i] = (methods[0].getParameterTypes()[i]).newInstance();
  -                                        foundInputParameter = true;
  -                                        usedOutputParam = true;
  -                                    }
  +                    } catch (WSIFException e) {
  +                        if (fieldOutParameterNames.length > 0) {
  +                            String outParameterName = null;
  +                            for (int j = 0; j < fieldOutParameterNames.length; j++) {
  +                                outParameterName =
  +                                    fieldOutParameterNames[j];
  +                                if ((outParameterName != null)
  +                                    && (outParameterName
  +                                        .equals(fieldInParameterNames[i]))) {
  +                                    arguments[i] =
  +                                        (methods[0].getParameterTypes()[i])
  +                                            .newInstance();
  +                                    foundInputParameter = true;
  +                                    usedOutputParam = true;
                                   }
                               }
                           }
  @@ -925,8 +925,8 @@
                           if (usedOutputParam) {
                               for (int i = 0; i < fieldInParameterNames.length; i++) {
                                   String outParameterName = null;
  -                                for (int j = 1; j <= arguments.length; j++) {
  -                                    outParameterName = (String) fieldOutParameterNames.get(Integer.toString(j));
  +                                for (int j = 0; j < fieldOutParameterNames.length; j++) {
  +                                    outParameterName = fieldOutParameterNames[j];
                                       if ((outParameterName != null)
                                           && (outParameterName.equals(fieldInParameterNames[i]))) {
                                           arguments[i] = (methods[a].getParameterTypes()[i]).newInstance();
  @@ -958,8 +958,8 @@
                           if (usedOutputParam) {
                               for (int i = 0; i < fieldInParameterNames.length; i++) {
                                   String outParameterName = null;
  -                                for (int j = 1; j <= arguments.length; j++) {
  -                                    outParameterName = (String) fieldOutParameterNames.get(Integer.toString(j));
  +                                for (int j = 0; j < fieldOutParameterNames.length; j++) {
  +                                    outParameterName = fieldOutParameterNames[j];
                                       if ((outParameterName != null)
                                           && (outParameterName.equals(fieldInParameterNames[i]))) {
                                           arguments[i] = (methods[a].getParameterTypes()[i]).newInstance();
  @@ -989,9 +989,9 @@
                   }
   
                   String outParameterName = null;
  -                if (fieldOutParameterNames.size() > 0) {
  +                if (fieldOutParameterNames.length > 0) {
                       output.setName(getOutputMessageName());
  -                    outParameterName = (String) fieldOutParameterNames.get("0");
  +                    outParameterName = (String) fieldOutParameterNames[0];
                       if (outParameterName != null) {
                           output.setObjectPart(
                               outParameterName,
  @@ -1000,10 +1000,19 @@
                       }
   
                       if (arguments != null) {
  -                        for (int i = 1; i <= arguments.length; i++) {
  -                            outParameterName = (String) fieldOutParameterNames.get(Integer.toString(i));
  +                        for (int i = 1; i < fieldOutParameterNames.length; i++) {
  +                            outParameterName = fieldOutParameterNames[i];
                               if (outParameterName != null) {
  -                                output.setObjectPart(outParameterName, arguments[i - 1]);
  +                            	try {
  +                            		for (int r = 0; r < fieldInParameterNames.length; r++) {
  +                            			if (outParameterName.equals(fieldInParameterNames[r])) {
  +                            				output.setObjectPart(outParameterName, arguments[r]);
  +                            				break;
  +                            			}
  +                            		}
  +                            	} catch (WSIFException e) {
  +                            		//ignore
  +                            	}
                               }
                           }
                       }
  @@ -1099,22 +1108,11 @@
               if ((fieldInParameterNames != null) && (fieldInParameterNames.length > 0)) {
                   arguments = new Object[fieldInParameterNames.length];
                   for (int i = 0; i < fieldInParameterNames.length; i++) {
  -                    part = input.getObjectPart(fieldInParameterNames[i]);
  -                    if (part != null) {
  +                   try {
  +                        part = input.getObjectPart(fieldInParameterNames[i]);
                           arguments[i] = part;
                           foundInputParameter = true;
  -                    } else {
  -                        String paramName = fieldInParameterNames[i];
  -                        Iterator partsIterator = input.getPartNames();
  -                        while (partsIterator.hasNext()) {
  -                            Object partName = (Object) partsIterator.next();
  -                            if (partName == null || paramName == null)
  -                                break;
  -                            if (partName.equals(paramName)) {
  -                                arguments[i] = part;
  -                                foundInputParameter = true;
  -                            }
  -                        }
  +                    } catch (WSIFException e) {
                       }
   
                       if (!foundInputParameter) {
  @@ -1289,24 +1287,7 @@
               buff += " constructor:" + fieldConstructor;
   
               buff += Tr.brief("inParameterNames", fieldInParameterNames);
  -
  -            if (fieldOutParameterNames == null) {
  -                buff += " outParameterNames:null";
  -            } else {
  -                buff += " outParameterNames: size:" + fieldOutParameterNames.size();
  -                Iterator it = fieldOutParameterNames.keySet().iterator();
  -                int i = 0;
  -                while (it.hasNext()) {
  -                    String key = (String) it.next();
  -                    buff += " outParameterNames["
  -                        + i
  -                        + "]:"
  -                        + key
  -                        + " "
  -                        + fieldOutParameterNames.get(key);
  -                    i++;
  -                }
  -            }
  +            buff += Tr.brief("outParameterNames", fieldOutParameterNames);          
   
               if (fieldFaultMessageInfos == null) {
                   buff += " faultMessageInfos:null";
  
  
  

Mime
View raw message