Package org.apache.wsif

Examples of org.apache.wsif.WSIFException


    Trc.entry(this, input, handler);
    close();

    if (!fieldJmsPort.supportsAsync())
      throw new WSIFException("asynchronous operations not available");

    setAsyncOperation(true);
    WSIFCorrelationId correlId = null;

    try {

      getOperation();
      this.handler = handler;

      if (inputOnlyOp) {
        sendJmsMessage(input);
      } else {
        if (handler == null) {
          correlId = new WSIFJMSCorrelationId(sendJmsMessage(input));
        } else {
          WSIFCorrelationService cs =
            WSIFCorrelationServiceLocator.getCorrelationService();
          synchronized (cs) {
            correlId =
              new WSIFJMSCorrelationId(sendJmsMessage(input));
            //register it to the correlation service
            cs.put(correlId, this, asyncTimeout);
          }
        }
      }
    } catch (Exception ex) {
      Trc.exception(ex);

      // Log message
      MessageLogger.log(
        "WSIF.0005E",
        "Jms",
        fieldBindingOperation.getName());

      throw new WSIFException(
        this
          + " : Could not invoke '"
          + fieldBindingOperation.getName()
          + "'",
        ex);
View Full Code Here


      MessageLogger.log(
        "WSIF.0005E",
        "Jms",
        fieldBindingOperation.getName());

      throw new WSIFException(
        this
          + " : Could not invoke '"
          + fieldBindingOperation.getName()
          + "'",
        ex);
View Full Code Here

        serviceModel = s;
        break;
      }
    }
    if (serviceModel == null) {
      throw new WSIFException("cannot find service for port: " + port);
    }

    formatter = (JMSFormatter) fieldJmsPort.getFormatter();

    WSIFRequest request = new WSIFRequest(serviceModel.getQName());
View Full Code Here

    WSIFMessage fault)
    throws WSIFException {
    Trc.entry(this, responseObject, output, fault);

    if (!(responseObject instanceof javax.jms.Message))
      throw new WSIFException("Object is not of type javax.jms.Message");

        // The WSIFJMSDestination probably didn't receive this message, so
        // tell it about the message so we can inquire about its JMS properties
        // later.
        fieldJmsPort.getJmsDestination().setLastMessage(
View Full Code Here

      }
    }

    if (fieldOperation == null) {
      throw new WSIFException(
        "Unable to resolve Jms binding for operation '"
          + fieldBindingOperation.getName()
          + ":"
          + fieldInputMessageName
          + ":"
View Full Code Here

    }

    if (primitiveType != null)
      return primitiveType;
    else
      throw new WSIFException(
        "Unable to create the java object for XSD Type '"
          + type.toString()
          + "' using value '"
          + value
          + "'");
View Full Code Here

        try {
            fieldJavaOperationModel =
                (JavaOperation) fieldBindingOperationModel.getExtensibilityElements().get(0);
        } catch (Exception e) {
          Trc.exception(e);
            throw new WSIFException(
                "Unable to resolve Java binding for operation '"
                    + bindingOperationModel.getName()
                    + "'");
        }
View Full Code Here

      Trc.entry(null,classname);
     
        Class cls = null;

        if (classname == null) {
            throw new WSIFException("Error in getClassForName(): No class name specified!");
        }

        try {
            if (classname.lastIndexOf('.') == -1) {
                // Have to check for built in data types
                if (classname.equals("char")) {
                    cls = char.class;
                } else if (classname.equals("boolean")) {
                    cls = boolean.class;
                } else if (classname.equals("byte")) {
                    cls = byte.class;
                } else if (classname.equals("short")) {
                    cls = short.class;
                } else if (classname.equals("int")) {
                    cls = int.class;
                } else if (classname.equals("long")) {
                    cls = long.class;
                } else if (classname.equals("float")) {
                    cls = float.class;
                } else if (classname.equals("double")) {
                    cls = double.class;
                } else {
                    // Load the class using the Thread context's class loader
                    cls =
                        Class.forName(classname, true, Thread.currentThread().getContextClassLoader());
                }
            } else {
                cls =
                    Class.forName(classname, true, Thread.currentThread().getContextClassLoader());
            }
        } catch (ClassNotFoundException ex) {
          Trc.exception(ex);
            throw new WSIFException("Could not instantiate class '" + classname + "'", ex);
        }
        Trc.exit(cls);
        return cls;
    }
View Full Code Here

        } catch (WSIFException ex) {
          Trc.exception(ex);
            throw ex;
        } catch (Exception ex) {
          Trc.exception(ex);
            throw new WSIFException(
                "Error while resolving meta information of method "
                    + fieldJavaOperationModel.getMethodName()
                    + " : The meta information is not consistent.",
                ex);
        }
