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 de...@apache.org on 2006/03/27 11:26:45 UTC
svn commit: r389081 [1/2] - in /webservices/axis2/trunk/java: ./ etc/
modules/adb/src/org/apache/axis2/databinding/utils/
modules/codegen/src/org/apache/axis2/wsdl/
modules/codegen/src/org/apache/axis2/wsdl/codegen/ modules/core/
modules/core/src/org/a...
Author: deepal
Date: Mon Mar 27 01:26:40 2006
New Revision: 389081
URL: http://svn.apache.org/viewcvs?rev=389081&view=rev
Log:
-moved java2WSDL into separate module
Added:
webservices/axis2/trunk/java/modules/java2wsdl/
webservices/axis2/trunk/java/modules/java2wsdl/maven.xml
webservices/axis2/trunk/java/modules/java2wsdl/project.xml
webservices/axis2/trunk/java/modules/java2wsdl/src/
webservices/axis2/trunk/java/modules/java2wsdl/src/org/
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Constants.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2OMBuilder.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDL.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLCodegenEngine.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLTask.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/bytecode/
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/bytecode/ChainedParamReader.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/bytecode/ClassReader.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/bytecode/MethodTable.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/bytecode/ParamNameExtractor.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/bytecode/ParamReader.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/utils/
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/utils/Java2WSDLCommandLineOption.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/utils/Java2WSDLCommandLineOptionParser.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/utils/Java2WSDLOptionsValidator.java
webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/utils/TypeTable.java
Removed:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/Java2WSDL.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/Java2WSDLCodegenEngine.java
webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/ant/Java2WSDLTask.java
webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/Java2WSDLGenerator.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/Java2WOMBuilder.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/Java2WSDLBuilder.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/SchemaGenerator.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/TypeTable.java
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/bytecode/
Modified:
webservices/axis2/trunk/java/etc/project.properties
webservices/axis2/trunk/java/maven.xml
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
webservices/axis2/trunk/java/modules/core/project.xml
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/AxisService.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2WOM.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfiguration.java
webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/deployment/ModuleDisEngagementTest.java
webservices/axis2/trunk/java/modules/integration/project.xml
webservices/axis2/trunk/java/modules/saaj/project.xml
webservices/axis2/trunk/java/modules/tool/project.xml
Modified: webservices/axis2/trunk/java/etc/project.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/etc/project.properties?rev=389081&r1=389080&r2=389081&view=diff
==============================================================================
--- webservices/axis2/trunk/java/etc/project.properties (original)
+++ webservices/axis2/trunk/java/etc/project.properties Mon Mar 27 01:26:40 2006
@@ -47,6 +47,7 @@
maven.multiproject.includes=\
modules/common/project.xml,\
+modules/java2wsdl/project.xml,\
modules/adb/project.xml,\
modules/codegen/project.xml,\
modules/wsdl/project.xml,\
Modified: webservices/axis2/trunk/java/maven.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/maven.xml?rev=389081&r1=389080&r2=389081&view=diff
==============================================================================
--- webservices/axis2/trunk/java/maven.xml (original)
+++ webservices/axis2/trunk/java/maven.xml Mon Mar 27 01:26:40 2006
@@ -334,6 +334,7 @@
<ant:mkdir dir="modules/saaj/target/classes"/>
<jar destfile="target/lib/axis2-${pom.currentVersion}.jar">
+ <fileset dir="modules/java2wsdl/target/classes"/>
<fileset dir="modules/core/target/classes"/>
<!-- adding the tool classes. This is needed to get the ant task -->
<fileset dir="modules/tool/target/classes"/>
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java?rev=389081&r1=389080&r2=389081&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java Mon Mar 27 01:26:40 2006
@@ -25,7 +25,6 @@
import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
import org.apache.axis2.AxisFault;
import org.apache.axis2.databinding.typemapping.SimpleTypeMapper;
-import org.apache.axis2.wsdl.builder.SchemaGenerator;
import org.codehaus.jam.JClass;
import org.codehaus.jam.JProperty;
import org.codehaus.jam.JamClassIterator;
@@ -43,6 +42,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Locale;
public class BeanUtil {
@@ -84,7 +84,7 @@
for (int i = 0; i < properties.length; i++) {
JProperty property = properties[i];
PropertyDescriptor propDesc = (PropertyDescriptor) propertMap.get(
- SchemaGenerator.getCorrectName(property.getSimpleName()));
+ getCorrectName(property.getSimpleName()));
if (propDesc == null) {
// JAM does bad thing so I need to add this
continue;
@@ -504,5 +504,22 @@
OMAbstractFactory.getSOAP11Factory(), xr);
return stAXOMBuilder.getDocumentElement();
}
+
+ /**
+ * JAM convert first name of an attribute into UpperCase as an example
+ * if there is a instance variable called foo in a bean , then Jam give that as Foo
+ * so this method is to correct that error
+ *
+ * @param wrongName
+ * @return the right name, using english as the locale for case conversion
+ */
+ private static String getCorrectName(String wrongName) {
+ if (wrongName.length() > 1) {
+ return wrongName.substring(0, 1).toLowerCase(Locale.ENGLISH)
+ + wrongName.substring(1, wrongName.length());
+ } else {
+ return wrongName.substring(0, 1).toLowerCase(Locale.ENGLISH);
+ }
+ }
}
Modified: webservices/axis2/trunk/java/modules/core/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/project.xml?rev=389081&r1=389080&r2=389081&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/project.xml (original)
+++ webservices/axis2/trunk/java/modules/core/project.xml Mon Mar 27 01:26:40 2006
@@ -46,6 +46,12 @@
<artifactId>axis2-common</artifactId>
<version>${pom.currentVersion}</version>
</dependency>
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-java2wsdl</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
+
<!-- external JARs -->
<dependency>
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=389081&r1=389080&r2=389081&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 Mar 27 01:26:40 2006
@@ -16,9 +16,9 @@
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.engine.Handler;
import org.apache.axis2.engine.MessageReceiver;
-import org.apache.axis2.wsdl.builder.SchemaGenerator;
-import org.apache.axis2.wsdl.builder.TypeTable;
import org.apache.wsdl.WSDLConstants;
+import org.apache.ws.java2wsdl.SchemaGenerator;
+import org.apache.ws.java2wsdl.utils.TypeTable;
import org.codehaus.jam.JMethod;
import javax.xml.namespace.QName;
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=389081&r1=389080&r2=389081&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 Mar 27 01:26:40 2006
@@ -18,11 +18,7 @@
package org.apache.axis2.description;
import com.ibm.wsdl.PortImpl;
-import com.ibm.wsdl.extensions.soap.SOAPAddressImpl;
-import com.ibm.wsdl.extensions.soap.SOAPBindingImpl;
-import com.ibm.wsdl.extensions.soap.SOAPBodyImpl;
-import com.ibm.wsdl.extensions.soap.SOAPConstants;
-import com.ibm.wsdl.extensions.soap.SOAPOperationImpl;
+import com.ibm.wsdl.extensions.soap.*;
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
@@ -38,28 +34,21 @@
import org.apache.axis2.transport.TransportListener;
import org.apache.axis2.util.PolicyUtil;
import org.apache.axis2.util.XMLUtils;
-import org.apache.axis2.wsdl.builder.SchemaGenerator;
-import org.apache.axis2.wsdl.builder.TypeTable;
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.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.java2wsdl.SchemaGenerator;
+import org.apache.ws.java2wsdl.utils.TypeTable;
import org.apache.wsdl.WSDLConstants;
import org.apache.wsdl.WSDLDescription;
import org.codehaus.jam.JMethod;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
-import javax.wsdl.Binding;
-import javax.wsdl.BindingInput;
-import javax.wsdl.BindingOperation;
-import javax.wsdl.BindingOutput;
-import javax.wsdl.Definition;
-import javax.wsdl.Port;
-import javax.wsdl.Service;
-import javax.wsdl.WSDLException;
+import javax.wsdl.*;
import javax.wsdl.extensions.soap.SOAPAddress;
import javax.wsdl.extensions.soap.SOAPOperation;
import javax.wsdl.factory.WSDLFactory;
@@ -70,12 +59,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
/**
* Class AxisService
@@ -880,10 +864,14 @@
}
public boolean isEngaged(QName moduleName) {
+ AxisModule module = getAxisConfiguration().getModule(moduleName);
+ if (module == null) {
+ return false;
+ }
Iterator engagedModuleItr = engagedModules.iterator();
while (engagedModuleItr.hasNext()) {
AxisModule axisModule = (AxisModule) engagedModuleItr.next();
- if (axisModule.getName().getLocalPart().equals(moduleName.getLocalPart())) {
+ if (axisModule.getName().getLocalPart().equals(module.getName().getLocalPart())) {
return true;
}
}
@@ -918,7 +906,7 @@
WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
reader.setFeature("javax.wsdl.importDocuments", true);
Definition wsdlDefinition = reader.readWSDL(null, doc);
- return createClientSideAxisService(wsdlDefinition,wsdlServiceName,portName,options);
+ return createClientSideAxisService(wsdlDefinition, wsdlServiceName, portName, options);
} catch (IOException e) {
throw new AxisFault("IOException" + e.getMessage());
} catch (ParserConfigurationException e) {
Modified: 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=389081&r1=389080&r2=389081&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2WOM.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService2WOM.java Mon Mar 27 01:26:40 2006
@@ -2,11 +2,11 @@
import org.apache.axis2.Constants;
import org.apache.axis2.i18n.Messages;
-import org.apache.axis2.wsdl.builder.SchemaGenerator;
import org.apache.axis2.wsdl.builder.WSDLComponentFactory;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.policy.PolicyConstants;
import org.apache.ws.policy.PolicyReference;
+import org.apache.ws.java2wsdl.SchemaGenerator;
import org.apache.wsdl.Component;
import org.apache.wsdl.MessageReference;
import org.apache.wsdl.WSDLBinding;
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java?rev=389081&r1=389080&r2=389081&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java Mon Mar 27 01:26:40 2006
@@ -115,6 +115,10 @@
engagedModules.add(moduleName);
}
+ public void removeFromEngageList(QName moduleName) {
+ engagedModules.remove(moduleName);
+ }
+
public void engageModule(AxisModule module) throws AxisFault {
QName moduleName = module.getName();
for (Iterator iterator = engagedModules.iterator(); iterator.hasNext();) {
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfiguration.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfiguration.java?rev=389081&r1=389080&r2=389081&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfiguration.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfiguration.java Mon Mar 27 01:26:40 2006
@@ -21,14 +21,7 @@
import org.apache.axis2.Constants;
import org.apache.axis2.deployment.DeploymentConstants;
import org.apache.axis2.deployment.util.PhasesInfo;
-import org.apache.axis2.description.AxisDescription;
-import org.apache.axis2.description.AxisModule;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.AxisServiceGroup;
-import org.apache.axis2.description.ModuleConfiguration;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.description.*;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.phaseresolver.PhaseResolver;
import org.apache.axis2.util.Utils;
@@ -36,12 +29,7 @@
import org.apache.commons.logging.LogFactory;
import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
/**
* Class AxisConfigurationImpl
@@ -307,6 +295,11 @@
while (serviceItr.hasNext()) {
AxisService axisService = (AxisService) serviceItr.next();
axisService.disEngageModule(module);
+ }
+ Iterator serviceGroups = getServiceGroups();
+ while (serviceGroups.hasNext()) {
+ AxisServiceGroup axisServiceGroup = (AxisServiceGroup) serviceGroups.next();
+ axisServiceGroup.removeFromEngageList(module.getName());
}
engagedModules.remove(module.getName());
}
Modified: webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/deployment/ModuleDisEngagementTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/deployment/ModuleDisEngagementTest.java?rev=389081&r1=389080&r2=389081&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/deployment/ModuleDisEngagementTest.java (original)
+++ webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/deployment/ModuleDisEngagementTest.java Mon Mar 27 01:26:40 2006
@@ -97,6 +97,15 @@
assertEquals(0, userPhase.getHandlerCount());
}
+
+ public void testGlobalChcek() throws AxisFault {
+ AxisModule module = er.getModule(new QName("testModule"));
+ assertNotNull(module);
+ er.engageModule(module.getName());
+ er.disEngageModule(module);
+ er.engageModule(module.getName());
+ }
+
public void testOperationDisengagement() throws AxisFault {
AxisModule module = er.getModule(new QName("testModule"));
assertNotNull(module);
Modified: webservices/axis2/trunk/java/modules/integration/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/project.xml?rev=389081&r1=389080&r2=389081&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/project.xml (original)
+++ webservices/axis2/trunk/java/modules/integration/project.xml Mon Mar 27 01:26:40 2006
@@ -42,6 +42,12 @@
<artifactId>axis2-security</artifactId>
<version>${pom.currentVersion}</version>
</dependency>
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-java2wsdl</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
+
<dependency>
<groupId>axis2</groupId>
Added: webservices/axis2/trunk/java/modules/java2wsdl/maven.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/java2wsdl/maven.xml?rev=389081&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/maven.xml (added)
+++ webservices/axis2/trunk/java/modules/java2wsdl/maven.xml Mon Mar 27 01:26:40 2006
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- $Revision: 1.21 $ $Date: 2004-10-27 20:54:09 +0600 (Wed, 27 Oct 2004) $ -->
+
+<project default="jar"
+ xmlns:j="jelly:core"
+ xmlns:u="jelly:util"
+ xmlns:maven="jelly:maven"
+ xmlns:deploy="deploy"
+ xmlns:ant="jelly:ant">
+</project>
Added: webservices/axis2/trunk/java/modules/java2wsdl/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/java2wsdl/project.xml?rev=389081&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/project.xml (added)
+++ webservices/axis2/trunk/java/modules/java2wsdl/project.xml Mon Mar 27 01:26:40 2006
@@ -0,0 +1,152 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*
+ * Copyright 2001-2004 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.
+ */
+ -->
+<project>
+ <pomVersion>3</pomVersion>
+ <extend>../../etc/project.xml</extend>
+
+ <name>Apache Axis 2.0 - Core</name>
+ <id>axis2-java2wsdl</id>
+ <groupId>axis2</groupId>
+ <description>To generate WSDL file for a given Java class</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>ws-commons</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>${axiom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>ws-commons</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>${axiom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>${ant.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+ <!-- external JARs -->
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>${commons.logging.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${log4j.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ <url>http://dist.codehaus.org/stax/jars/</url>
+ </dependency>
+ <dependency>
+ <groupId>${stax.impl.groupid}</groupId>
+ <artifactId>${stax.impl.artifactid}</artifactId>
+ <version>${stax.impl.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>${stax.api.version}</version>
+ <properties>
+ <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>${geronimo.spec.groupid}</groupId>
+ <artifactId>${geronimo.spec.javamail.artifactid}</artifactId>
+ <version>${geronimo.spec.javamail.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>geronimo-spec</groupId>
+ <artifactId>geronimo-spec-jms</artifactId>
+ <version>${geronimo.spec.jms.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>${geronimo.spec.groupid}</groupId>
+ <artifactId>${geronimo.spec.activation.artifactid}</artifactId>
+ <version>${geronimo.spec.activation.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>jaxen</groupId>
+ <artifactId>jaxen</artifactId>
+ <version>${jaxen.version}</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ <url>http://www.ibiblio.org/maven/jaxen/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>
+ <!-- Added this to support WS Policy in Axis2 -->
+ </dependencies>
+ <build>
+ <resources>
+ <resource>
+ <directory>conf</directory>
+ <excludes>
+ <exclude>**/*.properties</exclude>
+ </excludes>
+ </resource>
+ <resource>
+ <directory>src</directory>
+ <includes>
+ <include>**/*.properties</include>
+ <include>**/*.xml</include>
+ <include>**/*.xsl</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+ <reports/>
+</project>
\ No newline at end of file
Added: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Constants.java?rev=389081&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Constants.java (added)
+++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Constants.java Mon Mar 27 01:26:40 2006
@@ -0,0 +1,157 @@
+package org.apache.ws.java2wsdl;
+/*
+* 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 interface Constants {
+
+ String DEFAULT_SOAP_NAMESPACE_PREFIX = "soap";
+ String DEFAULT_WSDL_NAMESPACE_PREFIX = "wsdl";
+ String DEFAULT_SCHEMA_NAMESPACE_PREFIX = "xs";
+ String BINDING_NAME_SUFFIX = "Binding";
+ String PORT_TYPE_SUFFIX = "PortType";
+ String PORT_NAME_SUFFIX = "Port";
+ String DEFAULT_TARGET_NAMESPACE = "http://ws.apache.org/axis2";
+ String WSDL_NAMESPACE = "http://schemas.xmlsoap.org/wsdl/";
+ String DEFAULT_TARGET_NAMESPACE_PREFIX = "axis2";
+
+ String AXIS2_XSD = "http://org.apache.axis2/xsd";
+ String DEFAULT_SOAP_NAMESPACE = "http://schemas.xmlsoap.org/wsdl/soap/";
+ String TARGETNAMESPACE_PREFIX = "tns";
+ String SCHEMA_NAME_SPACE = "http://www.w3.org/2001/XMLSchema";
+ String MESSAGE_LOCAL_NAME = "message";
+ String ATTRIBUTE_NAME = "name";
+ String REQUEST_MESSAGE = "RequestMessage";
+ String RESPONSE_MESSAGE = "ReponseMessage";
+ String REQUEST = "Request";
+ String RESPONSE = "Reponse";
+ String PORT_TYPE_LOCAL_NAME = "portType";
+ String OPERATION_LOCAL_NAME = "operation";
+ String IN_PUT_LOCAL_NAME = "input";
+ String OUT_PUT_LOCAL_NAME = "output";
+ String SERVICE_LOCAL_NAME = "service";
+ String BINDING_LOCAL_NAME = "binding";
+ String TRANSPORT_URI = "http://schemas.xmlsoap.org/soap/http";
+ String PORT = "port";
+ String PART_ATTRIBUTE_NAME = "part";
+ String ELEMENT_ATTRIBUTE_NAME = "element";
+
+ String SOAP_ADDRESS = "address";
+ String LOCATION = "location";
+ String TRANSPORT = "transport";
+ String STYLE = "style";
+ String SOAP_ACTION = "soapAction";
+ String SOAP_BODY = "body";
+ String SOAP_USE = "use";
+ String DOCUMNT = "document";
+ String LITERAL = "literal";
+ String DEFAULT_LOCATION_URL = "http://localhost:8080/axis2/services/";
+
+
+ public static final String URI_SOAP11_ENV =
+ "http://schemas.xmlsoap.org/soap/envelope/";
+ public static final String URI_SOAP12_ENV =
+ "http://www.w3.org/2003/05/soap-envelope";
+
+ public static final String URI_LITERAL_ENC = "";
+
+ //
+ // SOAP-ENC Namespaces
+ //
+ public static final String URI_SOAP11_ENC =
+ "http://schemas.xmlsoap.org/soap/encoding/";
+ public static final String URI_SOAP12_ENC =
+ "http://www.w3.org/2003/05/soap-encoding";
+ public static final String URI_SOAP12_NOENC =
+ "http://www.w3.org/2003/05/soap-envelope/encoding/none";
+
+ // Misc SOAP Namespaces / URIs
+ public static final String URI_SOAP11_NEXT_ACTOR =
+ "http://schemas.xmlsoap.org/soap/actor/next";
+ public static final String URI_SOAP12_NEXT_ROLE =
+ "http://www.w3.org/2003/05/soap-envelope/role/next";
+ /**
+ * @deprecated use URI_SOAP12_NEXT_ROLE
+ */
+ public static final String URI_SOAP12_NEXT_ACTOR = URI_SOAP12_NEXT_ROLE;
+
+ public static final String URI_SOAP12_RPC =
+ "http://www.w3.org/2003/05/soap-rpc";
+
+ public static final String URI_SOAP12_NONE_ROLE =
+ "http://www.w3.org/2003/05/soap-envelope/role/none";
+ public static final String URI_SOAP12_ULTIMATE_ROLE =
+ "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver";
+
+ public static final String URI_SOAP11_HTTP =
+ "http://schemas.xmlsoap.org/soap/http";
+ public static final String URI_SOAP12_HTTP =
+ "http://www.w3.org/2003/05/http";
+
+ public static final String NS_URI_XMLNS =
+ "http://www.w3.org/2000/xmlns/";
+
+ public static final String NS_URI_XML =
+ "http://www.w3.org/XML/1998/namespace";
+
+ //
+ // Schema XSD Namespaces
+ //
+ public static final String URI_1999_SCHEMA_XSD =
+ "http://www.w3.org/1999/XMLSchema";
+ public static final String URI_2000_SCHEMA_XSD =
+ "http://www.w3.org/2000/10/XMLSchema";
+ public static final String URI_2001_SCHEMA_XSD =
+ "http://www.w3.org/2001/XMLSchema";
+
+ public static final String URI_DEFAULT_SCHEMA_XSD = URI_2001_SCHEMA_XSD;
+
+ interface Java2WSDLConstants {
+ String OUTPUT_LOCATION_OPTION = "o";
+ String OUTPUT_FILENAME_OPTION = "of";
+ String CLASSNAME_OPTION = "cn";
+ String CLASSPATH_OPTION = "cp";
+ String TARGET_NAMESPACE_OPTION = "tn";
+ String TARGET_NAMESPACE_PREFIX_OPTION = "tp";
+ String SCHEMA_TARGET_NAMESPACE_OPTION = "stn";
+ String SCHEMA_TARGET_NAMESPACE_PREFIX_OPTION = "stp";
+ String SERVICE_NAME_OPTION = "sn";
+ String STYLE_OPTION = "st";
+ String USE_OPTION = "u";
+ String LOCATION_OPTION = "l";
+
+ //long option constants
+ String OUTPUT_LOCATION_OPTION_LONG = "output";
+ String TARGET_NAMESPACE_OPTION_LONG = "targetNamespace";
+ String TARGET_NAMESPACE_PREFIX_OPTION_LONG = "targetNamespacePrefix";
+ String SERVICE_NAME_OPTION_LONG = "serviceName";
+ String CLASSNAME_OPTION_LONG = "className";
+ String CLASSPATH_OPTION_LONG = "classPath";
+ String OUTPUT_FILENAME_OPTION_LONG = "outputFilename";
+ String SCHEMA_TARGET_NAMESPACE_OPTION_LONG = "schemaTargetnamespace";
+ String SCHEMA_TARGET_NAMESPACE_PREFIX_OPTION_LONG = "schemaTargetnamespacePrefix";
+ String STYLE_OPTION_LONG = "style";
+ String USE_OPTION_LONG = "use";
+ String LOCATION_OPTION_LONG = "location";
+
+
+ }
+
+ public static final String SOLE_INPUT = "SOLE_INPUT";
+
+}
Added: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2OMBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2OMBuilder.java?rev=389081&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2OMBuilder.java (added)
+++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2OMBuilder.java Mon Mar 27 01:26:40 2006
@@ -0,0 +1,243 @@
+package org.apache.ws.java2wsdl;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.codehaus.jam.JMethod;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayInputStream;
+import java.io.StringWriter;
+/*
+* 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 Java2OMBuilder implements Constants {
+
+ private JMethod method [];
+ private XmlSchema schema;
+ private String serviceName;
+ private String targetNamespace;
+ private OMNamespace ns1;
+ private OMNamespace soap;
+ private OMNamespace tns;
+ private OMNamespace wsdl;
+
+ private String style;
+ private String use;
+ private String locationURL;
+
+ public Java2OMBuilder(JMethod[] method,
+ XmlSchema schema,
+ String serviceName,
+ String targetNamespace,
+ String style,
+ String use,
+ String locationURL) {
+ this.method = method;
+ this.schema = schema;
+ if (style == null) {
+ this.style = DOCUMNT;
+ } else {
+ this.style = style;
+ }
+ if (use == null) {
+ this.use = LITERAL;
+ } else {
+ this.use = use;
+ }
+
+ if (locationURL == null) {
+ this.locationURL = DEFAULT_LOCATION_URL;
+ } else {
+ this.locationURL = locationURL;
+ }
+ this.serviceName = serviceName;
+
+ if (targetNamespace != null && !targetNamespace.trim().equals("")) {
+ this.targetNamespace = targetNamespace;
+ } else {
+ this.targetNamespace = DEFAULT_TARGET_NAMESPACE;
+ }
+ }
+
+ public OMElement generateOM() throws Exception {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ wsdl = fac.createOMNamespace(WSDL_NAMESPACE,
+ DEFAULT_WSDL_NAMESPACE_PREFIX);
+ OMElement ele = fac.createOMElement("definitions", wsdl);
+ ns1 = ele.declareNamespace(AXIS2_XSD, "ns1");
+ ele.declareNamespace(SCHEMA_NAME_SPACE, DEFAULT_SCHEMA_NAMESPACE_PREFIX);
+ soap = ele.declareNamespace(DEFAULT_SOAP_NAMESPACE, DEFAULT_SOAP_NAMESPACE_PREFIX);
+ tns = ele.declareNamespace(DEFAULT_TARGET_NAMESPACE, TARGETNAMESPACE_PREFIX);
+ ele.addAttribute("targetNamespace", DEFAULT_TARGET_NAMESPACE, null);
+ OMElement wsdlTypes = fac.createOMElement("type", wsdl);
+ StringWriter writer = new StringWriter();
+ schema.write(writer);
+ XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(new
+ ByteArrayInputStream(writer.toString().getBytes()));
+
+ StAXOMBuilder staxOMBuilder = new
+ StAXOMBuilder(fac, xmlReader);
+ wsdlTypes.addChild(staxOMBuilder.getDocumentElement());
+ ele.addChild(wsdlTypes);
+ generateMessages(fac, ele);
+ generatePortType(fac, ele);
+ generateBinding(fac, ele);
+ generateService(fac, ele);
+ return ele;
+ }
+
+ private void generateMessages(OMFactory fac,
+ OMElement defintions) {
+ for (int i = 0; i < method.length; i++) {
+ JMethod jmethod = method[i];
+ //Request Message
+ OMElement requestMessge = fac.createOMElement(MESSAGE_LOCAL_NAME, wsdl);
+ requestMessge.addAttribute(ATTRIBUTE_NAME, jmethod.getSimpleName()
+ + REQUEST_MESSAGE, null);
+ defintions.addChild(requestMessge);
+ OMElement requestPart = fac.createOMElement(PART_ATTRIBUTE_NAME, wsdl);
+ requestMessge.addChild(requestPart);
+ requestPart.addAttribute(ATTRIBUTE_NAME, "part1", null);
+ requestPart.addAttribute(ELEMENT_ATTRIBUTE_NAME,
+ ns1.getPrefix() + ":" + jmethod.getSimpleName()
+ + REQUEST, null);
+ //Response Message
+ OMElement responseMessge = fac.createOMElement(MESSAGE_LOCAL_NAME, wsdl);
+ responseMessge.addAttribute(ATTRIBUTE_NAME,
+ jmethod.getSimpleName() + RESPONSE_MESSAGE, null);
+ defintions.addChild(responseMessge);
+ OMElement responsePart = fac.createOMElement(PART_ATTRIBUTE_NAME, wsdl);
+ responseMessge.addChild(responsePart);
+ responsePart.addAttribute(ATTRIBUTE_NAME, "part1", null);
+ responsePart.addAttribute(ELEMENT_ATTRIBUTE_NAME,
+ ns1.getPrefix() + ":" + jmethod.getSimpleName() + RESPONSE, null);
+ }
+ }
+
+ /**
+ * Generate the porttypes
+ */
+ private void generatePortType(OMFactory fac,
+ OMElement defintions) {
+ OMElement portType = fac.createOMElement(PORT_TYPE_LOCAL_NAME, wsdl);
+ defintions.addChild(portType);
+ portType.addAttribute(ATTRIBUTE_NAME, serviceName + PORT_TYPE_SUFFIX, null);
+ //adding message refs
+ for (int i = 0; i < method.length; i++) {
+ JMethod jmethod = method[i];
+ OMElement operation = fac.createOMElement(OPERATION_LOCAL_NAME, wsdl);
+ portType.addChild(operation);
+ operation.addAttribute(ATTRIBUTE_NAME, jmethod.getSimpleName(), null);
+
+ OMElement input = fac.createOMElement(IN_PUT_LOCAL_NAME, wsdl);
+ input.addAttribute(MESSAGE_LOCAL_NAME, tns.getPrefix() + ":"
+ + jmethod.getSimpleName() + REQUEST_MESSAGE, null);
+ operation.addChild(input);
+
+ OMElement output = fac.createOMElement(OUT_PUT_LOCAL_NAME, wsdl);
+ output.addAttribute(MESSAGE_LOCAL_NAME, tns.getPrefix() + ":"
+ + jmethod.getSimpleName() + RESPONSE_MESSAGE, null);
+ operation.addChild(output);
+ }
+
+ }
+
+ /**
+ * Generate the service
+ */
+ public void generateService(OMFactory fac,
+ OMElement defintions) {
+ OMElement service = fac.createOMElement(SERVICE_LOCAL_NAME, wsdl);
+ defintions.addChild(service);
+ service.addAttribute(ATTRIBUTE_NAME, serviceName, null);
+ OMElement port = fac.createOMElement(PORT, wsdl);
+ service.addChild(port);
+ port.addAttribute(ATTRIBUTE_NAME, serviceName + PORT, null);
+ port.addAttribute(BINDING_LOCAL_NAME, tns.getPrefix() + ":" +
+ serviceName + BINDING_NAME_SUFFIX, null);
+ addExtensionElemnet(fac, port, SOAP_ADDRESS, LOCATION,
+ locationURL + serviceName);
+ }
+
+
+ /**
+ * Generate the bindings
+ */
+ private void generateBinding(OMFactory fac,
+ OMElement defintions) {
+ OMElement binding = fac.createOMElement(BINDING_LOCAL_NAME, wsdl);
+ defintions.addChild(binding);
+ binding.addAttribute(ATTRIBUTE_NAME, serviceName + BINDING_NAME_SUFFIX, null);
+ binding.addAttribute("type", tns.getPrefix() + ":" + serviceName + PORT_TYPE_SUFFIX, null);
+
+ addExtensionElemnet(fac, binding, BINDING_LOCAL_NAME,
+ TRANSPORT, TRANSPORT_URI,
+ STYLE, style);
+
+ for (int i = 0; i < method.length; i++) {
+ JMethod jmethod = method[i];
+ OMElement operation = fac.createOMElement(OPERATION_LOCAL_NAME, wsdl);
+ binding.addChild(operation);
+ addExtensionElemnet(fac, operation, OPERATION_LOCAL_NAME,
+ SOAP_ACTION, jmethod.getSimpleName(),
+ STYLE, style);
+ operation.addAttribute(ATTRIBUTE_NAME, jmethod.getSimpleName(), null);
+
+ OMElement input = fac.createOMElement(IN_PUT_LOCAL_NAME, wsdl);
+ addExtensionElemnet(fac, input, SOAP_BODY, SOAP_USE, use, "namespace",
+ targetNamespace);
+ operation.addChild(input);
+
+ OMElement output = fac.createOMElement(OUT_PUT_LOCAL_NAME, wsdl);
+ addExtensionElemnet(fac, output, SOAP_BODY, SOAP_USE, use, "namespace",
+ targetNamespace);
+ operation.addChild(output);
+ }
+ }
+
+ private void addExtensionElemnet(OMFactory fac,
+ OMElement element,
+ String name,
+ String att1Name,
+ String att1Value,
+ String att2Name,
+ String att2Value) {
+ OMElement soapbinding = fac.createOMElement(name, soap);
+ element.addChild(soapbinding);
+ soapbinding.addAttribute(att1Name, att1Value, null);
+ soapbinding.addAttribute(att2Name, att2Value, null);
+ }
+
+ private void addExtensionElemnet(OMFactory fac,
+ OMElement element,
+ String name,
+ String att1Name,
+ String att1Value) {
+ OMElement soapbinding = fac.createOMElement(name, soap);
+ element.addChild(soapbinding);
+ soapbinding.addAttribute(att1Name, att1Value, null);
+ }
+
+
+}
Added: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDL.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDL.java?rev=389081&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDL.java (added)
+++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDL.java Mon Mar 27 01:26:40 2006
@@ -0,0 +1,65 @@
+package org.apache.ws.java2wsdl;
+
+import org.apache.ws.java2wsdl.utils.Java2WSDLCommandLineOptionParser;
+import org.apache.ws.java2wsdl.utils.Java2WSDLOptionsValidator;
+/*
+* 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 Java2WSDL {
+ public static void main(String[] args) {
+ Java2WSDLCommandLineOptionParser commandLineOptionParser = new Java2WSDLCommandLineOptionParser(
+ args);
+ // validate the arguments
+ validateCommandLineOptions(commandLineOptionParser);
+ try {
+ new Java2WSDLCodegenEngine(commandLineOptionParser.getAllOptions()).generate();
+ } catch (Exception e) {
+ System.out.println("An error occured while generating code" + e.getMessage());
+ }
+ }
+
+ public static void printUsage() {
+ System.out.println("Usage java2wsdl -cn <fully qualified class name> : class file name");
+ System.out.println("-o <output Location> : output file location");
+ System.out.println("-cp <class path uri> : list of classpath entries - (urls)");
+ System.out.println("-tn <target namespace> : target namespace");
+ System.out.println("-tp <target namespace prefix> : target namespace prefix");
+ System.out.println("-stn <schema target namespace> : target namespace for schema");
+ System.out.println("-stp <schema target namespace prefix> : target namespace prefix for schema");
+ System.out.println("-sn <service name> : service name");
+ System.out.println("-of <output file name> : output file name for the WSDL");
+ System.out.println("-st <binding style> : style for the WSDL");
+ System.out.println("-u <binding use> : use for the WSDL");
+ System.out.println("-l <soap address> : address of the port for the WSDL");
+ System.exit(0);
+ }
+
+
+ private static void validateCommandLineOptions(
+ Java2WSDLCommandLineOptionParser parser) {
+ if (parser.getAllOptions().size() == 0) {
+ printUsage();
+ } else if (parser.getInvalidOptions(new Java2WSDLOptionsValidator()).size() > 0) {
+ printUsage();
+ }
+
+ }
+
+}
+
Added: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java?rev=389081&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java (added)
+++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java Mon Mar 27 01:26:40 2006
@@ -0,0 +1,164 @@
+package org.apache.ws.java2wsdl;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.ws.commons.schema.XmlSchema;
+
+import java.io.OutputStream;
+/*
+* 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.
+*
+*
+*/
+
+public class Java2WSDLBuilder {
+
+ private OutputStream out;
+ private String className;
+ private ClassLoader classLoader;
+ private String wsdlPrefix = "wsdl";
+
+ private String serviceName = null;
+
+ //these apply for the WSDL
+ private String targetNamespace = null;
+ private String targetNamespacePrefix = null;
+
+ private String schemaTargetNamespace = null;
+ private String schemaTargetNamespacePrefix = null;
+ private String style = Constants.DOCUMNT;
+ private String use = Constants.LITERAL;
+ private String locationUri = Constants.DEFAULT_LOCATION_URL;
+
+ public String getSchemaTargetNamespace() {
+ return schemaTargetNamespace;
+ }
+
+ public String getStyle() {
+ return style;
+ }
+
+ public String getLocationUri() {
+ return locationUri;
+ }
+
+ public void setLocationUri(String locationUri) {
+ this.locationUri = locationUri;
+ }
+
+ public void setStyle(String style) {
+ this.style = style;
+ }
+
+ public String getUse() {
+ return use;
+ }
+
+ public void setUse(String use) {
+ this.use = use;
+ }
+
+ public void setSchemaTargetNamespace(String schemaTargetNamespace) {
+ this.schemaTargetNamespace = schemaTargetNamespace;
+ }
+
+ public String getSchemaTargetNamespacePrefix() {
+ return schemaTargetNamespacePrefix;
+ }
+
+ public void setSchemaTargetNamespacePrefix(String schemaTargetNamespacePrefix) {
+ this.schemaTargetNamespacePrefix = schemaTargetNamespacePrefix;
+ }
+
+ public String getTargetNamespace() {
+ return targetNamespace;
+ }
+
+ public void setTargetNamespace(String targetNamespace) {
+ this.targetNamespace = targetNamespace;
+ }
+
+ public String getTargetNamespacePrefix() {
+ return targetNamespacePrefix;
+ }
+
+ public void setTargetNamespacePrefix(String targetNamespacePrefix) {
+ this.targetNamespacePrefix = targetNamespacePrefix;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+
+ public String getWsdlPrefix() {
+ return wsdlPrefix;
+ }
+
+ public void setWsdlPrefix(String wsdlPrefix) {
+ this.wsdlPrefix = wsdlPrefix;
+ }
+
+ /**
+ * @param out
+ * @param className
+ * @param classLoader
+ */
+ public Java2WSDLBuilder(OutputStream out, String className, ClassLoader classLoader) {
+ this.out = out;
+ this.className = className;
+ this.classLoader = classLoader;
+ }
+
+
+ /**
+ * Externally visible generator method
+ *
+ * @throws Exception
+ */
+ public void generateWSDL() throws Exception {
+ SchemaGenerator sg = new SchemaGenerator(classLoader, className,
+ schemaTargetNamespace, schemaTargetNamespacePrefix);
+ XmlSchema schema = sg.generateSchema();
+ Java2OMBuilder java2OMBuilder = new Java2OMBuilder(sg.getMethods(),
+ schema,
+ serviceName == null ? simpleClassName(className) : serviceName,
+ targetNamespace,
+ style,
+ use,
+ locationUri);
+ OMElement wsdlElemnet = java2OMBuilder.generateOM();
+ wsdlElemnet.serialize(out);
+ out.flush();
+ out.close();
+ }
+
+ /**
+ * A method to strip the fully qualified className to a simple classname
+ *
+ * @param qualifiedName
+ */
+ private String simpleClassName(String qualifiedName) {
+ int index = qualifiedName.lastIndexOf(".");
+ if (index > 0) {
+ return qualifiedName.substring(index + 1, qualifiedName.length());
+ }
+ return qualifiedName;
+ }
+}
+
Added: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLCodegenEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLCodegenEngine.java?rev=389081&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLCodegenEngine.java (added)
+++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLCodegenEngine.java Mon Mar 27 01:26:40 2006
@@ -0,0 +1,207 @@
+package org.apache.ws.java2wsdl;
+
+import org.apache.ws.java2wsdl.utils.Java2WSDLCommandLineOption;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Map;
+/*
+* 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.
+*
+*/
+
+public class Java2WSDLCodegenEngine implements Constants {
+ private Java2WSDLBuilder java2WsdlBuilder;
+ public static final String WSDL_FILENAME_SUFFIX = ".wsdl";
+
+ public Java2WSDLCodegenEngine(Map optionsMap) throws Exception {
+ //create a new Java2WSDLBuilder and populate it
+ File outputFolder;
+
+ Java2WSDLCommandLineOption option = loadOption(Java2WSDLConstants.OUTPUT_LOCATION_OPTION,
+ Java2WSDLConstants.OUTPUT_LOCATION_OPTION_LONG, optionsMap);
+ String outputFolderName = option == null ? System.getProperty("user.dir") : option.getOptionValue();
+
+
+ outputFolder = new File(outputFolderName);
+ if (!outputFolder.exists()) {
+ outputFolder.mkdir();
+ } else if (!outputFolder.isDirectory()) {
+ throw new Exception("The specivied location " + outputFolderName + "is not a folder");
+ }
+
+ option = loadOption(Java2WSDLConstants.CLASSNAME_OPTION, Java2WSDLConstants.CLASSNAME_OPTION_LONG, optionsMap);
+ String className = option == null ? null : option.getOptionValue();
+
+ if (className == null || className.equals("")) {
+ throw new Exception("class name must be present!");
+ }
+
+ option = loadOption(Java2WSDLConstants.OUTPUT_FILENAME_OPTION,
+ Java2WSDLConstants.OUTPUT_FILENAME_OPTION_LONG, optionsMap);
+ String outputFileName = option == null ? null : option.getOptionValue();
+ //derive a file name from the class name if the filename is not specified
+ if (outputFileName == null) {
+ outputFileName = getSimpleClassName(className) + WSDL_FILENAME_SUFFIX;
+ }
+
+ //first create a file in the given location
+ File outputFile = new File(outputFolder, outputFileName);
+ FileOutputStream out;
+ try {
+ if (!outputFile.exists()) {
+ outputFile.createNewFile();
+ }
+ out = new FileOutputStream(outputFile);
+ } catch (IOException e) {
+ throw new Exception(e);
+ }
+
+ //if the class path is present, create a URL class loader with those
+ //class path entries present. if not just take the TCCL
+ option = loadOption(Java2WSDLConstants.CLASSPATH_OPTION,
+ Java2WSDLConstants.CLASSPATH_OPTION_LONG, optionsMap);
+
+ ClassLoader classLoader;
+
+ if (option != null) {
+ ArrayList optionValues = option.getOptionValues();
+ URL[] urls = new URL[optionValues.size()];
+ String[] classPathEntries = (String[]) optionValues.toArray(new String[optionValues.size()]);
+
+ try {
+ for (int i = 0; i < classPathEntries.length; i++) {
+ String classPathEntry = classPathEntries[i];
+ //this should be a file(or a URL)
+ if (isURL(classPathEntry)) {
+ urls[i] = new URL(classPathEntry);
+ } else {
+ urls[i] = new File(classPathEntry).toURL();
+ }
+ }
+ } catch (MalformedURLException e) {
+ throw new Exception(e);
+ }
+
+ classLoader = new URLClassLoader(urls, Thread.currentThread().getContextClassLoader());
+
+ } else {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+
+ //Now we are done with loading the basic values - time to create the builder
+ java2WsdlBuilder = new Java2WSDLBuilder(out,
+ className,
+ classLoader);
+
+ //set the other parameters to the builder
+ option = loadOption(Java2WSDLConstants.SCHEMA_TARGET_NAMESPACE_OPTION,
+ Java2WSDLConstants.SCHEMA_TARGET_NAMESPACE_OPTION_LONG, optionsMap);
+ java2WsdlBuilder.setSchemaTargetNamespace(option == null ? null : option.getOptionValue());
+
+ option = loadOption(Java2WSDLConstants.SCHEMA_TARGET_NAMESPACE_PREFIX_OPTION,
+ Java2WSDLConstants.SCHEMA_TARGET_NAMESPACE_PREFIX_OPTION_LONG, optionsMap);
+ java2WsdlBuilder.setSchemaTargetNamespacePrefix(option == null ? null : option.getOptionValue());
+
+ option = loadOption(Java2WSDLConstants.TARGET_NAMESPACE_OPTION,
+ Java2WSDLConstants.TARGET_NAMESPACE_OPTION_LONG, optionsMap);
+ java2WsdlBuilder.setTargetNamespace(option == null ? null : option.getOptionValue());
+
+ option = loadOption(Java2WSDLConstants.TARGET_NAMESPACE_PREFIX_OPTION,
+ Java2WSDLConstants.TARGET_NAMESPACE_PREFIX_OPTION_LONG, optionsMap);
+ java2WsdlBuilder.setTargetNamespacePrefix(option == null ? null : option.getOptionValue());
+
+ option = loadOption(Java2WSDLConstants.SERVICE_NAME_OPTION,
+ Java2WSDLConstants.SERVICE_NAME_OPTION_LONG, optionsMap);
+ java2WsdlBuilder.setServiceName(option == null ? getSimpleClassName(className) : option.getOptionValue());
+
+ option = loadOption(Java2WSDLConstants.STYLE_OPTION,
+ Java2WSDLConstants.STYLE_OPTION, optionsMap);
+ if (option != null) {
+ java2WsdlBuilder.setStyle(option.getOptionValue());
+ }
+
+ option = loadOption(Java2WSDLConstants.LOCATION_OPTION,
+ Java2WSDLConstants.LOCATION_OPTION, optionsMap);
+ if (option != null) {
+ java2WsdlBuilder.setLocationUri(option.getOptionValue());
+ }
+
+ option = loadOption(Java2WSDLConstants.USE_OPTION,
+ Java2WSDLConstants.USE_OPTION, optionsMap);
+ if (option != null) {
+ java2WsdlBuilder.setUse(option.getOptionValue());
+ }
+
+
+ }
+
+ public void generate() throws Exception {
+ try {
+ java2WsdlBuilder.generateWSDL();
+ } catch (Exception e) {
+ throw new Exception(e);
+ }
+ }
+
+ /**
+ * check the entry for a URL. This is a simple check and need to be improved
+ *
+ * @param entry
+ */
+
+ private boolean isURL(String entry) {
+ return entry.startsWith("http://");
+ }
+
+ /**
+ * @param shortOption
+ * @param longOption
+ * @param options
+ */
+ private Java2WSDLCommandLineOption loadOption(String shortOption, String longOption, Map options) {
+ //short option gets precedence
+ Java2WSDLCommandLineOption option = null;
+ if (longOption != null) {
+ option = (Java2WSDLCommandLineOption) options.get(longOption);
+ if (option != null) {
+ return option;
+ }
+ }
+ if (shortOption != null) {
+ option = (Java2WSDLCommandLineOption) options.get(shortOption);
+ }
+
+ return option;
+ }
+
+ /**
+ * A method to strip the fully qualified className to a simple classname
+ *
+ * @param qualifiedName
+ */
+ private String getSimpleClassName(String qualifiedName) {
+ int index = qualifiedName.lastIndexOf(".");
+ if (index > 0) {
+ return qualifiedName.substring(index + 1, qualifiedName.length());
+ }
+ return qualifiedName;
+ }
+}
Added: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLTask.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLTask.java?rev=389081&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLTask.java (added)
+++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLTask.java Mon Mar 27 01:26:40 2006
@@ -0,0 +1,204 @@
+package org.apache.ws.java2wsdl;
+
+import org.apache.tools.ant.AntClassLoader;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+import org.apache.ws.java2wsdl.utils.Java2WSDLCommandLineOption;
+
+import java.util.Map;
+import java.util.HashMap;
+/*
+* 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 Java2WSDLTask extends Task implements Constants{
+
+ private String className = null;
+ private String outputLocation = null;
+ private String classpathURI = null;
+ private String targetNamespace = null;
+ private String targetNamespacePrefix = null;
+ private String schemaTargetNamespace = null;
+ private String schemaTargetNamespacePrefix = null;
+ private String serviceName = null;
+ private String outputFileName = null;
+
+ /**
+ *
+ */
+ public Java2WSDLTask() {
+ super();
+ }
+
+ /**
+ * Fills the option map. This map is passed onto
+ * the code generation API to generate the code.
+ */
+ private Map fillOptionMap() {
+ Map optionMap = new HashMap();
+
+ // Check that critical options exist
+ if (className == null) {
+ throw new BuildException(
+ "You must specify a classname");
+ }
+
+ ////////////////////////////////////////////////////////////////
+
+ // Classname
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.CLASSNAME_OPTION,
+ className);
+
+ // Output location
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.OUTPUT_LOCATION_OPTION,
+ outputLocation);
+
+ // Classpath URI
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.CLASSPATH_OPTION,
+ classpathURI);
+
+ // Target namespace
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.TARGET_NAMESPACE_OPTION,
+ targetNamespace);
+
+ // Target namespace prefix
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.TARGET_NAMESPACE_PREFIX_OPTION,
+ targetNamespacePrefix);
+
+ // Schema target namespace
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.SCHEMA_TARGET_NAMESPACE_OPTION,
+ schemaTargetNamespace);
+
+ // Schema target namespace prefix
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.SCHEMA_TARGET_NAMESPACE_PREFIX_OPTION,
+ schemaTargetNamespacePrefix);
+
+ // Service name
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.SERVICE_NAME_OPTION,
+ serviceName);
+
+ // Output file name
+ addToOptionMap( optionMap,
+ Java2WSDLConstants.OUTPUT_FILENAME_OPTION,
+ outputFileName);
+
+ return optionMap;
+ }
+
+ /**
+ * Utility method to convert a string into a single item string[]
+ * @param value
+ * @return Returns String[].
+ */
+ private String[] getStringArray(String value) {
+ String[] values = new String[1];
+ values[0] = value;
+ return values;
+ }
+
+ /**
+ * Function to put arguments in the option map.
+ * This functions skips adding of options that have a null value.
+ *
+ * @param map The option map into which the option is to be added
+ * @param option The option name
+ * @param value The value of the option
+ */
+ private void addToOptionMap(Map map, String option, String value) {
+ if (value != null) {
+ map.put(option,
+ new Java2WSDLCommandLineOption(option, getStringArray(value)));
+ }
+ }
+
+ public void execute() throws BuildException {
+ try {
+ /**
+ * <comment borrowed from AntCodegenTask>
+ *
+ * This needs the ClassLoader we use to load the task have all the dependancies set, hope that
+ * is ok for now
+ *
+ * todo look into this further!!!!!
+ */
+
+
+ AntClassLoader cl = new AntClassLoader(
+ null,
+ getProject(),
+ null,
+ false);
+
+ Thread.currentThread().setContextClassLoader(cl);
+
+ if (outputLocation != null) cl.addPathElement(outputLocation);
+
+ Map commandLineOptions = this.fillOptionMap();
+ new Java2WSDLCodegenEngine(commandLineOptions).generate();
+
+ } catch (Throwable e) {
+ throw new BuildException(e);
+ }
+
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public void setOutputLocation(String outputLocation) {
+ this.outputLocation = outputLocation;
+ }
+
+ public void setClassPathURI(String classpathURI) {
+ this.classpathURI = classpathURI;
+ }
+
+ public void setTargetNamespace(String targetNamespace) {
+ this.targetNamespace = targetNamespace;
+ }
+
+ public void setTargetNamespacePrefix(String targetNamespacePrefix) {
+ this.targetNamespacePrefix = targetNamespacePrefix;
+ }
+
+ public void setSchemaTargetNamespace(String schemaTargetNamespace) {
+ this.schemaTargetNamespace = schemaTargetNamespace;
+ }
+
+ public void setSchemaTargetNamespacePrefix(String schemaTargetNamespacePrefix) {
+ this.schemaTargetNamespacePrefix = schemaTargetNamespacePrefix;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public void setOutputFileName(String outputFileName) {
+ this.outputFileName = outputFileName;
+ }
+ }
+