You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2006/04/08 08:58:45 UTC

svn commit: r392486 - in /webservices/axis2/trunk/java/modules/codegen: src/org/apache/axis2/wsdl/codegen/emitter/ src/org/apache/axis2/wsdl/template/java/ test-resources/

Author: ajith
Date: Fri Apr  7 23:58:42 2006
New Revision: 392486

URL: http://svn.apache.org/viewcvs?rev=392486&view=rev
Log:
Adding the Fault binding support for codegen
1. Changed the AxisServiceBasedMultiLanguageEmitter.java  to add the faults to the generated intermediate XML
2. Changed the templates to generate the right code for the MessageReceiverTemplate.xsl and the SkeletonTemplate.xsl

Added:
    webservices/axis2/trunk/java/modules/codegen/test-resources/BookQuote2.wsdl
Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java?rev=392486&r1=392485&r2=392486&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java Fri Apr  7 23:58:42 2006
@@ -40,6 +40,9 @@
 import java.io.IOException;
 import java.io.StringWriter;
 import java.util.*;
+
+import com.ibm.wsdl.util.xml.DOM2Writer;
+
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -66,15 +69,16 @@
     private static final String CALL_BACK_HANDLER_SUFFIX = "CallbackHandler";
     private static final String STUB_SUFFIX = "Stub";
     private static final String TEST_SUFFIX = "Test";
-    private static final String SERVICE_CLASS_SUFFIX = "Skeleton";
+    private static final String SKELETON_CLASS_SUFFIX = "Skeleton";
     private static final String MESSAGE_RECEIVER_SUFFIX = "MessageReceiver";
+    private static final String FAULT_SUFFIX = "Exception";
     private static final String DATABINDING_SUPPORTER_NAME_SUFFIX = "DatabindingSupporter";
-    private static final String DATABINDING_PACKAGE_NAME_SUFFIX = ".databinding";
+//    private static final String DATABINDING_PACKAGE_NAME_SUFFIX = ".databinding";
 
     private static Map MEPtoClassMap;
     private static Map MEPtoSuffixMap;
 
-
+    private int uniqueFaultNameCounter = 0;
     /**
      * Field constructorMap
      */
@@ -134,6 +138,11 @@
     
     private AxisService axisService;
 
+    //a map to keep the fault classNames
+    private Map fullyQualifiedFaultClassNameMap = new HashMap();
+    private Map faultClassNameMap = new HashMap();
+
+
     public AxisServiceBasedMultiLanguageEmitter() {
         infoHolder = new HashMap();
     }
