You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by de...@apache.org on 2005/12/20 07:36:34 UTC

svn commit: r357929 - in /webservices/axis2/trunk/java: etc/ modules/addressing/ modules/codegen/ modules/core/ modules/core/src/org/apache/axis2/ modules/core/src/org/apache/axis2/context/ modules/core/src/org/apache/axis2/deployment/ modules/core/src...

Author: deepal
Date: Mon Dec 19 22:35:33 2005
New Revision: 357929

URL: http://svn.apache.org/viewcvs?rev=357929&view=rev
Log:
1.Integrate java2wsdl (java2Axis*) generation to deployment .If  service archive does not contain a wsdl file then it will fill the Axis* using schema generation and filling AxisMessages.
2.Even if service archive file does not have a wsdl file , if you type ?wsdl at the run time it will generate WSDL file (not yet compete)
3.Added annogen jar dependency into core and every where to have JAM classes (I think we have to take a decision about that)
4.Added a way to store schema in AxisService and to store schema element name in AxisMessage as well.

Added:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2WOM.java
Modified:
    webservices/axis2/trunk/java/etc/project.properties
    webservices/axis2/trunk/java/modules/addressing/project.xml
    webservices/axis2/trunk/java/modules/codegen/project.xml
    webservices/axis2/trunk/java/modules/core/project.xml
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/util/Utils.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOnlyAxisOperation.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOutAxisOperation.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutOnlyAxisOperation.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AbstractDispatcher.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java
    webservices/axis2/trunk/java/modules/integration/project.xml
    webservices/axis2/trunk/java/modules/samples/project.xml
    webservices/axis2/trunk/java/modules/wsdl/project.xml
    webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/java2wsdl/Java2WOM.java
    webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/java2wsdl/Java2WSDL.java
    webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/java2wsdl/SchemaGenerator.java

Modified: webservices/axis2/trunk/java/etc/project.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/etc/project.properties?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/etc/project.properties (original)
+++ webservices/axis2/trunk/java/etc/project.properties Mon Dec 19 22:35:33 2005
@@ -99,6 +99,8 @@
 XmlSchema.version=SNAPSHOT
 xmlsec.version=1.2.1
 xmlunit.version=1.0
+#for JAM
+annogen.version=0.1.0
 
 #stax.impl.groupid=stax
 #stax.impl.artifactid=stax

Modified: webservices/axis2/trunk/java/modules/addressing/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/project.xml?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/project.xml (original)
+++ webservices/axis2/trunk/java/modules/addressing/project.xml Mon Dec 19 22:35:33 2005
@@ -112,7 +112,17 @@
                 <module>true</module>
             </properties>
         </dependency>
