scheu 02/05/01 10:17:15 Modified: java/src/org/apache/axis/wsdl/toJava JavaDefinitionWriter.java JavaFaultWriter.java JavaTestCaseWriter.java SymbolTable.java Utils.java Log: Upgraded the fault -> Java Exception mapping to the 0.8 version of JSR 101. * The java exception name is mapped from the name of the message referenced in the fault message attribute. This includes using the namespaceURI of the message to construct the package name (previously the code used the namespaceURI of the portType). * The WSDL document indicates that the fault message attribute is required. I removed some uneccessary code which attempted to construct a java exception class name if the fault message was not present. Note that there have been discussions on the chat concerning additional changes to the fault mapping for version 0.9 of JSR 101. We do not agree with the mapping presented in version 0.9 and are waiting clarifications and changes. Revision Changes Path 1.6 +3 -7 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDefinitionWriter.java Index: JavaDefinitionWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDefinitionWriter.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- JavaDefinitionWriter.java 9 Apr 2002 15:41:30 -0000 1.5 +++ JavaDefinitionWriter.java 1 May 2002 17:17:15 -0000 1.6 @@ -163,15 +163,11 @@ Fault f = (Fault) fi.next(); String name = Utils.getFullExceptionName( f, - symbolTable, - portType.getQName().getNamespaceURI()); - // prevent duplicates + symbolTable); + // prevent duplicates if (! faultList.contains(name) ) { faultList.add(name); - QName faultQName = new QName( - portType.getQName().getNamespaceURI(), - Utils.getExceptionName(f)); - faults.put(f, faultQName); // add this fault to the list + faults.put(f, f.getMessage().getQName()); } } } 1.7 +8 -0 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaFaultWriter.java Index: JavaFaultWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaFaultWriter.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- JavaFaultWriter.java 19 Mar 2002 20:15:28 -0000 1.6 +++ JavaFaultWriter.java 1 May 2002 17:17:15 -0000 1.7 @@ -76,6 +76,14 @@ */ protected JavaFaultWriter(Emitter emitter, QName qname, Fault fault, SymbolTable symbolTable) { super(emitter, qname, "", "java", JavaUtils.getMessage("genFault00"), "fault"); + + // Need to adjust the className and fileName to make sure they are consistent with + // the full name. The alternative is to pass a 'dummy' qname into JavaFaultWriter, + // which is not appropriate. + String fullName = Utils.getFullExceptionName(fault, symbolTable); + className = fullName.substring(fullName.lastIndexOf(".")+1); + fileName = className + ".java"; + this.fault = fault; this.symbolTable = symbolTable; } // ctor 1.22 +1 -2 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaTestCaseWriter.java Index: JavaTestCaseWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaTestCaseWriter.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- JavaTestCaseWriter.java 19 Apr 2002 13:59:05 -0000 1.21 +++ JavaTestCaseWriter.java 1 May 2002 17:17:15 -0000 1.22 @@ -299,10 +299,9 @@ while (i.hasNext()) { count++; Fault f = (Fault) i.next(); - String namespace = portType.getQName().getNamespaceURI(); pw.print(" catch ("); pw.print(Utils.getFullExceptionName( - f, symbolTable, namespace)); + f, symbolTable)); pw.println(" e" + count + ") {"); pw.print(" "); pw.println("throw new junit.framework.AssertionFailedError(\"" + f.getName() + " Exception caught: \" + e" + count + ");"); 1.55 +1 -1 xml-axis/java/src/org/apache/axis/wsdl/toJava/SymbolTable.java Index: SymbolTable.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/SymbolTable.java,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- SymbolTable.java 11 Apr 2002 13:30:55 -0000 1.54 +++ SymbolTable.java 1 May 2002 17:17:15 -0000 1.55 @@ -1017,7 +1017,7 @@ while (i.hasNext()) { Fault fault = (Fault) i.next(); String exceptionName = - Utils.getFullExceptionName(fault, this, namespace); + Utils.getFullExceptionName(fault, this); if (parameters.faultString == null) parameters.faultString = exceptionName; else 1.28 +9 -45 xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java Index: Utils.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- Utils.java 24 Apr 2002 17:13:02 -0000 1.27 +++ Utils.java 1 May 2002 17:17:15 -0000 1.28 @@ -565,35 +565,10 @@ return typeValue + "Holder"; } // holder - /** - * Given a fault, return the Java class name of the exception to be - * generated from this fault - * - * @param fault - The WSDL fault object - * @return A Java class name for the fault - */ - public static String getExceptionName(Fault fault) { - /** - * Use the message name as the fault class name, - * fall back to fault name if there isn't a message part - * - * NOTE: JAX-RPC version 0.5 says to use the message name, but - * hopefully this will change to use the fault name, which makes - * a good deal more sense ([EMAIL PROTECTED]) - */ - Message faultMessage = fault.getMessage(); - String exceptionName; - if (faultMessage != null) { - String faultMessageName = faultMessage.getQName().getLocalPart(); - exceptionName = xmlNameToJavaClass(faultMessageName); - } else { - exceptionName = xmlNameToJavaClass(fault.getName()); - } - return exceptionName; - } /** - * Given a fault, return the fully qualified Java class name of the exception to be + * Given a fault, return the fully qualified Java class name + * of the exception to be * generated from this fault * * @param fault - The WSDL fault object @@ -601,25 +576,14 @@ * @return A Java class name for the fault */ public static String getFullExceptionName( - Fault fault, SymbolTable symbolTable, String namespace) { - /** - * Use the message name as the fault class name, - * fall back to fault name if there isn't a message part - * - * NOTE: JAX-RPC version 0.5 says to use the message name, but - * hopefully this will change to use the fault name, which makes - * a good deal more sense ([EMAIL PROTECTED]) - */ + Fault fault, SymbolTable symbolTable) { + + // Upgraded to JSR 101 version 0.8 + + // Get the Message referenced in the message attribute of the + // fault. Message faultMessage = fault.getMessage(); - String exceptionName; - if (faultMessage != null) { - String faultName = faultMessage.getQName().getLocalPart(); - QName qname = new QName(namespace, faultName); - exceptionName = symbolTable.getJavaName(qname); - } else { - exceptionName = xmlNameToJavaClass(fault.getName()); - } - return exceptionName; + return symbolTable.getJavaName(faultMessage.getQName()); } // getFullExceptionName