@@ -165,11 +174,49 @@
      * Update mapper for the stub
      */
     private void updateMapperForStub() {
+        updateMapperClassnames(getFullyQualifiedStubName() + ".");
+    }
+
+    private String getFullyQualifiedStubName(){
         String packageName = codeGenConfiguration.getPackageName();
         String localPart = makeJavaClassName(axisService.getName());
-        String stubName = localPart + STUB_SUFFIX;
+        return packageName + "." + localPart + STUB_SUFFIX;
+    }
+    /**
+     * Populate a map of fault class names
+     */
+    private void generateAndPopulateFaultNames(){
+        //loop through and find the faults
+        Iterator operations = axisService.getOperations();
+        AxisOperation operation;
+        AxisMessage faultMessage;
+        while (operations.hasNext()) {
+            operation =  (AxisOperation)operations.next();
+            ArrayList faultMessages = operation.getFaultMessages();
+            for (int i = 0; i < faultMessages.size(); i++) {
+                faultMessage  = (AxisMessage)faultMessages.get(i);
+                //make a unique name and put that in the hashmap
+                if (!fullyQualifiedFaultClassNameMap.
+                        containsKey(faultMessage.getElementQName())){
+                    //make a name
+                    String className = makeJavaClassName(faultMessage.getName()
+                            + FAULT_SUFFIX);
+                    while(fullyQualifiedFaultClassNameMap.containsValue(className)){
+                        className = makeJavaClassName(className + (uniqueFaultNameCounter++));
+                    }
 
-        updateMapperClassnames(packageName + "." + stubName + ".");
+                    fullyQualifiedFaultClassNameMap.put(
+                            faultMessage.getElementQName(),
+                            className);
+
+                    //we've to keep track of the fault base names seperately
+                    faultClassNameMap.put(faultMessage.getElementQName(),
+                            className);
+
+                }
+            }
+
+        }
     }
 
     /**
@@ -185,6 +232,10 @@
             updateMapperForStub();
         }
 
+        //generate and populate the fault names before hand. We need that for
+        //the smooth opration of the thing
+        generateAndPopulateFaultNames();
+
         // write the inteface
         // feed the binding information also
         // note that we do not create this interface if the user switched on the wrap classes mode
@@ -201,12 +252,15 @@
         // write the test classes
         writeTestClasses();
 
-        // write a dummy implementation call for the tests to run.
-        // writeTestSkeletonImpl(axisBinding);
-        // write a testservice.xml that will load the dummy skeleton impl for testing
-        // writeTestServiceXML(axisBinding);
+
         // write an ant build file
-        writeAntBuild();
+        //Note that ant build is generated only once
+        //and that has to happen here only if the
+        //client side code is required
+        if (!codeGenConfiguration.isGenerateAll()){
+            writeAntBuild();
+        }
+
     }
 
     /**
@@ -364,6 +418,11 @@
             rootElement.appendChild(doc.importNode((Element) stubMethods, true));
         }
 
+        /////////////////////////////////////////////////////
+        //System.out.println(DOM2Writer.nodeToString(rootElement));
+        /////////////////////////////////////////////////////
+
+
         doc.appendChild(rootElement);
         return doc;
     }
@@ -501,70 +560,6 @@
         return doc;
     }
 
-    /**
-     * Emits the stubcode with bindings.
-     *
-     * @throws Exception
-     */
-//    private void emitStubBinding() throws Exception {
-//        WSDLInterface axisInterface = infoHolder.getWSDLinterface();
-//
-//        // see the comment at updateMapperClassnames for details and reasons for
-//        // calling this method
-//        if (mapper.isObjectMappingPresent()) {
-//            updateMapperForStub(axisInterface);
-//        }
-//
-//        // write the inteface
-//        // feed the binding information also
-//        // note that we do not create this interface if the user switched on the wrap classes mode
-//        if (!configuration.isPackClasses()) {
-//            writeInterface(false);
-//        }
-//
-//        // write the call back handlers
-//        writeCallBackHandlers();
-//
-//        // write interface implementations
-//        writeInterfaceImplementation();
-//
-//        // write the test classes
-//        writeTestClasses();
-//
-//        // write a dummy implementation call for the tests to run.
-//        // writeTestSkeletonImpl(axisBinding);
-//        // write a testservice.xml that will load the dummy skeleton impl for testing
-//        // writeTestServiceXML(axisBinding);
-//        // write an ant build file
-//        writeAntBuild();
-//    }
-
-//    /**
-//     * Emits the stub code with interfaces only.
-//     *
-//     * @throws Exception
-//     */
-//    private void emitStubInterface() throws Exception {
-//        WSDLInterface axisInterface = infoHolder.getWSDLinterface();
-//
-//        if (mapper.isObjectMappingPresent()) {
-//            updateMapperForInterface(axisInterface);
-//        }
-//
-//        // Write the interfaces
-//        // note that this case we do not care about the wrapping flag
-//        writeInterface(true);
-//
-//        // write the call back handlers
-//        writeCallBackHandlers();
-//
-//        // log the message stating that the binding dependent parts are not generated
-//        log.info(CodegenMessages.getMessage("emitter.logEntryInterface1"));
-//        log.info(CodegenMessages.getMessage("emitter.logEntryInterface3"));
-//        log.info(CodegenMessages.getMessage("emitter.logEntryInterface4"));
-//        log.info(CodegenMessages.getMessage("emitter.logEntryInterface5"));
-//        log.info(CodegenMessages.getMessage("emitter.logEntryInterface6"));
-//    }
 
     /**
      * Emit the skeltons
@@ -573,9 +568,7 @@
      */
     public void emitSkeleton() throws CodeGenerationException {
         try {
-
-            emitSkeletonInterface();
-
+            emitSkeletonService();
         } catch (Exception e) {
             throw new CodeGenerationException(e);
         }
@@ -585,20 +578,44 @@
      * Update mapper for message receiver
      */
     private void updateMapperForMessageReceiver() {
+        updateMapperClassnames(getFullyQualifiedMessageReceiverName() + ".");
+    }
+
+    /**
+     *
+     * @return fully qualified MR name
+     */
+    private String getFullyQualifiedMessageReceiverName(){
         String packageName = codeGenConfiguration.getPackageName();
         String localPart = makeJavaClassName(axisService.getName());
-        String messageReceiver = localPart + MESSAGE_RECEIVER_SUFFIX;
-        updateMapperClassnames(packageName + "." + messageReceiver + ".");
+        return  packageName + "."+localPart + MESSAGE_RECEIVER_SUFFIX;
     }
 
+    /**
+     *
+     * @return fully qualified MR name
+     */
+    private String getFullyQualifiedSkeletonName(){
+        String packageName = codeGenConfiguration.getPackageName();
+        String localPart = makeJavaClassName(axisService.getName());
+        return  packageName + "."+localPart + SKELETON_CLASS_SUFFIX;
+    }
 
-    private void emitSkeletonInterface() throws Exception {
+    /**
+     *
+     * @throws Exception
+     */
+    private void emitSkeletonService() throws Exception {
         // see the comment at updateMapperClassnames for details and reasons for
         // calling this method
         if (mapper.isObjectMappingPresent()) {
             updateMapperForMessageReceiver();
         }
 
+        //handle faults
+        generateAndPopulateFaultNames();
+        updateFaultPackageForSkeleton();
+
         // write skeleton
         writeSkeleton();
 
@@ -608,11 +625,29 @@
         // write interface implementations
         writeServiceXml();
 
+        //write the ant build
+        writeAntBuild();
+
         log.info(CodegenMessages.getMessage("emitter.logEntryInterface1"));
         log.info(CodegenMessages.getMessage("emitter.logEntryInterface2"));
     }
 
     /**
+     *
+     */
+    private void updateFaultPackageForSkeleton() {
+        Iterator faultClassNameKeys = fullyQualifiedFaultClassNameMap.keySet().iterator();
+        while (faultClassNameKeys.hasNext()) {
+            Object key =  faultClassNameKeys.next();
+            String className = (String)fullyQualifiedFaultClassNameMap.get(key);
+            //append the skelton name
+            className = getFullyQualifiedSkeletonName() + "."
+                           + className;
+            fullyQualifiedFaultClassNameMap.put(key,className);
+        }
+    }
+
+    /**
      * @throws Exception
      */
     protected void writeMessageReceiver() throws Exception {
@@ -646,7 +681,7 @@
         String localPart = makeJavaClassName(axisService.getName());
 
         addAttribute(doc, "name", localPart + MEPtoSuffixMap.get(mep), rootElement);
-        addAttribute(doc, "skeletonname", localPart + SERVICE_CLASS_SUFFIX, rootElement);
+        addAttribute(doc, "skeletonname", localPart + SKELETON_CLASS_SUFFIX, rootElement);
         addAttribute(doc, "basereceiver", (String) MEPtoClassMap.get(mep), rootElement);
         fillSyncAttributes(doc, rootElement);
 
@@ -656,26 +691,22 @@
         // ###########################################################################################
         // check for the special models in the mapper and if they are present process them
         if (mapper.isObjectMappingPresent()) {
-
             // add an attribute to the root element showing that the writing has been skipped
             addAttribute(doc, "skip-write", "yes", rootElement);
-
             // process the mapper objects
             processModelObjects(mapper.getAllMappedObjects(), rootElement, doc);
         }
-
         // #############################################################################################
 
         boolean isOpsFound = loadOperations(doc, rootElement, mep);
-
         //put the result in the property map
         infoHolder.put(mep, isOpsFound ? Boolean.TRUE : Boolean.FALSE);
-        // ///////////////////////
         rootElement.appendChild(createDOMElementforDatabinders(doc));
-
-        // ///////////////////////
         doc.appendChild(rootElement);
 
+        //////////////////////////////////
+        System.out.println(DOM2Writer.nodeToString(rootElement));
+        ////////////////////////////////
         return doc;
     }
 
@@ -695,20 +726,26 @@
             // Add the parameters to a map with their type as the key
             // this step is needed to remove repetitions
 
-            // process the input and output parameters
+            // process the input parameters
             Element inputParamElement = getInputParamElement(doc, axisOperation);
-
             if (inputParamElement != null) {
                 parameterMap.put(inputParamElement.getAttribute("type"), inputParamElement);
             }
 
+            // process output parameters
             Element outputParamElement = getOutputParamElement(doc, axisOperation);
-
             if (outputParamElement != null) {
                 parameterMap.put(outputParamElement.getAttribute("type"), outputParamElement);
             }
 
-            // todo process the exceptions
+            //process faults
+            Element[] faultParamElements = getFaultParamElements(doc, axisOperation);
+            for (int i = 0; i < faultParamElements.length; i++) {
+                parameterMap.put(
+                        faultParamElements[i].getAttribute("type"),
+                        faultParamElements[i]);
+            }
+
             // process the header parameters
             Element newChild;
             List headerParameterQNameList = new ArrayList();
@@ -853,7 +890,7 @@
 
         addAttribute(doc, "package", "", rootElement);
         addAttribute(doc, "classpackage", codeGenConfiguration.getPackageName(), rootElement);
-        addAttribute(doc, "name", className + SERVICE_CLASS_SUFFIX, rootElement);
+        addAttribute(doc, "name", className + SKELETON_CLASS_SUFFIX, rootElement);
         if (!codeGenConfiguration.isWriteTestCase()) {
             addAttribute(doc, "testOmit", "true", rootElement);
         }
@@ -890,7 +927,7 @@
 
         String serviceName = makeJavaClassName(axisService.getName());
         addAttribute(doc, "package", codeGenConfiguration.getPackageName(), rootElement);
-        addAttribute(doc, "name", serviceName + SERVICE_CLASS_SUFFIX, rootElement);
+        addAttribute(doc, "name", serviceName + SKELETON_CLASS_SUFFIX, rootElement);
         addAttribute(doc, "callbackname", serviceName + CALL_BACK_HANDLER_SUFFIX,
                 rootElement);
 
@@ -933,7 +970,6 @@
                 addAttribute(doc, "name", localPart, methodElement);
                 addAttribute(doc, "namespace", axisOperation.getName().getNamespaceURI(), methodElement);
                 String style = axisOperation.getStyle();
-
                 addAttribute(doc, "style", style, methodElement);
                 addAttribute(doc, "dbsupportname", portTypeName + localPart + DATABINDING_SUPPORTER_NAME_SUFFIX,
                         methodElement);
@@ -951,6 +987,8 @@
 
                 methodElement.appendChild(getInputElement(doc, axisOperation, soapHeaderInputParameterList));
                 methodElement.appendChild(getOutputElement(doc, axisOperation, soapHeaderOutputParameterList));
+                methodElement.appendChild(getFaultElement(doc, axisOperation));
+
                 rootElement.appendChild(methodElement);
             } else {
                 //mep is present - we move ahead only if the given mep matches the mep of this operation
@@ -982,12 +1020,19 @@
 
                     Policy policy = axisOperation.getPolicyInclude().getPolicy();
                     if (policy != null) {
-                        addAttribute(doc, "policy", PolicyUtil.getPolicyAsString(policy), methodElement);
+                        addAttribute(doc, "policy",
+                                PolicyUtil.getPolicyAsString(policy),
+                                methodElement);
                     }
 
 
-                    methodElement.appendChild(getInputElement(doc, axisOperation, soapHeaderInputParameterList));
-                    methodElement.appendChild(getOutputElement(doc, axisOperation, soapHeaderOutputParameterList));
+                    methodElement.appendChild(getInputElement(doc,
+                            axisOperation, soapHeaderInputParameterList));
+                    methodElement.appendChild(getOutputElement(doc,
+                            axisOperation, soapHeaderOutputParameterList));
+                    methodElement.appendChild(getFaultElement(doc,
+                            axisOperation));
+
                     rootElement.appendChild(methodElement);
                     //////////////////////
                 }
@@ -1035,6 +1080,11 @@
         XSLTUtils.addAttribute(document, AttribName, attribValue, element);
     }
 