View Full Code Here

        try {
            Object result = null;
            // Need to get the stuff here because this also initializes fieldInParameterNames
            if (fieldIsConstructor) {
                if (fieldConstructors.length <= 0)
                    throw new WSIFException(
                        "No constructor found that match the parts specified");
            } else {
                if (fieldMethods.length <= 0)
                    throw new WSIFException("No method named '"
                        + fieldJavaOperationModel.getMethodName()
                        + "' found that match the parts specified");
            }

            Object[] arguments = null;
            Object part = null;
            if ((fieldInParameterNames != null) && (fieldInParameterNames.length > 0)) {
                arguments = new Object[fieldInParameterNames.length];
                for (int i = 0; i < fieldInParameterNames.length; i++) {
                    try {
                        part = input.getObjectPart(fieldInParameterNames[i]);
                        arguments[i] = part;
                    } catch (WSIFException e) {
                       Trc.exception(e);
                        arguments[i] = null;
                        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] =
                                        (fieldMethods[0].getParameterTypes()[i])
                                            .newInstance();
                                    usedOutputParam = true;
                                }
                            }
                        }
                    }
                }
            }

            boolean invokedOK = false;
            if (fieldIsConstructor) {
                for (int a = 0; a < fieldConstructors.length; a++) {
                    try {
                        // Get a set of arguments which are compatible with the ctor
                        Object[] compatibleArguments =
                            getCompatibleArguments(fieldConstructors[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

                        Trc.event(
                            this,
                            "Invoking constructor ",
                            fieldConstructors[a],
                            " with arguments ",
                            compatibleArguments);

                        result =
                            fieldConstructors[a].newInstance(
                                compatibleArguments);

                        Trc.event(
                            this,
                            "Returned from constructor, result is ",
                            result);
                       
                        fieldPort.setObjectReference(result);
                        invokedOK = true;
                        break;
                    } catch (IllegalArgumentException ia) {
                      Trc.ignoredException(ia);
                        // Ignore and try next constructor
                    }
                }
                if (!invokedOK)
                    throw new WSIFException("Failed to call constructor for object in Java operation");
                // Side effect: Initialize port's object reference
            } else {
                if (fieldIsStatic) {
                    for (int a = 0; a < fieldMethods.length; a++) {
                        if (usedOutputParam) {
                            for (int i = 0; i < fieldInParameterNames.length; i++) {
                                String outParameterName = null;
                                for (int j = 0; j < fieldOutParameterNames.length; j++) {
                                    outParameterName = fieldOutParameterNames[j];
                                    if ((outParameterName != null)
                                        && (outParameterName.equals(fieldInParameterNames[i]))) {
                                        arguments[i] = (fieldMethods[a].getParameterTypes()[i]).newInstance();
                                    }
                                }
                            }
                        }
                        try {
                            // Get a set of arguments which are compatible with the method
                            Object[] compatibleArguments =
                                getCompatibleArguments(fieldMethods[a].getParameterTypes(), arguments);
                            // If we didn't get any arguments then the parts aren't compatible with the method
                            if (compatibleArguments == null)
                                break;
                            // Parts are compatible so invoke the method with the compatible set

                            Trc.event(
                                this,
                                "Invoking method ",
                                fieldMethods[a],
                                " with arguments ",
                                compatibleArguments);

                            result =
                                fieldMethods[a].invoke(
                                    null,
                                    compatibleArguments);

                            Trc.event(
                                this,
                                "Returned from method, result is ",
                                result);

                            chosenMethod = fieldMethods[a];
                            invokedOK = true;
                            break;
                        } catch (IllegalArgumentException ia) {
                             Trc.ignoredException(ia);
                            // Ignore and try next method
                        }
                    }
                    if (!invokedOK)
                        throw new WSIFException(
                            "Failed to invoke method '" + fieldJavaOperationModel.getMethodName() + "'");
                } else {
                    for (int a = 0; a < fieldMethods.length; a++) {
                        if (usedOutputParam) {
                            for (int i = 0; i < fieldInParameterNames.length; i++) {
                                String outParameterName = null;
                                for (int j = 0; j < fieldOutParameterNames.length; j++) {
                                    outParameterName = fieldOutParameterNames[j];
                                    if ((outParameterName != null)
                                        && (outParameterName.equals(fieldInParameterNames[i]))) {
                                        arguments[i] = (fieldMethods[a].getParameterTypes()[i]).newInstance();
                                    }
                                }
                            }
                        }
                        try {
                            // Get a set of arguments which are compatible with the method
                            Object[] compatibleArguments =
                                getCompatibleArguments(fieldMethods[a].getParameterTypes(), arguments);
                            // If we didn't get any arguments then the parts aren't compatible with the method
                            if (compatibleArguments == null)
                                break;
                            // Parts are compatible so invoke the method with the compatible set

                            Object objRef = fieldPort.getObjectReference();
                            Trc.event(
                                this,
                                "Invoking object ",
                                objRef,
                                " method ",
                                fieldMethods[a],
                                " with arguments ",
                                compatibleArguments);

                            result =
                                fieldMethods[a].invoke(
                                    objRef,
                                    compatibleArguments);

                            Trc.event(
                                this,
                                "Returned from method, result is ",
                                result);

                            chosenMethod = fieldMethods[a];
                            invokedOK = true;
                            break;
                        } catch (IllegalArgumentException ia) {
                            Trc.ignoredException(ia);
                            // Ignore and try next method
                        }
                    }
                    if (!invokedOK)
                        throw new WSIFException(
                            "Failed to invoke method '" + fieldJavaOperationModel.getMethodName() + "'");
                }

                String outParameterName = null;
                if (fieldOutParameterNames != null && fieldOutParameterNames.length > 0) {
                    output.setName(getOutputMessageName());
                    outParameterName = (String) fieldOutParameterNames[0];
                    if (outParameterName != null) {
                        output.setObjectPart(
                            outParameterName,
                            getCompatibleReturn(chosenMethod, result));
                        // Should we use the class of the method signature instead here ?
                    }

                    if (arguments != null) {
                        for (int i = 1; i < fieldOutParameterNames.length; i++) {
                            outParameterName = fieldOutParameterNames[i];
                            if (outParameterName != null) {
                              try {
                                for (int r = 0; r < fieldInParameterNames.length; r++) {
                                  if (outParameterName.equals(fieldInParameterNames[r])) {
                                    output.setObjectPart(outParameterName, arguments[r]);
                                    break;
                                  }
                                }
                              } catch (WSIFException e) {
                                  Trc.ignoredException(e);
                                //ignore
                              }
                            }
                        }
                    }
                }
            }
        } catch (InvocationTargetException ex) {
          Trc.exception(ex);
            Throwable invocationFault = ex.getTargetException();
            String className = invocationFault.getClass().getName();
            Map faultMessageInfos = getFaultMessageInfos();
            FaultMessageInfo faultMessageInfo =
                (FaultMessageInfo) faultMessageInfos.get(className);
            if ((faultMessageInfo != null)
                && (faultMessageInfo.fieldPartName != null)) { // Found fault
                Object faultPart = invocationFault;
                // Should we use the class of the method signature here ?
                fault.setObjectPart(faultMessageInfo.fieldPartName, faultPart);
                fault.setName(faultMessageInfo.fieldMessageName);
                if (faultMessageInfo.fieldMessageName != null) {
                  Fault wsdlFault = fieldBindingOperationModel.getOperation().getFault(faultMessageInfo.fieldMessageName);
                  if (wsdlFault != null) {
                      fault.setMessageDefinition(wsdlFault.getMessage());
                  }
                }
                operationSucceeded = false;
            } else {
                // Try to find a matching class:
                Class invocationFaultClass = invocationFault.getClass();
                Class tempClass = null;
                Iterator it = faultMessageInfos.values().iterator();
                boolean found = false;
                while (it.hasNext()) {
                    faultMessageInfo = (FaultMessageInfo) it.next();
                    try {
                        tempClass =
                            Class.forName(
                                faultMessageInfo.fieldFormatType,
                                true,
                                Thread.currentThread().getContextClassLoader());
                        if (tempClass.isAssignableFrom(invocationFaultClass)) {
                            found = true;
                            Object faultPart = invocationFault;
                            // Should we use the class of the method signature here ?
                            fault.setObjectPart(faultMessageInfo.fieldPartName, faultPart);
                            fault.setName(faultMessageInfo.fieldMessageName);
                            if (faultMessageInfo.fieldMessageName != null) {
                              Fault wsdlFault = fieldBindingOperationModel.getOperation().getFault(faultMessageInfo.fieldMessageName);
                              if (wsdlFault != null) {
                                fault.setMessageDefinition(wsdlFault.getMessage());
                              }
                            }
                            operationSucceeded = false;
                        }
                    } catch (Exception exc) { // Nothing to do - just try the next one...
                      Trc.ignoredException(exc);
                    }
                }
                if (!found) {
                    throw new WSIFException("Operation failed!", invocationFault);
                }
            }
        } catch (Exception ex) {
            Trc.exception(ex);

            // Log message
            MessageLogger.log(
                "WSIF.0005E",
                "Java",
                fieldJavaOperationModel.getMethodName());

            throw new WSIFException(
                this
                    + " : Could not invoke '"
                    + fieldJavaOperationModel.getMethodName()
                    + "'",
                ex);
View Full Code Here

TOP

Related Classes of org.apache.wsif.WSIFException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.