axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From isur...@apache.org
Subject svn commit: r759854 - in /webservices/axis2/trunk/java/modules: jaxws/src/org/apache/axis2/jaxws/framework/ kernel/conf/ kernel/src/org/apache/axis2/description/ metadata/src/org/apache/axis2/jaxws/description/ metadata/src/org/apache/axis2/jaxws/descr...
Date Mon, 30 Mar 2009 06:55:56 GMT
Author: isurues
Date: Mon Mar 30 06:55:55 2009
New Revision: 759854

URL: http://svn.apache.org/viewvc?rev=759854&view=rev
Log:
Applying the fix described in https://issues.apache.org/jira/browse/AXIS2-4284

This is an improvement in JAXWS WSDL generation


Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSDeployer.java
    webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/JAXWSRIWSDLGenerator.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/i18n/resource.properties

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSDeployer.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSDeployer.java?rev=759854&r1=759853&r2=759854&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSDeployer.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/framework/JAXWSDeployer.java
Mon Mar 30 06:55:55 2009
@@ -218,6 +218,7 @@
         for (int i = 0; i < size; i++) {
             AxisService axisService = (AxisService) axisServiceList.get(i);
             serviceGroup.addService(axisService);
+            Utils.addEndpointsToService(axisService, axisConfig);
         }
         axisConfig.addServiceGroup(serviceGroup);
         configureAddressing(serviceGroup);

Modified: webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml?rev=759854&r1=759853&r2=759854&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml Mon Mar 30 06:55:55 2009
@@ -105,6 +105,12 @@
     <!-- use this parameter to override autodetected url -->
     <!--<parameter name="httpFrontendHostUrl">https://someotherhost/context</parameter>-->
 