+    /**
+     *
+     * @param doc
+     * @param rootElement
+     */
     private void fillSyncAttributes(Document doc, Element rootElement) {
         addAttribute(doc, "isAsync", this.codeGenConfiguration.isAsyncOn()
                 ? "1"
@@ -1173,6 +1223,23 @@
     }
 
     /**
+     * Get the fault element - No header faults are supported
+     * @param doc
+     * @param operation
+     * @return
+     */
+    protected Element getFaultElement(Document doc, AxisOperation operation) {
+        Element faultElt = doc.createElement("fault");
+        Element[] param = getFaultParamElements(doc, operation);
+
+        for (int i = 0; i < param.length; i++) {
+            faultElt.appendChild(param[i]);
+        }
+
+        return faultElt;
+    }
+
+    /**
      * Finds the output element.
      *
      * @param doc
@@ -1188,7 +1255,6 @@
         }
 
         List outputElementList = getParameterElementList(doc, headerParameterQNameList, "header");
-
         for (int i = 0; i < outputElementList.size(); i++) {
             outputElt.appendChild((Element) outputElementList.get(i));
         }
@@ -1201,6 +1267,65 @@
      * @param operation
      * @return Returns the parameter element.
      */
+    private Element[] getFaultParamElements(Document doc, AxisOperation operation) {
+        ArrayList params = new ArrayList();
+        ArrayList faultMessages = operation.getFaultMessages();
+
+        if (faultMessages != null && !faultMessages.isEmpty()) {
+            Element paramElement;
+            AxisMessage msg;
+            for (int i = 0; i < faultMessages.size(); i++) {
+                paramElement = doc.createElement("param");
+                msg = (AxisMessage)faultMessages.get(i);
+
+                //as for the name of a fault, we generate an exception
+                addAttribute(doc, "name",
+                        (String)fullyQualifiedFaultClassNameMap.get(msg.getElementQName()),
+                        paramElement);
+                 addAttribute(doc, "shortName",
+                        (String)faultClassNameMap.get(msg.getElementQName()),
+                        paramElement);
+                //the type represents the type that will be wrapped by this
+                //name
+                String typeMapping =
+                        this.mapper.getTypeMappingName(msg.getElementQName());
+                addAttribute(doc, "type", (typeMapping == null)
+                        ? ""
+                        : typeMapping, paramElement);
+
+                // add an extra attribute to say whether the type mapping is
+                // the default
+                if (TypeMapper.DEFAULT_CLASS_NAME.equals(typeMapping)) {
+                    addAttribute(doc, "default", "yes", paramElement);
+                }
+                addAttribute(doc, "value", getParamInitializer(typeMapping),
+                        paramElement);
+
+                Iterator iter = msg.getExtensibilityAttributes().iterator();
+                while (iter.hasNext()) {
+                    WSDLExtensibilityAttribute att =
+                            (WSDLExtensibilityAttribute) iter.next();
+                    addAttribute(doc, att.getKey().getLocalPart(),
+                            att.getValue().toString(),
+                            paramElement);
+                }
+                params.add(paramElement);
+            }
+
+            return (Element[])params.toArray(new Element[params.size()]);
+        } else {
+            return new Element[]{};//return empty array
+        }
+
+
+    }
+
+
+    /**
+     * @param doc
+     * @param operation
+     * @return Returns the parameter element.
+     */
     private Element getInputParamElement(Document doc, AxisOperation operation) {
         Element param = doc.createElement("param");
         AxisMessage inputMessage = operation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
@@ -1274,8 +1399,12 @@
         return param;
     }
 
-
-    String getParamInitializer(String paramType) {
+    /**
+     *
+     * @param paramType
+     * @return
+     */
+    private String getParamInitializer(String paramType) {
 
         // Look up paramType in the table
         String out = (String) constructorMap.get(paramType);
@@ -1287,6 +1416,13 @@
         return out;
     }
 
+    /**
+     *
+     * @param doc
+     * @param parameters
+     * @param location
+     * @return
+     */
     private List getParameterElementList(Document doc, List parameters, String location) {
         List parameterElementList = new ArrayList();
 

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl?rev=392486&r1=392485&r2=392486&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl Fri Apr  7 23:58:42 2006
@@ -160,7 +160,7 @@
     }
 
     /**
-     * Constructor taking the traget endpoint
+     * Constructor taking the target endpoint
      */
     public <xsl:value-of select="@name"/>(java.lang.String targetEndpoint) throws java.lang.Exception {
         this(org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_HOME,null),
@@ -173,7 +173,6 @@
             <xsl:variable name="outputtype"><xsl:value-of select="output/param/@type"></xsl:value-of></xsl:variable>
             <xsl:variable name="style"><xsl:value-of select="@style"></xsl:value-of></xsl:variable>
             <xsl:variable name="soapAction"><xsl:value-of select="@soapaction"></xsl:value-of></xsl:variable>
-
             <xsl:variable name="mep"><xsl:value-of select="@mep"/></xsl:variable>
 	    
 	    <!-- MTOM -->
@@ -195,7 +194,12 @@
                     <xsl:text> </xsl:text><xsl:value-of select="@name"/>(
                     <xsl:for-each select="input/param[@type!='']">
                         <xsl:if test="position()>1">,</xsl:if><xsl:value-of select="@type"/><xsl:text> </xsl:text><xsl:value-of select="@name"/>
-                    </xsl:for-each>) throws java.rmi.RemoteException{
+                    </xsl:for-each>)
+                    throws java.rmi.RemoteException
+                    <!--add the faults-->
+                    <xsl:for-each select="fault/param[@type!='']">
+                        ,<xsl:value-of select="@name"/>
+                    </xsl:for-each>{
 
                org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[<xsl:value-of select="position()-1"/>].getName());
               _operationClient.getOptions().setAction("<xsl:value-of select="$soapAction"/>");
@@ -211,19 +215,17 @@
                         If the number of parameter is more then just run the normal test-->
                         <xsl:when test="$count>0">
                             <xsl:choose>
-                                <xsl:when test="$style='rpc'">
-                                    // Style is RPC
-                                    org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_operationClient.getOptions().getSoapVersionURI(), env,"<xsl:value-of select="@namespace"/>","<xsl:value-of select="@name"/>",
-                                    new java.lang.String[]{<xsl:for-each select="input/param[@type!='']"><xsl:if test="position()>1">,</xsl:if>"<xsl:value-of select="@name"/>"</xsl:for-each>},
-                                    new java.lang.Object[]{<xsl:for-each select="input/param[@type!='']"><xsl:if test="position()>1">,</xsl:if><xsl:value-of select="@name"/></xsl:for-each>});
-                                </xsl:when>
-                                <xsl:when test="$style='document'">
+                                <!-- style being doclit or rpc does not matter -->
+                                <xsl:when test="$style='rpc' or $style='document'">
                                     //Style is Doc.
                                     <!-- Let's assume there is only one parameters here -->
                                     <xsl:for-each select="input/param[@location='body']">
                                         <xsl:choose>
                                             <xsl:when test="@type!=''">
-                                                 env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), <xsl:value-of select="@name"/>, optimizeContent(new javax.xml.namespace.QName("<xsl:value-of select="$method-ns"/>", "<xsl:value-of select="$method-name"/>")));
+                                                 env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
+                                                <xsl:value-of select="@name"/>,
+                                                optimizeContent(new javax.xml.namespace.QName("<xsl:value-of select="$method-ns"/>",
+                                                "<xsl:value-of select="$method-name"/>")));
                                             </xsl:when>
                                             <xsl:otherwise>
                                                  env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()));
