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/05/04 08:10:54 UTC

svn commit: r399565 - in /webservices/axis2/trunk/java/modules: core/src/org/apache/axis2/description/AxisService.java core/src/org/apache/axis2/engine/AxisConfiguration.java integration/test/org/apache/axis2/engine/WSDLClientTest.java jibx/project.xml

Author: deepal
Date: Wed May  3 23:10:53 2006
New Revision: 399565

URL: http://svn.apache.org/viewcvs?rev=399565&view=rev
Log:
- we print out the wsdl only in following two cases
   - if user put his wsdl inside MEAT-INF
   - All the operations use RPC as its message receivers

Modified:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfiguration.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/WSDLClientTest.java
    webservices/axis2/trunk/java/modules/jibx/project.xml

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=399565&r1=399564&r2=399565&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 Wed May  3 23:10:53 2006
@@ -540,21 +540,38 @@
      * @throws AxisFault
      */
     public void printWSDL(OutputStream out) throws AxisFault {
+        setWsdlfound(true);
         //pick the endpoint and take it as the epr for the WSDL
         getWSDL(out, new String[]{getEndpoint()});
     }
 
     private void getWSDL(OutputStream out, String [] serviceURL) throws AxisFault {
-        AxisService2OM axisService2WOM = new AxisService2OM(this,
-                serviceURL, "document", "literal");
-        try {
-            OMElement wsdlElement = axisService2WOM.generateOM();
-            wsdlElement.serialize(out);
-            out.flush();
-            out.close();
-        } catch (Exception e) {
-            throw new AxisFault(e);
+        if (isWsdlfound()) {
+            AxisService2OM axisService2WOM = new AxisService2OM(this,
+                    serviceURL, "document", "literal");
+            try {
+                OMElement wsdlElement = axisService2WOM.generateOM();
+                wsdlElement.serialize(out);
+                out.flush();
+                out.close();
+            } catch (Exception e) {
+                throw new AxisFault(e);
+            }
+        } else {
+            try {
+                String wsdlntfound = "<error>" +
+                        "<description>Unable to generate wsdl for this service</description>" +
+                        "<reason>Either user does not drop the wsdl into META-INF or" +
+                        " operations uses message receivers other than RPC.</reason>" +
+                        "</error>";
+                out.write(wsdlntfound.getBytes());
+                out.flush();
+                out.close();
+            } catch (IOException e) {
+                throw new AxisFault(e);
+            }
         }
+
     }
 
     /**
@@ -1256,7 +1273,7 @@
             XmlSchemaObjectCollection includes = schema.getIncludes();
             for (int j = 0; j < includes.getCount(); j++) {
                 Object item = includes.getItem(j);
-                XmlSchema s ;
+                XmlSchema s;
                 if (item instanceof XmlSchemaExternal) {
                     //recursively call the calculating
                     XmlSchemaExternal externalSchema = (XmlSchemaExternal) item;

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=399565&r1=399564&r2=399565&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 Wed May  3 23:10:53 2006
@@ -160,6 +160,34 @@
         addServiceGroup(axisServiceGroup);
     }
 
+    /**
+     * This method will check whethere for a given service , can we ganerate valid
+     * wsdl or not. So if user derop a wsdl we print that out , else if all the operation
+     * uses RPC message recivers we will generate wsdl
+     *
+     * @param axisService
+     */
+    private void isWSDLEnable(AxisService axisService) {
+        if (!axisService.isWsdlfound()) {
+            Iterator operatins = axisService.getOperations();
+            while (operatins.hasNext()) {
+                AxisOperation axisOperation = (AxisOperation) operatins.next();
+                if (axisOperation.getMessageReceiver() == null) {
+                    axisService.setWsdlfound(false);
+                    return;
+                }
+                String messageReceiverClass = axisOperation.getMessageReceiver().getClass().getName();
+                if (!("org.apache.axis2.rpc.receivers.RPCMessageReceiver".equals(messageReceiverClass) ||
+                        "org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver".equals(messageReceiverClass) ||
+                        "org.apache.axis2.rpc.receivers.RPCInOutAsyncMessageReceiver".equals(messageReceiverClass))) {
+                    axisService.setWsdlfound(false);
+                    return;
+                }
+            }
+            axisService.setWsdlfound(true);
+        }
+    }
+
     public synchronized void addServiceGroup(AxisServiceGroup axisServiceGroup) throws AxisFault {
         Iterator services = axisServiceGroup.getServices();
         axisServiceGroup.setParent(this);
@@ -171,9 +199,10 @@
                         "twoservicecannothavesamename",
                         description.getName()));
             }