+    <!--By default, JAXWS services are created by reading annotations. WSDL and schema
are generated-->
+    <!--using a separate WSDL generator only when ?wsdl is called. Therefore, even if
you engage-->
+    <!--policies etc.. to AxisService, it doesn't appear in the WSDL. By setting the following
property-->
+    <!--to true, you can create the AxisService using the generated WSDL and remove the
need for a-->
+    <!--WSDL generator. When ?wsdl is called, WSDL is generated in the normal way.-->
+    <parameter name="useGeneratedWSDLinJAXWS">false</parameter>
 
     <!--    The way of adding listener to the system-->
     <!--    <listener class="org.apache.axis2.ObserverIMPL">-->

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java?rev=759854&r1=759853&r2=759854&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
Mon Mar 30 06:55:55 2009
@@ -308,7 +308,7 @@
 	}
 
 	private void writeMessage(AxisMessage axismessage, OMFactory fac, OMElement defintions)
{
-		if (messagesMap.get(axismessage.getName()) == null) {
+		if (axismessage.getName() != null && messagesMap.get(axismessage.getName()) ==
null) {
 			messagesMap.put(axismessage.getName(), axismessage);
 			QName schemaElementName = axismessage.getElementQName();
 			OMElement messageElement = fac.createOMElement(MESSAGE_LOCAL_NAME, wsdl);

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java?rev=759854&r1=759853&r2=759854&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java
Mon Mar 30 06:55:55 2009
@@ -22,9 +22,11 @@
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
 import org.apache.axis2.jaxws.ClientConfigurationFactory;
 import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
 import org.apache.axis2.jaxws.description.builder.JAXWSRIWSDLGenerator;
+import org.apache.axis2.jaxws.description.builder.MDQConstants;
 import org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl;
 import org.apache.ws.commons.schema.SchemaBuilder;
 import org.apache.commons.logging.Log;
@@ -532,12 +534,20 @@
         ServiceDescription serviceDescription = DescriptionFactoryImpl.createServiceDescription(serviceImplClass,
configContext);
         EndpointDescription[] edArray = serviceDescription.getEndpointDescriptions();
         AxisService axisService = edArray[0].getAxisService();
-        try {
-            JAXWSRIWSDLGenerator value = new JAXWSRIWSDLGenerator(axisService);
-            axisService.addParameter("WSDLSupplier", value);
-            axisService.addParameter("SchemaSupplier", value);
-        } catch (Exception ex) {
-            log.info("Unable to set the WSDLSupplier", ex);
+
+        /**
+         * WSDL supplier and Schema supplier is needed only when the service is built only
using
+         * annotations. In other cases, WSDL can be generated in the normal way.
+         */
+        Parameter param = axisService.getParameter(MDQConstants.USED_ANNOTATIONS_ONLY);
+        if (param != null && "true".equals(param.getValue())) {
+            try {
+                JAXWSRIWSDLGenerator value = new JAXWSRIWSDLGenerator(axisService);
+                axisService.addParameter("WSDLSupplier", value);
+                axisService.addParameter("SchemaSupplier", value);
+            } catch (Exception ex) {
+                log.info("Unable to set the WSDLSupplier", ex);
+            }
         }
         return axisService;
     }

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/JAXWSRIWSDLGenerator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/JAXWSRIWSDLGenerator.java?rev=759854&r1=759853&r2=759854&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/JAXWSRIWSDLGenerator.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/JAXWSRIWSDLGenerator.java
Mon Mar 30 06:55:55 2009
@@ -87,6 +87,7 @@
     private String classPath;
 
     private AxisService axisService;
+    private AxisConfiguration axisConfiguration;
     private boolean init = false;
     private HashMap<String, XmlSchema> docMap;
     private HashMap<String, Definition> wsdlDefMap;
@@ -95,6 +96,11 @@
         this.axisService = axisService;
     }
 
+    public JAXWSRIWSDLGenerator(AxisService axisService, AxisConfiguration axisConfig) {
+        this.axisService = axisService;
+        this.axisConfiguration = axisConfig;
+    }
+
     /**
      * This method will drive the call to WsGen to generate a WSDL file for
      * applications deployed without WSDL. We will then read this file in from
@@ -115,7 +121,9 @@
     public void generateWsdl(String className, String bindingType, JAXWSCatalogManager catalogManager)
throws
             WebServiceException {
 
-        AxisConfiguration axisConfiguration = axisService.getAxisConfiguration();
+        if (this.axisConfiguration == null) {
+            this.axisConfiguration = axisService.getAxisConfiguration();
+        }
         File tempFile = (File) axisConfiguration.getParameterValue(
                 Constants.Configuration.ARTIFACTS_TEMP_DIR);
         if (tempFile == null) {

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java?rev=759854&r1=759853&r2=759854&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
Mon Mar 30 06:55:55 2009
@@ -29,6 +29,8 @@
     public static final String WSDL_LOCATION = "WSDL_LOCATION";
     public static final String SERVICE_CLASS = "ServiceClass";
     public static final String WSDL_PORTTYPE_NAME = "WSDL_PORTTYPE_NAME";
+    public static final String USE_GENERATED_WSDL = "useGeneratedWSDLinJAXWS";
+    public static final String USED_ANNOTATIONS_ONLY = "usedAnnotationsOnly";
 
     public static final String OBJECT_CLASS_NAME = "java.lang.Object";
 

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java?rev=759854&r1=759853&r2=759854&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
Mon Mar 30 06:55:55 2009
@@ -46,6 +46,7 @@
 import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
 import org.apache.axis2.jaxws.description.builder.MDQConstants;
 import org.apache.axis2.jaxws.description.builder.WsdlComposite;
+import org.apache.axis2.jaxws.description.builder.JAXWSRIWSDLGenerator;
 import org.apache.axis2.jaxws.description.xml.handler.HandlerChainsType;
 import org.apache.axis2.jaxws.feature.ServerConfigurator;
 import org.apache.axis2.jaxws.feature.ServerFramework;
@@ -102,6 +103,7 @@
 
     private ServiceDescriptionImpl parentServiceDescription;
     private AxisService axisService;
+    private AxisConfiguration axisConfig;
     // In some environments some of the resources on an AxisService can lead to OOMs.
     // However, releasing these resources can have other implications.  
     private boolean releaseAxisServiceResources = false;
@@ -226,6 +228,8 @@
                             DescriptionBuilderComposite sparseComposite,
                             Object sparseCompositeKey) {
 
+        this.axisConfig = parent.getAxisConfigContext().getAxisConfiguration();
+
         this.parentServiceDescription = parent;
         composite = new DescriptionBuilderComposite();
         composite.setSparseComposite(sparseCompositeKey, sparseComposite);
@@ -320,6 +324,8 @@
      */
     EndpointDescriptionImpl(ServiceDescriptionImpl parent, String serviceImplName, Map<String,
Object>
         properties, Integer portCompositeIndex) {
+
+        this.axisConfig = parent.getAxisConfigContext().getAxisConfiguration();
         
         // initialize CustomAnnotationIntance list and CustomAnnotationProcessor map
         customAnnotations = new ArrayList<CustomAnnotationInstance>();
@@ -745,7 +751,12 @@
         if (!isDynamicPort && getServiceDescriptionImpl().getWSDLWrapper() != null)
{
             isAxisServiceBuiltFromWSDL = buildAxisServiceFromWSDL();
         } else {
-            buildAxisServiceFromAnnotations();
+            if (useGeneratedWSDL()) {
+                buildAxisServiceFromGeneratedWSDL();
+            } else {
+                buildAxisServiceFromAnnotations();
+                addAnnotationParamToService();
+            }
         }
 
         if (axisService == null) {
@@ -814,7 +825,12 @@
 
         if (!isAxisServiceBuiltFromWSDL) {
             //generateWSDL(composite);
-            buildAxisServiceFromAnnotations();
+            if (useGeneratedWSDL()) {
+                buildAxisServiceFromGeneratedWSDL();
+            } else {
+                buildAxisServiceFromAnnotations();
+                addAnnotationParamToService();
+            }
         }
 
         if (axisService == null) {
@@ -940,6 +956,79 @@
         return isBuiltFromWSDL;
     }
 
+    /**
+     * If a WSDL is not already found, this method can be used to generate a WSDL and create
+     * the AxisService using that WSDL
+     */
+
+    private void buildAxisServiceFromGeneratedWSDL() {
+        /**
+         * First we create a dummy axis service to get the information for WSDL generation.
+         * When the new axis service is created from the WSDL, this one is overidden by the
+         * new service.
+         */
+        buildAxisServiceFromAnnotations();
+
+        //Save the fully qualified class name for the serviceImpl
+        Parameter serviceClassNameParameter = new Parameter();
+        serviceClassNameParameter.setName(MDQConstants.SERVICE_CLASS);
+        serviceClassNameParameter
+                .setValue(DescriptionUtils.javifyClassName(composite.getClassName()));
+        try {
+            this.axisService.addParameter(serviceClassNameParameter);
+        } catch (AxisFault axisFault) {
+            throw ExceptionFactory.makeWebServiceException(Messages
+                    .getMessage("setupAxisServiceErr2"), axisFault);
+        }
+
+        addToAxisService();
+
+        JAXWSRIWSDLGenerator wsdlGenerator =
+                new JAXWSRIWSDLGenerator(this.axisService, this.axisConfig);
+
+        try {
+            //generate the wsdl
+            Definition def = wsdlGenerator.getWSDL(axisService);
+
+            //create the new axis service from the generated wsdl
+            WSDL11ToAxisServiceBuilder axisServiceBuilder = new WSDL11ToAxisServiceBuilder(def,
+                    getServiceDescription().getServiceQName(), getPortQName().getLocalPart());
+
+            if (getServiceDescriptionImpl().isServerSide()) {
+                axisServiceBuilder.setServerSide(true);
+            } else {
+                axisServiceBuilder.setServerSide(false);
+            }
+
+            this.axisService = axisServiceBuilder.populateService();
+            axisService.setName(createAxisServiceName());
+
+        } catch (AxisFault e) {
+            throw ExceptionFactory.makeWebServiceException(Messages
+                    .getMessage("setupAxisServiceErr3"),e);
+        }
+    }
+
+    /**
+     * Reads the property in axis config (comes from axis2.xml) and decides whether we have
to
+     * build the AxisService using a generated WSDL.
+     * @return true if param true
+     */
+    private boolean useGeneratedWSDL(){
+        Parameter param = this.axisConfig.getParameter(MDQConstants.USE_GENERATED_WSDL);
+        return param != null && "true".equals(param.getValue());
+    }
+
+    private void addAnnotationParamToService() {
+        //Add a parameter to identify that this AxisService is created only using annotations
+        try {
+            axisService.addParameter(MDQConstants.USED_ANNOTATIONS_ONLY, "true");
+        } catch (AxisFault axisFault) {
+            throw ExceptionFactory.makeWebServiceException(Messages
+                    .getMessage("setupAxisServiceErr2"), axisFault);
+        }
+    }
+
     private void buildAxisServiceFromAnnotations() {
         String serviceName = null;
         if (portQName != null) {

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/i18n/resource.properties?rev=759854&r1=759853&r2=759854&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/i18n/resource.properties
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/i18n/resource.properties
Mon Mar 30 06:55:55 2009
@@ -207,6 +207,7 @@
 updateWithSEIErr2=EndpointDescription.updateWithSEI was passed a null SEI.  PortQName: {0}
 setupAxisServiceErr1=Unable to create AxisService for {0}
 setupAxisServiceErr2=Exception when adding service parameters.
+setupAxisServiceErr3=Exception when generating WSDL to create AxisService
 bldAxisSrvcFromWSDLErr=The WSDL file could not be used due to an exception.  The WSDL will
be ignored and annotations will be used.  Implementation class: {0}; WSDL Location: {1}
 serviceDescErr3=WSDL Port not found for port {0}
 generateWSDLErr=EndpointDescriptionImpl: WSDLException thrown when attempting to instantiate
WSDL4JWrapper



Mime
View raw message