@@ -247,13 +249,8 @@
                         <!-- No input parameters present. So generate assuming no input parameters-->
                         <xsl:otherwise>
                             <xsl:choose>
-                                <xsl:when test="$style='rpc'">
-                                    //Style is RPC. No input parameters
-                                    org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_operationClient.getOptions().getSoapVersionURI()), env,"<xsl:value-of select="@namespace"/>","<xsl:value-of select="@name"/>",null,null);
-                                </xsl:when>
-                                <xsl:when test="$style='document'">
+                                <xsl:when test="$style='rpc' or $style='document'">
                                     //Style is Doc. No input parameters
-                                    <!-- setValueDoc(env,null); -->
                                 </xsl:when>
                                 <xsl:otherwise>
                                     //Unknown style!! No code is generated
@@ -283,7 +280,7 @@
                 org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope();
                 <!-- todo need to change this to cater for unwrapped messages (multiple parts) -->
                 <xsl:choose>
-                    <xsl:when test="$style='document'">
+                    <xsl:when test="$style='document' or $style='rpc'">
                            java.lang.Object object = fromOM(getElement(_returnEnv,"<xsl:value-of select="$style"/>"),<xsl:value-of select="$outputtype"/>.class);
                           
                            _messageContext.getTransportOut().getSender().cleanUp(_messageContext);
