cvs commit: xml-axis-wsif/java/src/org/apache/wsif/base WSIFClientProxy.java

[email protected]
Newsgroups gmane.comp.apache.webservices.wsif.devel
Message-ID <[email protected]>
owenb       2003/06/11 05:26:44

  Modified:    java/src/org/apache/wsif/base WSIFClientProxy.java
  Log:
  Improvement to fault handling (bugzilla 18612) - if the fault message contains a throwable
  object and that throwable is declared on the SEI method, do not wrap it in a WSIFException
  simply throw it.
  
  Revision  Changes    Path
  1.22      +31 -23    xml-axis-wsif/java/src/org/apache/wsif/base/WSIFClientProxy.java
  
  Index: WSIFClientProxy.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/base/WSIFClientProxy.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- WSIFClientProxy.java	7 Mar 2003 14:59:30 -0000	1.21
  +++ WSIFClientProxy.java	11 Jun 2003 12:26:44 -0000	1.22
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2002 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2003 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -50,7 +50,7 @@
    * This software consists of voluntary contributions made by many
    * individuals on behalf of the Apache Software Foundation and was
    * originally based on software copyright (c) 2001, 2002, International
  - * Business Machines, Inc., http://www.apache.org.  For more
  + * Business Machines, Inc., http://www.ibm.com.  For more
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  @@ -230,15 +230,9 @@
   
       /**
        * Invoke a user method. The java proxy support calls this method.
  -     * 
  -     * The fault from the fault message is not passed back to caller 
  -     * (but it should be). However none of the existing providers set 
  -     * the fault message. I'm not sure what to do with the fault message
  -     * anyhow. I guess raise a WSIFException which is what the current
  -     * providers do with faults already.
        */
       public Object invoke(Object proxy, Method method, Object[] args)
  -        throws WSIFException {
  +        throws Throwable {
           Trc.entry(this, method, args); // Tracing proxy cause a hang
   
           Operation operation = findMatchingOperation(method, args);
  @@ -286,11 +280,13 @@
           }
   
           boolean usingwrapped = false;
  -        List inputParts = (inputMessage == null) 
  -           ? new ArrayList() 
  -           : inputMessage.getOrderedParts(null);
  +        List inputParts =
  +            (inputMessage == null)
  +                ? new ArrayList()
  +                : inputMessage.getOrderedParts(null);
           if (args != null) {
  -        	usingwrapped = unWrapIfRequired(operation.getName(), inputParts, args);
  +            usingwrapped =
  +                unWrapIfRequired(operation.getName(), inputParts, args);
               Iterator partIt = inputParts.iterator();
               for (int argIndex = 0; partIt.hasNext(); argIndex++) {
                   Part part = (Part) partIt.next();
  @@ -308,15 +304,25 @@
                       wsifOutputMessage,
                       wsifFaultMessage);
               if (!success) {
  -                StringBuffer sb = new StringBuffer();
  -                Iterator it = wsifFaultMessage.getPartNames();
  +                Iterator it = wsifFaultMessage.getParts();
                   while (it.hasNext()) {
  -                    String name = (String) it.next();
  -                    sb.append(name).append(":").append(
  -                        wsifFaultMessage.getObjectPart(name)).append(
  -                        " ");
  +                    Object fault = it.next();
  +                    if (fault instanceof Throwable) {
  +                        Class[] exs = method.getExceptionTypes();
  +                        for (int e = 0; e < exs.length; e++) {
  +                            if (exs[e].isAssignableFrom(fault.getClass())) {
  +                                throw (Throwable) fault;
  +                            }
  +                        }
  +                        throw new WSIFException("Operation failed, fault message contains a non-declared throwable", 
  +                            (Throwable) fault);
  +                    } else {
  +                        throw new WSIFException(
  +                            "Operation failed and a non-throwable fault message part was returned: "
  +                                + fault);
  +                    }
                   }
  -                throw new WSIFException(sb.toString());
  +                throw new WSIFException("Operation failed but returned fault message contained no part");
               }
           }
   
  @@ -326,8 +332,8 @@
               List outputParts = outputMessage.getOrderedParts(null);
               if (outputParts != null && outputParts.size() > 0) {
                   if (usingwrapped || isWrappedInContext()) {
  -                	unwrap(operation.getName()+"Response", outputParts);
  -                } 
  +                    unwrap(operation.getName() + "Response", outputParts);
  +                }
   
                   // The return value is always the first output part
                   Iterator outPartIt = outputParts.iterator();
  @@ -341,7 +347,9 @@
                           inputMessage.getOrderedParts(null).toArray();
                       Part nextOutPart = (Part) outPartIt.next();
   
  -                    for (int argIndex = 0; argIndex < args.length; argIndex++) {
  +                    for (int argIndex = 0;
  +                        argIndex < args.length;
  +                        argIndex++) {
                           if (((Part) (inPartArr[argIndex]))
                               .getName()
                               .equals(nextOutPart.getName())) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.