-            if(description.getSchematargetNamespace()==null){
+            if (description.getSchematargetNamespace() == null) {
                 description.setSchematargetNamespace(Java2WSDLConstants.AXIS2_XSD);
             }
+            isWSDLEnable(description);
         }
         services = axisServiceGroup.getServices();
         while (services.hasNext()) {

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/WSDLClientTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/WSDLClientTest.java?rev=399565&r1=399564&r2=399565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/WSDLClientTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/WSDLClientTest.java Wed May  3 23:10:53 2006
@@ -5,6 +5,7 @@
 import junit.framework.TestSuite;
 import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.engine.util.TestConstants;
@@ -41,7 +42,7 @@
 
     protected void setUp() throws Exception {
         service = AxisService.createService(Echo.class.getName(),
-                UtilServer.getConfigurationContext().getAxisConfiguration());
+                UtilServer.getConfigurationContext().getAxisConfiguration(),RPCMessageReceiver.class );
         service.setName(serviceName.getLocalPart());
         UtilServer.deployService(service);
     }

Modified: webservices/axis2/trunk/java/modules/jibx/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/jibx/project.xml?rev=399565&r1=399564&r2=399565&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jibx/project.xml (original)
+++ webservices/axis2/trunk/java/modules/jibx/project.xml Wed May  3 23:10:53 2006
@@ -1,170 +1,176 @@
-<?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 - JiBX Data Binding</name>
-    <id>axis2-jibx</id>
-    <groupId>axis2</groupId>
-    <description>JiBX data binding support for Axis 2.0</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>org.apache.ws.commons</groupId>
-            <artifactId>XmlSchema</artifactId>
-            <version>${XmlSchema.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>ws-commons</groupId>
-            <artifactId>neethi</artifactId>
-            <version>${policy.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-        <dependency>
-            <groupId>axis2</groupId>
-            <artifactId>axis2-common</artifactId>
-            <version>${pom.currentVersion}</version>
-        </dependency>
-        <dependency>
-            <groupId>axis2</groupId>
-            <artifactId>axis2-codegen</artifactId>
-            <version>${pom.currentVersion}</version>
-        </dependency>
-        <dependency>
-            <groupId>axis2</groupId>
-            <artifactId>axis2-core</artifactId>
-            <version>${pom.currentVersion}</version>
-        </dependency>
-        <dependency>
-            <groupId>wsdl4j</groupId>
-            <artifactId>wsdl4j</artifactId>
-            <version>${wsdl4j.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-
-        <!-- external JARs -->
-        <dependency>
-            <groupId>ant</groupId>
-            <artifactId>ant</artifactId>
-            <version>${ant.version}</version>
-            <type>jar</type>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-            <version>${commons.logging.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-        <dependency>
-            <groupId>bcel</groupId>
-            <artifactId>bcel</artifactId>
-            <version>${bcel.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>commons-httpclient</groupId>
-            <artifactId>commons-httpclient</artifactId>
-            <version>${commons.httpclient.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-        <dependency>
-            <groupId>commons-codec</groupId>
-            <artifactId>commons-codec</artifactId>
-            <version>${commons.codec.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-        <dependency>
-            <groupId>backport-util-concurrent</groupId>
-            <artifactId>backport-util-concurrent</artifactId>
-            <version>${backport_util_concurrent.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-        </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>
-        <dependency>
-            <groupId>jibx</groupId>
-            <artifactId>jibx-bind</artifactId>
-            <version>${jibx.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-        <dependency>
-            <groupId>jibx</groupId>
-            <artifactId>jibx-run</artifactId>
-            <version>${jibx.version}</version>
-            <properties>
-                <module>true</module>
-            </properties>
-        </dependency>
-    </dependencies>
-    <build/>
-    <reports/>
-</project>
+<?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 - JiBX Data Binding</name>
+    <id>axis2-jibx</id>
+    <groupId>axis2</groupId>
+    <description>JiBX data binding support for Axis 2.0</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>org.apache.ws.commons</groupId>
+            <artifactId>XmlSchema</artifactId>
+            <version>${XmlSchema.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>neethi</artifactId>
+            <version>${policy.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>axis2</groupId>
+            <artifactId>axis2-common</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        <dependency>
+            <groupId>axis2</groupId>
+            <artifactId>axis2-codegen</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        <dependency>
+            <groupId>axis2</groupId>
+            <artifactId>axis2-java2wsdl</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>axis2</groupId>
+            <artifactId>axis2-core</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        <dependency>
+            <groupId>wsdl4j</groupId>
+            <artifactId>wsdl4j</artifactId>
+            <version>${wsdl4j.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+
+        <!-- external JARs -->
+        <dependency>
+            <groupId>ant</groupId>
+            <artifactId>ant</artifactId>
+            <version>${ant.version}</version>
+            <type>jar</type>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>${commons.logging.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>bcel</groupId>
+            <artifactId>bcel</artifactId>
+            <version>${bcel.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>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+            <version>${commons.httpclient.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>${commons.codec.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>${backport_util_concurrent.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </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>
+        <dependency>
+            <groupId>jibx</groupId>
+            <artifactId>jibx-bind</artifactId>
+            <version>${jibx.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
+            <groupId>jibx</groupId>
+            <artifactId>jibx-run</artifactId>
+            <version>${jibx.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+    </dependencies>
+    <build/>
+    <reports/>
+</project>