@@ -298,7 +295,7 @@
             </xsl:otherwise>
         </xsl:choose>
 
-                    }
+        }
             </xsl:if>
             <!-- Async method generation -->
             <xsl:if test="$isAsync='1'">
@@ -313,11 +310,13 @@
                 <xsl:variable name="paramCount"><xsl:value-of select="count(input/param[@type!=''])"></xsl:value-of></xsl:variable>
                 <xsl:for-each select="input/param[@type!='']">
                     <xsl:if test="position()>1">,</xsl:if><xsl:value-of select="@type"/><xsl:text> </xsl:text><xsl:value-of select="@name"></xsl:value-of></xsl:for-each>
-                <xsl:if test="$paramCount>0">,</xsl:if>final <xsl:value-of select="$package"/>.<xsl:value-of select="$callbackname"/> callback) throws java.rmi.RemoteException{
+                <xsl:if test="$paramCount>0">,</xsl:if>final <xsl:value-of select="$package"/>.<xsl:value-of select="$callbackname"/> callback)
 
-                org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[<xsl:value-of select="position()-1"/>].getName());
-          _operationClient.getOptions().setAction("<xsl:value-of select="$soapAction"/>");
-          _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
+                throws java.rmi.RemoteException{
+
+              org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[<xsl:value-of select="position()-1"/>].getName());
+             _operationClient.getOptions().setAction("<xsl:value-of select="$soapAction"/>");
+             _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
 
           <!--todo if the stub was generated with unwrapping, wrap all parameters into a single element-->
 