-        
+        <!--for java2wsdl generation we use JAM , so there should be a dependency on the annogen jar or-->
+        <!--XML Beans-->
+        <dependency>
+            <groupId>annogen</groupId>
+            <artifactId>annogen</artifactId>
+            <version>${annogen.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+
     </dependencies>
 
     <reports/>

Modified: webservices/axis2/trunk/java/modules/codegen/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/project.xml?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/project.xml (original)
+++ webservices/axis2/trunk/java/modules/codegen/project.xml Mon Dec 19 22:35:33 2005
@@ -139,6 +139,14 @@
             </properties>
             <url>http://www.ibiblio.org/maven/xmlunit/jars/</url>
         </dependency>
+         <dependency>
+            <groupId>annogen</groupId>
+            <artifactId>annogen</artifactId>
+            <version>${annogen.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
     </dependencies>
 
     <reports/>

Modified: webservices/axis2/trunk/java/modules/core/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/project.xml?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/project.xml (original)
+++ webservices/axis2/trunk/java/modules/core/project.xml Mon Dec 19 22:35:33 2005
@@ -101,6 +101,12 @@
                 <module>true</module>
             </properties>
         </dependency>
+        <!--added this to support to keep WSDL information in AxisService-->
+         <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>XmlSchema</artifactId>
+            <version>${XmlSchema.version}</version>
+        </dependency>
         <dependency>
             <groupId>commons-fileupload</groupId>
             <artifactId>commons-fileupload</artifactId>
@@ -137,6 +143,16 @@
             <groupId>geronimo-spec</groupId>
             <artifactId>geronimo-spec-activation</artifactId>
             <version>${geronimo.spec.activation.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <!--for java2wsdl generation we use JAM , so there should be a dependency on the annogen jar or-->
+        <!--XML Beans-->
+         <dependency>
+            <groupId>annogen</groupId>
+            <artifactId>annogen</artifactId>
+            <version>${annogen.version}</version>
             <properties>
                 <module>true</module>
             </properties>

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java Mon Dec 19 22:35:33 2005
@@ -85,6 +85,9 @@
      */
     public static final String TRANSPORT_HTTP = "http";
 
+    //Parameter name of Service impl class
+    public static final String SERVICE_CLASS = "ServiceClass";
+
     /**
      * Field REQUEST_URL_PREFIX
      */

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java Mon Dec 19 22:35:33 2005
@@ -686,12 +686,10 @@
     }
 
     public void setAxisOperation(AxisOperation axisOperation) {
-        this.axisOperation = axisOperation;
-        this.axisOperationName = axisOperation.getName();
-
         if (axisOperation != null) {
             this.axisOperationName = axisOperation.getName();
         }
+        this.axisOperation = axisOperation;
     }
 
     public void setAxisService(AxisService axisService) {

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java Mon Dec 19 22:35:33 2005
@@ -19,14 +19,8 @@
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.deployment.util.PhasesInfo;
-import org.apache.axis2.description.AxisMessage;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisOperationFactory;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.InOutAxisOperation;
-import org.apache.axis2.description.ModuleConfiguration;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.ParameterInclude;
+import org.apache.axis2.deployment.util.Utils;
+import org.apache.axis2.description.*;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.MessageReceiver;
 import org.apache.axis2.i18n.Messages;
@@ -84,15 +78,15 @@
                     descriptionValue.build();
                     descriptionValue.serialize(writer);
                     writer.flush();
-                    service.setAxisServiceName(writer.toString());
+                    service.setServiceDescription(writer.toString());
                 } else {
-                    service.setAxisServiceName(descriptionElement.getText());
+                    service.setServiceDescription(descriptionElement.getText());
                 }
             } else {
                 OMAttribute serviceNameatt = service_element.getAttribute(new QName(ATTRIBUTE_NAME));
 
                 if (serviceNameatt != null) {
-                    service.setAxisServiceName(serviceNameatt.getAttributeValue());
+                    service.setServiceDescription(serviceNameatt.getAttributeValue());
                 }
             }
 
@@ -130,6 +124,12 @@
                             DeploymentErrorMsgs.OPERATION_PROCESS_ERROR, axisFault.getMessage()));
         }
 
+        //todo this is not the right way pls improve this : Deepal
+        try {
+            Utils.fillAxisService(service);
+        } catch (Exception e) {
+            log.info("Error in generating scheam:" + e.getMessage());
+        }
         return service;
     }
 

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java Mon Dec 19 22:35:33 2005
@@ -63,7 +63,8 @@
     private Log log = LogFactory.getLog(getClass());
 
     private ArrayList buildServiceGroup(InputStream zin, DeploymentEngine engine,
-                                        AxisServiceGroup axisServiceGroup, HashMap wsdlServices, AxisConfiguration axisConfig)
+                                        AxisServiceGroup axisServiceGroup, HashMap wsdlServices,
+                                        AxisConfiguration axisConfig)
             throws XMLStreamException, DeploymentException {
         DescriptionBuilder builder;
         String rootelementName;
@@ -89,6 +90,7 @@
 
             ServiceBuilder serviceBuilder = new ServiceBuilder(axisConfig, axisService);
             AxisService service = serviceBuilder.populateService(services);
+
             ArrayList serviceList = new ArrayList();
 
             serviceList.add(service);

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/util/Utils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/util/Utils.java?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/util/Utils.java Mon Dec 19 22:35:33 2005
@@ -1,11 +1,16 @@
 package org.apache.axis2.deployment.util;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
 import org.apache.axis2.deployment.DeploymentException;
-import org.apache.axis2.description.Flow;
-import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.description.*;
 import org.apache.axis2.engine.Handler;
+import org.apache.axis2.wsdl.java2wsdl.SchemaGenerator;
+import org.apache.axis2.wsdl.java2wsdl.TypeTable;
+import org.apache.wsdl.WSDLConstants;
+import org.codehaus.jam.JMethod;
 
+import javax.xml.namespace.QName;
 import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -141,5 +146,41 @@
         }
 
         return handlerClass;
