scheu 02/02/27 12:31:10 Modified: java/src log4j.properties java/src/org/apache/axis/wsdl/fromJava ClassRep.java Emitter.java ExceptionRep.java FieldRep.java MethodRep.java ParamRep.java Log: The following changes were made: 1) Java2WSDL now uses meta data from the skeleton to set the soapAction and the input/output namespace information. 2) The new meta data information is collected in ClassRep and attached to the MethodRep as meta data. 3) Created a new BaseRep class that allows meta data values to be attached to any of the *Rep objects. Revision Changes Path 1.6 +1 -1 xml-axis/java/src/log4j.properties Index: log4j.properties =================================================================== RCS file: /home/cvs/xml-axis/java/src/log4j.properties,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- log4j.properties 27 Feb 2002 13:41:27 -0000 1.5 +++ log4j.properties 27 Feb 2002 20:31:09 -0000 1.6 @@ -1,5 +1,5 @@ # Set root category priority to ERROR and its only appender to A1. -log4j.rootCategory=ERROR, CONSOLE +log4j.rootCategory=INFO, CONSOLE #log4j.rootCategory=INFO, CONSOLE, LOGFILE # CONSOLE is set to be a ConsoleAppender using a PatternLayout. 1.18 +83 -6 xml-axis/java/src/org/apache/axis/wsdl/fromJava/ClassRep.java Index: ClassRep.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/ClassRep.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- ClassRep.java 20 Feb 2002 20:41:13 -0000 1.17 +++ ClassRep.java 27 Feb 2002 20:31:10 -0000 1.18 @@ -146,9 +146,11 @@ * | type * +--------------> Class * + * Note: all classes extend BaseRep where meta data information can be stored. + * * @author Rich Scheuerle ([EMAIL PROTECTED]) */ -public class ClassRep { +public class ClassRep extends BaseRep { private String _name = ""; private boolean _isInterface= false; @@ -298,20 +300,20 @@ // add each method in this class to the list for (int i=0; i < m.length; i++) { int mod = m[i].getModifiers(); - if (Modifier.isPublic(mod)) { + if (Modifier.isPublic(mod) && !Modifier.isStatic(mod)) { String methodName = m[i].getName(); // Ignore the getParameterName/getParameterMode methods from the Skeleton class if (((methodName.equals("getParameterName") || - methodName.equals("getParameterNameStatic") || - methodName.equals("getParameterMode") || - methodName.equals("getParameterModeStatic")) && + methodName.equals("getParameterMode")) && (Skeleton.class).isAssignableFrom(m[i].getDeclaringClass()))) { continue; // skip it } Class[] types = getParameterTypes(m[i]); String[] names = getParameterNames(m[i], implClass); ParameterMode[] modes = getParameterModes(m[i], implClass); - _methods.add(new MethodRep(m[i], types, modes, names)); + MethodRep methodRep = new MethodRep(m[i], types, modes, names); + getMethodMetaData(methodRep, m[i], implClass); + _methods.add(methodRep); } } @@ -657,6 +659,81 @@ return modes; } + + /** + * Gets additional meta data and sets it on the MethodRep. + * @param methodRep is the target MethodRep. + * @param method is the Method to search. + * @param implClass If the first search fails, the corresponding + * Method in this class is searched. + */ + protected void getMethodMetaData(MethodRep methodRep, Method method, Class implClass) { + + if (getMethodMetaDataFromSkeleton(methodRep, method)) { + return; + } + + // If failed, try getting a method of the impl class + if (implClass != null) { + Method m = null; + try { + m = implClass.getDeclaredMethod(method.getName(), method.getParameterTypes()); + } catch (Exception e) {} + if (m == null) { + try { + m = implClass.getMethod(method.getName(), method.getParameterTypes()); + } catch (Exception e) {} + } + if (m != null) { + getMethodMetaDataFromSkeleton(methodRep, m); + } + } + return; + } + + + /** + * Gets additional meta data and sets it on the MethodRep. + * @param methodRep is the target MethodRep. + * @param method is the Method to search. + * @return true if the method is part of a skeleton. + */ + protected boolean getMethodMetaDataFromSkeleton(MethodRep methodRep, Method method) { + Class cls = method.getDeclaringClass(); + Class skel = Skeleton.class; + if (!cls.isInterface() && skel.isAssignableFrom(cls)) { + try { + Method m = cls.getMethod("getInputNamespaceStatic", + new Class [] {String.class}); + if (m != null) { + String value = (String) m.invoke(null, new Object[] {method.getName()}); + if (value != null) { + methodRep.setMetaData("inputNamespace", value); + } + } + + m = cls.getMethod("getOutputNamespaceStatic", + new Class [] {String.class}); + if (m != null) { + String value = (String) m.invoke(null, new Object[] {method.getName()}); + if (value != null) { + methodRep.setMetaData("outputNamespace", value); + } + } + m = cls.getMethod("getSOAPAction", + new Class [] {String.class}); + if (m != null) { + String value = (String) m.invoke(null, new Object[] {method.getName()}); + if (value != null) { + methodRep.setMetaData("soapAction", value); + } + } + } catch (Exception e) { + } + return true; + } + return false; + } /** * Determines if the Property in the class has been compliant accessors. If so returns true, 1.21 +39 -16 xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java Index: Emitter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- Emitter.java 20 Feb 2002 20:41:13 -0000 1.20 +++ Emitter.java 27 Feb 2002 20:31:10 -0000 1.21 @@ -567,7 +567,7 @@ for(int i=0; i<methods.size(); i++) { MethodRep method = (MethodRep) methods.elementAt(i); - Operation oper = writeOperation(def, binding, method.getName()); + Operation oper = writeOperation(def, binding, method); writeMessages(def, oper, method); portType.addOperation(oper); } @@ -633,16 +633,16 @@ * * @param def * @param binding - * @param operName + * @param methodRep - Representation of the method * @throws Exception */ private Operation writeOperation(Definition def, Binding binding, - String operName) { + MethodRep methodRep) { Operation oper = def.createOperation(); - oper.setName(operName); + oper.setName(methodRep.getName()); oper.setUndefined(false); - writeBindingOperation(def, binding, oper); + writeBindingOperation(def, binding, oper, methodRep); return oper; } @@ -650,12 +650,14 @@ * * @param def * @param binding - * @param oper + * @param oper + * @param methodRep - Representation of the method * @throws Exception */ private void writeBindingOperation (Definition def, Binding binding, - Operation oper) { + Operation oper, + MethodRep methodRep) { BindingOperation bindingOper = def.createBindingOperation(); BindingInput bindingInput = def.createBindingInput(); BindingOutput bindingOutput = def.createBindingOutput(); @@ -663,7 +665,11 @@ bindingOper.setName(oper.getName()); SOAPOperation soapOper = new SOAPOperationImpl(); - soapOper.setSoapActionURI(""); + String soapAction = methodRep.getMetaData("soapAction"); + if (soapAction == null) { + soapAction = ""; + } + soapOper.setSoapActionURI(soapAction); // Until we have per-operation configuration, this will always be // the same as the binding default. @@ -671,16 +677,33 @@ bindingOper.addExtensibilityElement(soapOper); - SOAPBody soapBody = new SOAPBodyImpl(); - soapBody.setUse("encoded"); + // Input SOAP Body + SOAPBody soapBodyIn = new SOAPBodyImpl(); + soapBodyIn.setUse("encoded"); if (targetService == null) - soapBody.setNamespaceURI(intfNS); + soapBodyIn.setNamespaceURI(intfNS); else - soapBody.setNamespaceURI(targetService); - soapBody.setEncodingStyles(encodingList); - - bindingInput.addExtensibilityElement(soapBody); - bindingOutput.addExtensibilityElement(soapBody); + soapBodyIn.setNamespaceURI(targetService); + String namespace = methodRep.getMetaData("inputNamespace"); + if (namespace != null) { + soapBodyIn.setNamespaceURI(namespace); + } + soapBodyIn.setEncodingStyles(encodingList); + bindingInput.addExtensibilityElement(soapBodyIn); + + // Output SOAP Body + SOAPBody soapBodyOut = new SOAPBodyImpl(); + soapBodyOut.setUse("encoded"); + if (targetService == null) + soapBodyOut.setNamespaceURI(intfNS); + else + soapBodyOut.setNamespaceURI(targetService); + namespace = methodRep.getMetaData("outputNamespace"); + if (namespace != null) { + soapBodyOut.setNamespaceURI(namespace); + } + soapBodyOut.setEncodingStyles(encodingList); + bindingOutput.addExtensibilityElement(soapBodyOut); bindingOper.setBindingInput(bindingInput); bindingOper.setBindingOutput(bindingOutput); 1.2 +1 -1 xml-axis/java/src/org/apache/axis/wsdl/fromJava/ExceptionRep.java Index: ExceptionRep.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/ExceptionRep.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ExceptionRep.java 20 Feb 2002 20:41:13 -0000 1.1 +++ ExceptionRep.java 27 Feb 2002 20:31:10 -0000 1.2 @@ -62,7 +62,7 @@ * user provided code to affect the emitted wsdl file. (See ClassRep) * @author Brent Ulbricht */ -public class ExceptionRep { +public class ExceptionRep extends BaseRep { private String _name = ""; private Vector _parameters = null; 1.4 +1 -1 xml-axis/java/src/org/apache/axis/wsdl/fromJava/FieldRep.java Index: FieldRep.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/FieldRep.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- FieldRep.java 31 Dec 2001 21:36:12 -0000 1.3 +++ FieldRep.java 27 Feb 2002 20:31:10 -0000 1.4 @@ -63,7 +63,7 @@ * user provided code to affect the emitted wsdl file. (See ClassRep) * @author Rich Scheuerle ([EMAIL PROTECTED]) */ -public class FieldRep { +public class FieldRep extends BaseRep { private String _name = ""; private Class _type = void.class; 1.9 +2 -1 xml-axis/java/src/org/apache/axis/wsdl/fromJava/MethodRep.java Index: MethodRep.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/MethodRep.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- MethodRep.java 20 Feb 2002 20:41:13 -0000 1.8 +++ MethodRep.java 27 Feb 2002 20:31:10 -0000 1.9 @@ -58,6 +58,7 @@ import java.lang.reflect.Modifier; import java.lang.reflect.Field; import java.util.Vector; +import java.util.HashMap; import javax.xml.rpc.ParameterMode; @@ -68,7 +69,7 @@ * @author Rich Scheuerle ([EMAIL PROTECTED]) * @author Brent Ulbricht */ -public class MethodRep { +public class MethodRep extends BaseRep { private String _name = ""; private ParamRep _returns = null; 1.3 +1 -1 xml-axis/java/src/org/apache/axis/wsdl/fromJava/ParamRep.java Index: ParamRep.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/ParamRep.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ParamRep.java 19 Feb 2002 15:06:51 -0000 1.2 +++ ParamRep.java 27 Feb 2002 20:31:10 -0000 1.3 @@ -62,7 +62,7 @@ * user provided code to affect the emitted wsdl file. (See ClassRep) * @author Rich Scheuerle ([EMAIL PROTECTED]) */ -public class ParamRep { +public class ParamRep extends BaseRep { public static short IN = 0; public static short OUT = 1;