@@ -329,13 +328,7 @@
                         If the number of parameter is more then just run the normal test-->
                         <xsl:when test="$count>0">
                             <xsl:choose>
-                                <xsl:when test="$style='rpc'">
-                                    // Style is RPC
-                                    org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_operationClient.getOptions().getSoapVersionURI(), env,"<xsl:value-of select="@namespace"/>","<xsl:value-of select="@name"/>",
-                                    new java.lang.String[]{<xsl:for-each select="input/param[@type!='']"><xsl:if test="position()>1">,</xsl:if>"<xsl:value-of select="@name"/>"</xsl:for-each>},
-                                    new java.lang.Object[]{<xsl:for-each select="input/param[@type!='']"><xsl:if test="position()>1">,</xsl:if><xsl:value-of select="@name"/></xsl:for-each>});
-                                </xsl:when>
-                                <xsl:when test="$style='document'">
+                                <xsl:when test="$style='document' or $style='rpc'">
                                     //Style is Doc.
                                     <xsl:for-each select="input/param[@location='body']">
                                         <xsl:choose>
@@ -363,13 +356,8 @@
                         <!-- No input parameters present. So generate assuming no input parameters-->
                         <xsl:otherwise>
                             <xsl:choose>
-                                <xsl:when test="$style='rpc'">
-                                    //Style is RPC. No input parameters
-                                    org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_operationClient.getOptions().getSoapVersionURI()), env,"<xsl:value-of select="@namespace"/>","<xsl:value-of select="@name"/>",null,null);
-                                </xsl:when>
-                                <xsl:when test="$style='document'">
+                                <xsl:when test="$style='document' or $style='rpc'">
                                     //Style is Doc. No input parameters
-                                    <!-- setValueDoc(env,null); -->
                                 </xsl:when>
                                 <xsl:otherwise>
                                     //Unknown style!! No code is generated
@@ -442,14 +430,7 @@
                        If the number of parameter is more then just run the normal generation-->
                     <xsl:when test="count(input/param[@type!=''])>0">
                         <xsl:choose>
-                            <xsl:when test="$style='rpc'">
-                                // Style is RPC
-                                env = createEnvelope();
-                                org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_operationClient.getOptions().getSoapVersionURI()), env,"<xsl:value-of select="@namespace"/>","<xsl:value-of select="@name"/>",
-                                new java.lang.String[]{<xsl:for-each select="input/param[@type!='']"><xsl:if test="position()>1">,</xsl:if>"<xsl:value-of select="@name"/>"</xsl:for-each>},
-                                new java.lang.Object[]{<xsl:for-each select="input/param[@type!='']"><xsl:if test="position()>1">,</xsl:if><xsl:value-of select="@name"/></xsl:for-each>});
-                            </xsl:when>
-                            <xsl:when test="$style='document'">
+                            <xsl:when test="$style='document' or $style='rpc'">
                                 <!-- for the doc lit case there can be only one element. So take the first element -->
                                 //Style is Doc.
                                 env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), <xsl:value-of select="input/param[1]/@name"/>, optimizeContent(new javax.xml.namespace.QName("<xsl:value-of select="$method-ns"/>", "<xsl:value-of select="$method-name"/>")));