+    }
+
+    /**
+     * This guy will create a AxisService using java replection
+     */
+    public static void fillAxisService(AxisService axisService) throws Exception {
+        Parameter implInfoParam = axisService.getParameter(Constants.SERVICE_CLASS);
+        String serviceClass = (String) implInfoParam.getValue();
+        ClassLoader serviceClassLoader = axisService.getClassLoader();
+        SchemaGenerator schemaGenerator = new SchemaGenerator(serviceClassLoader,
+                serviceClass, null, null);
+        axisService.setSchema(schemaGenerator.generateSchema());
+
+        JMethod [] method = schemaGenerator.getMethods();
+        TypeTable table = schemaGenerator.getTypeTable();
+
+        for (int i = 0; i < method.length; i++) {
+            JMethod jmethod = method[i];
+            String opName = jmethod.getSimpleName();
+            AxisOperation operation = axisService.getOperation(new QName(opName));
+            if (operation != null) {
+                AxisMessage inMessage = operation.getMessage(
+                        WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+                if (inMessage != null) {
+                    inMessage.setElementQName(table.getComplexScheamType(jmethod.getSimpleName() +
+                            SchemaGenerator.METHOD_REQUEST_WRAPPER));
+                }
+                if (!jmethod.getReturnType().isVoidType()) {
+                    AxisMessage outMessage = operation.getMessage(
+                            WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+                    outMessage.setElementQName(table.getQNamefortheType(jmethod.getSimpleName() +
+                            SchemaGenerator.METHOD_RESPONSE_WRAPPER));
+                }
+            }
+
+        }
     }
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java Mon Dec 19 22:35:33 2005
@@ -2,7 +2,10 @@
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.om.OMElement;
+import org.apache.wsdl.MessageReference;
+import org.apache.wsdl.impl.MessageReferenceImpl;
 
+import javax.xml.namespace.QName;
 import java.util.ArrayList;
 
 /*
@@ -30,10 +33,14 @@
     private ArrayList handlerChain;
     private ParameterInclude parameterinclude;
     private AxisOperation parent;
+    //to keep data in WSDL message refference and to keep the Java2WSDL data
+    // such as SchemaElementName , direction etc.
+    private MessageReference messageReference;
 
     public AxisMessage() {
         parameterinclude = new ParameterIncludeImpl();
         handlerChain = new ArrayList();
+        messageReference = new MessageReferenceImpl();
     }
 
     public void addParameter(Parameter param) throws AxisFault {
@@ -92,5 +99,21 @@
 
     public void setParent(AxisOperation parent) {
         this.parent = parent;
+    }
+
+    public String getDirection() {
+        return messageReference.getDirection();
+    }
+
+    public void setDirection(String direction) {
+        messageReference.setDirection(direction);
+    }
+
+    public QName getElementQName() {
+        return messageReference.getElementQName();
+    }
+
+    public void setElementQName(QName element) {
+        messageReference.setElementQName(element);
     }
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java Mon Dec 19 22:35:33 2005
@@ -22,8 +22,12 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.om.OMElement;
+import org.apache.axis2.wsdl.writer.WOMWriter;
+import org.apache.axis2.wsdl.writer.WOMWriterFactory;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.wsdl.WSDLDescription;
 
 import javax.wsdl.Definition;
 import javax.wsdl.Port;
@@ -33,19 +37,14 @@
 import javax.wsdl.factory.WSDLFactory;
 import javax.xml.namespace.QName;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
+import java.util.*;
 
 /**
  * Class AxisService
  */
 public class AxisService
-
-//extends WSDLServiceImpl
         implements ParameterInclude, DescriptionConstants {
     private Definition definition = null;
     private Log log = LogFactory.getLog(getClass());
@@ -59,7 +58,7 @@
 
     // to store engaged mdodules
     private ArrayList engagedModules = new ArrayList();
-    private String axisServiceName;
+    private String serviceDescription;
 
     // to store the wsdl definition , which is build at the deployment time
     // to keep the time that last update time of the service
@@ -70,6 +69,9 @@
     private AxisServiceGroup parent;
     private ClassLoader serviceClassLoader;
 
+    //to keep the XMLScheam getting either from WSDL or java2wsdl
+    private XmlSchema schema;
+
     /**
      * Constructor AxisService
      */
@@ -301,6 +303,8 @@
 
                 WSDLFactory.newInstance().newWSDLWriter().writeWSDL(wsdlDefinition, out);
                 out.flush();
+
+
             } else {
                 WSDLFactory.newInstance().newWSDLWriter().writeWSDL(wsdlDefinition, out);
                 out.write("<wsdl>This service does not have a WSDL</wsdl>");
@@ -313,13 +317,27 @@
         }
     }
 
+    public void printWSDL(OutputStream out) throws AxisFault {
+        //todo : This is a tempory hack pls imporve me : Deepal
+        AxisService2WOM axisService2WOM = new AxisService2WOM(getSchema(), this, null, null);
+        try {
+            WSDLDescription desc = axisService2WOM.generateWOM();
+            WOMWriter womWriter = WOMWriterFactory.createWriter(org.apache.wsdl.WSDLConstants.WSDL_1_1);
+            womWriter.setdefaultWSDLPrefix("wsdl");
+            womWriter.writeWOM(desc, out);
+
+        } catch (Exception e) {
+            throw new AxisFault(e);
+        }
+    }
+
     /**
-     * To get the description about the service ty67tyuio
+     * To get the description about the service which is sepcified in services.xml
      *
      * @return String
      */
-    public String getAxisServiceName() {
-        return axisServiceName;
+    public String getServiceDescription() {
+        return serviceDescription;
     }
 
     /*
@@ -518,12 +536,12 @@
     }
 
     /**
-     * Set the description about the service
+     * Set the description about the service wchih is specified in services.xml
      *
-     * @param axisServiceName
+     * @param serviceDescription
      */
-    public void setAxisServiceName(String axisServiceName) {
-        this.axisServiceName = axisServiceName;
+    public void setServiceDescription(String serviceDescription) {
+        this.serviceDescription = serviceDescription;
     }
 
     /*
@@ -562,5 +580,13 @@
 
     public void setWSDLDefinition(Definition difDefinition) {
         this.definition = difDefinition;
+    }
+
+    public XmlSchema getSchema() {
+        return schema;
+    }
+
+    public void setSchema(XmlSchema schema) {
+        this.schema = schema;
     }
 }

Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2WOM.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2WOM.java?rev=357929&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2WOM.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2WOM.java Mon Dec 19 22:35:33 2005
@@ -0,0 +1,221 @@
+package org.apache.axis2.description;
+
+import org.apache.axis2.wsdl.builder.WSDLComponentFactory;
+import org.apache.axis2.wsdl.java2wsdl.SchemaGenerator;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.wsdl.*;
+import org.apache.wsdl.extensions.ExtensionConstants;
+import org.apache.wsdl.extensions.ExtensionFactory;
+import org.apache.wsdl.extensions.impl.SOAPAddressImpl;
+import org.apache.wsdl.extensions.impl.SOAPBindingImpl;
+import org.apache.wsdl.extensions.impl.SOAPBodyImpl;
+import org.apache.wsdl.extensions.impl.SOAPOperationImpl;
+import org.apache.wsdl.impl.WSDLDescriptionImpl;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.ByteArrayInputStream;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.Iterator;
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* @author : Deepal Jayasinghe (deepal@apache.org)
+*
+*/
+
+public class AxisService2WOM {
+
+    private XmlSchema schema;
+    private AxisService axisService;
+
+
+    public AxisService2WOM(XmlSchema schema, AxisService service,
+                           String targentNamespece,
+                           String targetNamespecheprefix) {
+        this.schema = schema;
+        this.axisService = service;
+
+        if (targentNamespece != null && !targentNamespece.trim().equals("")) {
+            SchemaGenerator.TARGET_NAMESPACE = targentNamespece;
+        }
+        if (targetNamespecheprefix != null && !targetNamespecheprefix.trim().equals("")) {
+            SchemaGenerator.TARGET_NAMESPACE_PREFIX = targetNamespecheprefix;
+        }
+
+    }
+
+    public WSDLDescription generateWOM() throws Exception {
+        DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
+        DocumentBuilder domBuilder = domFactory.newDocumentBuilder();
+        StringWriter writer = new StringWriter();
+        schema.write(writer);
+        writer.flush();
+        Document doc = domBuilder.parse(new ByteArrayInputStream(writer.toString().getBytes()));
+        Element documentElement = doc.getDocumentElement();
+        WSDLDescription womDescription;
+        WSDLComponentFactory wsdlComponentFactory = new WSDLDescriptionImpl();
+        womDescription = wsdlComponentFactory.createDescription();
+        HashMap namspaseMap = new HashMap();
+        namspaseMap.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
+        namspaseMap.put(SchemaGenerator.TARGET_NAMESPACE_PREFIX, SchemaGenerator.TARGET_NAMESPACE);
+        namspaseMap.put("ns1", "http://org.apache.axis2/xsd");
+        namspaseMap.put("xs", "http://www.w3.org/2001/XMLSchema");
+        womDescription.setNamespaces(namspaseMap);
+        womDescription.setTargetNameSpace(SchemaGenerator.TARGET_NAMESPACE);
+
+        //generating port type
+        WSDLInterface portType = generatePortType(womDescription, wsdlComponentFactory, documentElement);
+        womDescription.addInterface(portType);
+
+        QName bindingName = new QName(SchemaGenerator.TARGET_NAMESPACE, axisService.getName() + "Binding"
+                , SchemaGenerator.TARGET_NAMESPACE_PREFIX);
+        //generating binding
+        WSDLBinding binding = generateBinding(wsdlComponentFactory,
+                portType,
+                bindingName,
+                "document", "literal", "http://schemas.xmlsoap.org/soap/http",
+                "http://www.org.apache.axis2");
+        womDescription.addBinding(binding);
+
+        //generating axisService
+        WSDLService service = generateService(wsdlComponentFactory, binding,
+                axisService.getName());
+        womDescription.addService(service);
+        return womDescription;
+    }
+
+    private WSDLInterface generatePortType(WSDLDescription womDescription,
+                                           WSDLComponentFactory wsdlComponentFactory,
+                                           Element documentElement) {
+        WSDLTypes wsdlTypes = wsdlComponentFactory.createTypes();
+        ExtensionFactory extensionFactory = wsdlComponentFactory.createExtensionFactory();
+        org.apache.wsdl.extensions.Schema schemaExtensibilityElement =
+                (org.apache.wsdl.extensions.Schema) extensionFactory.getExtensionElement(
+                        ExtensionConstants.SCHEMA);
+        wsdlTypes.addExtensibilityElement(schemaExtensibilityElement);
+        schemaExtensibilityElement.setElement(documentElement);
+        womDescription.setTypes(wsdlTypes);
+
+        WSDLInterface portType = womDescription.createInterface();
+        portType.setName(new QName(axisService.getName() + "Port"));
+
+
+        Iterator operations = axisService.getOperations().values().iterator();
+        while (operations.hasNext()) {
+            AxisOperation axisOperation = (AxisOperation) operations.next();
+            WSDLOperation wsdlOperation = womDescription.createOperation();
+            wsdlOperation.setName(axisOperation.getName());
+
+            AxisMessage inaxisMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+            if (inaxisMessage != null) {
+                MessageReference messageRefinput = wsdlComponentFactory.createMessageReference();
+                messageRefinput.setElementQName(inaxisMessage.getElementQName());
+                messageRefinput.setDirection(org.apache.wsdl.WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
+                wsdlOperation.setInputMessage(messageRefinput);
+            }
+
+            AxisMessage outaxisMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+            if (outaxisMessage != null) {
+                MessageReference messageRefout = wsdlComponentFactory.createMessageReference();
+                messageRefout.setElementQName(outaxisMessage.getElementQName());
+                messageRefout.setDirection(org.apache.wsdl.WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
+                wsdlOperation.setOutputMessage(messageRefout);
+            }
+            portType.setOperation(wsdlOperation);
+
+        }
+        return portType;
+    }
+
+    private WSDLService generateService(WSDLComponentFactory wsdlComponentFactory,
+                                        WSDLBinding binding, String ServiceName) {
+        WSDLService service = wsdlComponentFactory.createService();
+        service.setName(new QName(ServiceName));
+        WSDLEndpoint endpoints = wsdlComponentFactory.createEndpoint();
+        endpoints.setBinding(binding);
+        endpoints.setName(new QName(ServiceName + "PortType"));
+        SOAPAddressImpl address = new SOAPAddressImpl();
+        address.setLocationURI("http://127.0.0.1:8080:/axis2/services/" + ServiceName);
+        endpoints.addExtensibilityElement(address);
+        service.setEndpoint(endpoints);
+        return service;
+    }
+
+
+    private WSDLBinding generateBinding(WSDLComponentFactory wsdlComponentFactory,
+                                        WSDLInterface portType, QName bindingName,
+                                        String style,
+                                        String use,
+                                        String trsportURI,
+                                        String namespeceURI) {
+        WSDLBinding binding = wsdlComponentFactory.createBinding();
+        binding.setBoundInterface(portType);
+        binding.setName(bindingName);
+
+        SOAPBindingImpl soapbindingImpl = new SOAPBindingImpl();
+        soapbindingImpl.setStyle(style);
+        soapbindingImpl.setTransportURI(trsportURI);
+        binding.addExtensibilityElement(soapbindingImpl);
+
+        Iterator op_itr = portType.getOperations().keySet().iterator();
+        while (op_itr.hasNext()) {
+            String opName = (String) op_itr.next();
+            WSDLOperation wsdlOperation = portType.getOperation(opName);
+            MessageReference inMessage = wsdlOperation.getInputMessage();
+
+            WSDLBindingOperation bindingoperation = wsdlComponentFactory.createWSDLBindingOperation();
+            bindingoperation.setName(new QName(opName));
+            bindingoperation.setOperation(wsdlOperation);
+            binding.addBindingOperation(bindingoperation);
+
+            SOAPOperationImpl soapOpimpl = new SOAPOperationImpl();
+            soapOpimpl.setStyle(style);
+            //to do heve to set a proper SOAPAction
+            soapOpimpl.setSoapAction(opName);
+            bindingoperation.addExtensibilityElement(soapOpimpl);
+            if (inMessage != null) {
+                WSDLBindingMessageReference bindingInMessage = wsdlComponentFactory.createWSDLBindingMessageReference();
+                bindingInMessage.setDirection(org.apache.wsdl.WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
+                bindingoperation.setInput(bindingInMessage);
+                SOAPBodyImpl requestSoapbody = new SOAPBodyImpl();
+                requestSoapbody.setUse(use);
+                //todo need to fix this
+                requestSoapbody.setNamespaceURI(namespeceURI);
+                bindingInMessage.addExtensibilityElement(requestSoapbody);
+            }
+
+            MessageReference outMessage = wsdlOperation.getOutputMessage();
+            if (outMessage != null) {
+                WSDLBindingMessageReference bindingOutMessage = wsdlComponentFactory.createWSDLBindingMessageReference();
+
+                bindingOutMessage.setDirection(org.apache.wsdl.WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
+                bindingoperation.setOutput(bindingOutMessage);
+                SOAPBodyImpl resSoapbody = new SOAPBodyImpl();
+                resSoapbody.setUse(use);
+                resSoapbody.setNamespaceURI(namespeceURI);
+                bindingOutMessage.addExtensibilityElement(resSoapbody);
+            }
+        }
+        return binding;
+    }
+
+
+}
+

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOnlyAxisOperation.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOnlyAxisOperation.java?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOnlyAxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOnlyAxisOperation.java Mon Dec 19 22:35:33 2005
@@ -51,6 +51,7 @@
 
     private void createMessage() {
         inMessage = new AxisMessage();
+        inMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
         inFaultMessage = new AxisMessage();
         outFaultMessage = new AxisMessage();
         outPhase = new ArrayList();

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOutAxisOperation.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOutAxisOperation.java?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOutAxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOutAxisOperation.java Mon Dec 19 22:35:33 2005
@@ -61,9 +61,11 @@
 
     private void createMessages() {
         inMessage = new AxisMessage();
+        inMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
         inFaultMessage = new AxisMessage();
         outFaultMessage = new AxisMessage();
         outMessage = new AxisMessage();
+        outMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
     }
 
     public AxisMessage getMessage(String label) {

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutOnlyAxisOperation.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutOnlyAxisOperation.java?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutOnlyAxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutOnlyAxisOperation.java Mon Dec 19 22:35:33 2005
@@ -46,6 +46,7 @@
 
     private void createMessage() {
         outMessage = new AxisMessage();
+        outMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
         inFaultMessage = new AxisMessage();
         outFaultMessage = new AxisMessage();
         inPhases = new ArrayList();

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AbstractDispatcher.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AbstractDispatcher.java?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AbstractDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AbstractDispatcher.java Mon Dec 19 22:35:33 2005
@@ -87,7 +87,7 @@
 
             if (axisService != null) {
                 if (log.isDebugEnabled()) {
-                    log.debug("Found AxisService : " + axisService.getAxisServiceName());
+                    log.debug("Found AxisService : " + axisService.getServiceDescription());
                 }
 
                 msgctx.setAxisService(axisService);

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/ListingAgent.java Mon Dec 19 22:35:33 2005
@@ -469,10 +469,11 @@
             if (serviceObj != null) {
                 if (wsdl != null) {
                     res.setContentType("text/xml");
+                    ((AxisService) serviceObj).printWSDL(out);
 
-                    PrintWriter out_writer = new PrintWriter(out);
+//                    PrintWriter out_writer = new PrintWriter(out);
 
-                    ((AxisService) serviceObj).printWSDL(out_writer, filePart);
+//                    ((AxisService) serviceObj).printWSDL(out_writer, filePart);
                     out.flush();
                     out.close();
 

Modified: webservices/axis2/trunk/java/modules/integration/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/project.xml?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/project.xml (original)
+++ webservices/axis2/trunk/java/modules/integration/project.xml Mon Dec 19 22:35:33 2005
@@ -259,6 +259,21 @@
                 <module>true</module>
             </properties>
         </dependency>
+         <!--for java2wsdl generation we use JAM , so there should be a dependency on the annogen jar or-->
+        <!--XML Beans-->
+         <dependency>
+            <groupId>annogen</groupId>
+            <artifactId>annogen</artifactId>
+            <version>${annogen.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+         <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>XmlSchema</artifactId>
+            <version>${XmlSchema.version}</version>
+        </dependency>
 
     </dependencies>
 

Modified: webservices/axis2/trunk/java/modules/samples/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/project.xml?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/project.xml (original)
+++ webservices/axis2/trunk/java/modules/samples/project.xml Mon Dec 19 22:35:33 2005
@@ -211,6 +211,16 @@
                 <module>true</module>
             </properties>
         </dependency>
+         <!--for java2wsdl generation we use JAM , so there should be a dependency on the annogen jar or-->
+        <!--XML Beans-->
+         <dependency>
+            <groupId>annogen</groupId>
+            <artifactId>annogen</artifactId>
+            <version>${annogen.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
     </dependencies>
 
     <!-- build information for the project -->

Modified: webservices/axis2/trunk/java/modules/wsdl/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/project.xml?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/project.xml (original)
+++ webservices/axis2/trunk/java/modules/wsdl/project.xml Mon Dec 19 22:35:33 2005
@@ -108,6 +108,16 @@
             </properties>
             <url>http://www.ibiblio.org/maven/xmlunit/jars/</url>
         </dependency>
+         <!--for java2wsdl generation we use JAM , so there should be a dependency on the annogen jar or-->
+        <!--XML Beans-->
+         <dependency>
+            <groupId>annogen</groupId>
+            <artifactId>annogen</artifactId>
+            <version>${annogen.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
     </dependencies>
 	<!-- add the build properties-->
 	<build>

Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/java2wsdl/Java2WOM.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/java2wsdl/Java2WOM.java?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/java2wsdl/Java2WOM.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/java2wsdl/Java2WOM.java Mon Dec 19 22:35:33 2005
@@ -10,9 +10,9 @@
 import org.apache.wsdl.extensions.impl.SOAPBodyImpl;
 import org.apache.wsdl.extensions.impl.SOAPOperationImpl;
 import org.apache.wsdl.impl.WSDLDescriptionImpl;
-import org.apache.xmlbeans.impl.jam.JMethod;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.codehaus.jam.JMethod;
 
 import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilder;
@@ -100,6 +100,7 @@
         womDescription.addService(service);
         return womDescription;
     }
+
 
     public WSDLInterface generatePortType(WSDLDescription womDescription,
                                           WSDLComponentFactory wsdlComponentFactory,

Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/java2wsdl/Java2WSDL.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/java2wsdl/Java2WSDL.java?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/java2wsdl/Java2WSDL.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/java2wsdl/Java2WSDL.java Mon Dec 19 22:35:33 2005
@@ -35,6 +35,7 @@
         this.classLoader = classLoader;
     }
 
+
     public void generateWSDL() throws Exception {
         SchemaGenerator sg = new SchemaGenerator(classLoader, className, null, null);
         XmlSchema scheam = sg.generateSchema();

Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/java2wsdl/SchemaGenerator.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/java2wsdl/SchemaGenerator.java?rev=357929&r1=357928&r2=357929&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/java2wsdl/SchemaGenerator.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/java2wsdl/SchemaGenerator.java Mon Dec 19 22:35:33 2005
@@ -2,7 +2,7 @@
 
 import org.apache.axis2.wsdl.java2wsdl.bytecode.MethodTable;
 import org.apache.ws.commons.schema.*;
-import org.apache.xmlbeans.impl.jam.*;
+import org.codehaus.jam.*;
 
 import javax.xml.namespace.QName;
 import java.util.Hashtable;
@@ -26,13 +26,14 @@
 */
 
 public class SchemaGenerator {
+
     private ClassLoader classLoader;
     private String className;
-    Hashtable prefixmap;
-    XmlSchemaCollection schemaCollection;
-    XmlSchema schema;
-    TypeTable typeTable;
+    private XmlSchema schema;
+    private TypeTable typeTable;
+    // to keep loadded method using JAM
     private JMethod methods [];
+    //to store byte code method using Axis 1.x codes
     private MethodTable methodTable;
 
     public static String METHOD_REQUEST_WRAPPER = "Request";
@@ -54,11 +55,10 @@
         if (scheamtargetNamespacePrefix != null && !scheamtargetNamespacePrefix.trim().equals("")) {
             SCHEMA_NAMESPASE_PRFIX = scheamtargetNamespacePrefix;
         }
-
-        prefixmap = new Hashtable();
+        Hashtable prefixmap = new Hashtable();
         prefixmap.put(SCHEMA_NAMESPASE_PRFIX, SCHEMA_TARGET_NAMESPASE);
 
-        schemaCollection = new XmlSchemaCollection();
+        XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
 
         schema = new XmlSchema(SCHEMA_TARGET_NAMESPASE, schemaCollection);
         schema.setElementFormDefault(new XmlSchemaForm(XmlSchemaForm.QUALIFIED));
@@ -111,6 +111,9 @@
 
             for (int i = 0; i < methods.length; i++) {
                 JMethod jMethod = methods[i];
+                //no need to think abt this method , since that is system config method
+                if (jMethod.getSimpleName().equals("init"))
+                    continue;
 
                 //it can easily get the annotations
 //                jMethod.getAnnotations();
@@ -174,6 +177,8 @@
     private void generateWrapperElements(JMethod methods[]) {
         for (int i = 0; i < methods.length; i++) {
             JMethod method = methods[i];
+            if (method.getSimpleName().equals("init"))
+                continue;
             genereteWrapperElementforMethod(method);
         }
     }
@@ -200,7 +205,10 @@
         if (paras.length > 0) {
             complexType.setParticle(sequence);
         }
-        String parameterNames [] = methodTable.getParameterNames(methodName);
+        String parameterNames [] = null;
+        if (paras.length > 0) {
+            parameterNames = methodTable.getParameterNames(methodName);
+        }
         for (int j = 0; j < paras.length; j++) {
             JParameter methodParameter = paras[j];
             String paraName = methodParameter.getSimpleName();
@@ -315,7 +323,6 @@
                     elt1.setSchemaTypeName(typeTable.getSimpleSchemaTypeName(propertyName));
                     sequence.getItems().add(elt1);
                     if (isArryType) {
-                        //todo pls check this with Ajith
                         elt1.setMaxOccurs(Long.MAX_VALUE);
 //                        elt1.setMinOccurs(2);
                     }