@@ -463,13 +444,8 @@
                     <!-- No input parameters present. So generate assuming no input parameters-->
                     <xsl:otherwise>
                         <xsl:choose>
-                            <xsl:when test="$style='rpc'">
-                                //Style is RPC. No input parameters
-                                org.apache.axis2.rpc.client.RPCStub.setValueRPC(getFactory(_operationClient.getOptions().getSoapVersionURI()), env,"<xsl:value-of select="@namespace"/>","<xsl:value-of select="@name"/>",null,null);
-                            </xsl:when>
-                            <xsl:when test="$style='document'">
+                            <xsl:when test="$style='document' or $style='rpc'">
                                 //Style is Doc. No input parameters
-                                <!-- setValueDoc(env,null); -->
                             </xsl:when>
                             <xsl:otherwise>
                                 //Unknown style!! No code is generated
@@ -597,12 +573,27 @@
 		}
 		return false;
 	}
-    //<xsl:apply-templates/>
-   }
 
 
+     <!-- write the classes for the exceptions if there are any present -->
+   <xsl:for-each select="method">
+       <xsl:for-each select="fault/param">
+         public static class <xsl:value-of select="@shortName"/> extends Exception{
+
+            private <xsl:value-of select="@type"/> faultMessage;
+
+            public void setFaultMessage(<xsl:value-of select="@type"/> msg){
+               faultMessage = msg;
+            }
+
+            public <xsl:value-of select="@type"/> getFaultMessage(){
+               return faultMessage;
+            }
+         }
+       </xsl:for-each>
+   </xsl:for-each>
 
-    </xsl:template>
-
-
+    //<xsl:apply-templates/>
+   }
+   </xsl:template>
 </xsl:stylesheet>

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl?rev=392486&r1=392485&r2=392486&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl Fri Apr  7 23:58:42 2006
@@ -75,21 +75,18 @@
 
 
             <xsl:choose>
-                <xsl:when test="$style='rpc'">
-
-                    //rpc style  -- this needs to be filled
-
-                </xsl:when>
-                <xsl:when test="$style='document'">
+                <!-- We really don't need to make a difference between these-->
+                <xsl:when test="$style='document' or $style='rpc'">
                     //doc style
                     <xsl:if test="$returntype!=''"><xsl:value-of select="$returnvariable"/> =</xsl:if>
-                    <xsl:variable name="paramCount"> <xsl:value-of select="count(input/param[@location='body'])"/></xsl:variable>
+                    <xsl:variable name="paramCount"><xsl:value-of select="count(input/param[@location='body'])"/></xsl:variable>
                     <xsl:choose>
-                        <xsl:when test="$paramCount &gt; 0"> skel.<xsl:value-of select="@name"/>(
+                        <xsl:when test="$paramCount &gt; 0">skel.<xsl:value-of select="@name"/>(
                             <xsl:for-each select="input/param[@location='body']">
                                 <xsl:if test="@type!=''">(<xsl:value-of select="@type"/>)fromOM(msgContext.getEnvelope().getBody().getFirstElement(), <xsl:value-of select="@type"/>.class)<xsl:if test="position() &gt; 1">,</xsl:if></xsl:if>
                             </xsl:for-each>);
                         </xsl:when>
+                        <!--No input parameters-->
                         <xsl:otherwise>skel.<xsl:value-of select="@name"/>();</xsl:otherwise>
                     </xsl:choose>
 
@@ -116,12 +113,27 @@
         newMsgContext.setEnvelope(envelope);
         }
 
-
-
-        } catch (Exception e) {
-        throw org.apache.axis2.AxisFault.makeFault(e);
-        }
-        <xsl:for-each select="method"/>
+        <xsl:for-each select="method">
+        <xsl:choose>
+           <xsl:when test="fault/param">
+               <xsl:for-each select="fault/param">
+                   <xsl:if test="position()>1">}</xsl:if> catch (<xsl:value-of select="@name"/> e) {
+                        org.apache.axis2.AxisFault f =
+                            new org.apache.axis2.AxisFault("<xsl:value-of select="@shortName"/>");
+                        f.setDetail(toOM(e.getFaultMessage(),false));
+                        throw f;
+                   }
+               </xsl:for-each>
+           </xsl:when>
+            <xsl:otherwise>
+                    <!-- put a single bracket for the catch-->
+                    }
+            </xsl:otherwise>
+        </xsl:choose>
+        </xsl:for-each>
+            catch (Exception e) {
+              throw org.apache.axis2.AxisFault.makeFault(e);
+            }
         }
          <!-- Call templates recursively-->
         //<xsl:apply-templates/>
@@ -212,13 +224,12 @@
         } catch (Exception e) {
         throw org.apache.axis2.AxisFault.makeFault(e);
         }
-        <xsl:for-each select="method"/>
         }
          <!-- Call templates recursively-->
         //<xsl:apply-templates/>
 
         }
+
     </xsl:template>
-      <!-- start of in-only -->
 
 </xsl:stylesheet>

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl?rev=392486&r1=392485&r2=392486&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/SkeletonTemplate.xsl Fri Apr  7 23:58:42 2006
@@ -26,11 +26,35 @@
         public  <xsl:if test="$outputtype=''">void</xsl:if><xsl:if test="$outputtype!=''"><xsl:value-of select="$outputtype"/></xsl:if><xsl:text> </xsl:text><xsl:value-of select="@name"/>
                   (<xsl:for-each select="input/param[@location='body']">
             <xsl:if test="@type!=''"><xsl:if test="position()>1">,</xsl:if><xsl:value-of select="@type"/><xsl:text> </xsl:text><xsl:value-of select="@name"/></xsl:if>
-                   </xsl:for-each> ) throws Exception {
+                   </xsl:for-each> )
+         <!--add the faults-->
+           <xsl:for-each select="fault/param[@type!='']">
+               <xsl:if test="position()=1">throws </xsl:if>
+               <xsl:if test="position()>1">,</xsl:if><xsl:value-of select="@name"/>
+           </xsl:for-each>{
                 //Todo fill this with the necessary business logic
                 <xsl:if test="$outputtype!=''">throw new  java.lang.UnsupportedOperationException();</xsl:if>
         }
      </xsl:for-each>
+
+
+    <!-- write the classes for the exceptions if there are any present -->
+   <xsl:for-each select="method">
+       <xsl:for-each select="fault/param">
+         public static class <xsl:value-of select="@shortName"/> extends Exception{
+
+            private <xsl:value-of select="@type"/> faultMessage;
+
+            public void setFaultMessage(<xsl:value-of select="@type"/> msg){
+               faultMessage = msg;
+            }
+
+            public <xsl:value-of select="@type"/> getFaultMessage(){
+               return faultMessage;
+            }
+         }
+       </xsl:for-each>
+   </xsl:for-each>
     }
     </xsl:template>
  </xsl:stylesheet>

Added: webservices/axis2/trunk/java/modules/codegen/test-resources/BookQuote2.wsdl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test-resources/BookQuote2.wsdl?rev=392486&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test-resources/BookQuote2.wsdl (added)
+++ webservices/axis2/trunk/java/modules/codegen/test-resources/BookQuote2.wsdl Fri Apr  7 23:58:42 2006
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions xmlns:mh="http://www.Monson-Haefel.com/jwsbook/BookQuote" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://www.Monson-Haefel.com/jwsbook/BookQuote" name="BookQuote">
+    <message name="BookQuote_getBookPrice">
+        <part name="isbn" type="xsd:string"/>
+        <part name="number" type="xsd:int"/>
+    </message>
+    <message name="BookQuote_getBookPriceResponse">
+        <part name="result" type="xsd:string"/>
+    </message>
+    <message name="InvalidIsbnFault">
+        <part name="message" type="xsd:string"/>
+    </message>
+    <portType name="BookQuote">
+        <operation name="getBookPrice">
+            <input message="mh:BookQuote_getBookPrice"/>
+            <output message="mh:BookQuote_getBookPriceResponse"/>
+            <fault name="InvalidIsbnFault" message="mh:InvalidIsbnFault"/>
+        </operation>
+        <operation name="getBookPriceNonRobust">
+            <input message="mh:BookQuote_getBookPrice"/>
+            <output message="mh:BookQuote_getBookPriceResponse"/>
+        </operation>
+    </portType>
+
+    <binding name="BookQuoteBinding" type="mh:BookQuote">
+        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+        <operation name="getBookPrice">
+            <soap:operation soapAction="myAction"/>
+            <input>
+                <soap:body use="literal" namespace="http://www.Monson-Haefel.com/jwsbook/BookQuote/BookQuote"/>
+            </input>
+            <output>
+                <soap:body use="literal" namespace="http://www.Monson-Haefel.com/jwsbook/BookQuote/BookQuote"/>
+            </output>
+        </operation>
+
+        <operation name="getBookPriceNonRobust">
+            <soap:operation soapAction="myAction2"/>
+            <input>
+                <soap:body use="literal" namespace="http://www.Monson-Haefel.com/jwsbook/BookQuote/BookQuote"/>
+            </input>
+            <output>
+                <soap:body use="literal" namespace="http://www.Monson-Haefel.com/jwsbook/BookQuote/BookQuote"/>
+            </output>
+        </operation>
+    </binding>
+
+    <service name="BookQuoteService">
+        <port name="BookQuotePort" binding="mh:BookQuoteBinding">
+            <soap:address location="http://www.Monson-Haefel.com/jwsbook/BookQuoteService"/>
+        </port>
+    </service>
+</definitions>