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 ba...@apache.org on 2007/06/26 22:06:02 UTC

svn commit: r550923 - in /webservices/axis2/trunk/java/modules: jaxws/src/org/apache/axis2/jaxws/dispatchers/ jaxws/test/org/apache/axis2/jaxws/provider/ metadata/src/org/apache/axis2/jaxws/description/ metadata/src/org/apache/axis2/jaxws/description/i...

Author: barrettj
Date: Tue Jun 26 13:06:00 2007
New Revision: 550923

URL: http://svn.apache.org/viewvc?view=rev&rev=550923
Log:
CTS: Add support for generic provider operations using the HTTP Binding

Added:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/dispatchers/
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/dispatchers/GenericProviderDispatcher.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/GenericOperationProviderTest.java
Modified:
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointInterfaceDescription.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/description/impl/EndpointInterfaceDescriptionImpl.java

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/dispatchers/GenericProviderDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/dispatchers/GenericProviderDispatcher.java?view=auto&rev=550923
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/dispatchers/GenericProviderDispatcher.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/dispatchers/GenericProviderDispatcher.java Tue Jun 26 13:06:00 2007
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.axis2.jaxws.dispatchers;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AbstractDispatcher;
+import org.apache.axis2.engine.SOAPActionBasedDispatcher;
+import org.apache.axis2.jaxws.description.EndpointInterfaceDescription;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+
+/**
+ * This dispatcher will look for a specific operation on the AxisService and return it
+ * if found.  This dispatcher is used for Provider-based endpoints which do not have WSDL
+ * associated with them.  Those types of endpoints will not have WSDL operations created for them
+ * since (a) there is no WSDL and (b) there is no SEI from which to build operations using
+ * annotations.  For these types of endpoints, a generic operation will have been added to the
+ * service which will accept any incoming WSDL operation and pass the incoming message to the
+ * Provider endpoint. 
+ */
+public class GenericProviderDispatcher extends AbstractDispatcher {
+    private static final Log log = LogFactory.getLog(GenericProviderDispatcher.class);
+
+    /* (non-Javadoc)
+     * @see org.apache.axis2.engine.AbstractDispatcher#findOperation(org.apache.axis2.description.AxisService, org.apache.axis2.context.MessageContext)
+     */
+    @Override
+    public AxisOperation findOperation(AxisService service, MessageContext messageContext)
+            throws AxisFault {
+        AxisOperation theOperation = null;
+        if (log.isDebugEnabled()) {
+            log.debug("findOperation service = " + service + "; messagectx: " + messageContext);
+        }
+        
+        // If there's an AxisService, then look for the specially named operation and return it
+        if (service != null) {
+            theOperation = service.getOperation(new QName(EndpointInterfaceDescription.JAXWS_NOWSDL_PROVIDER_OPERATION_NAME));
+            if (log.isDebugEnabled()) {
+                log.debug("operation " + EndpointInterfaceDescription.JAXWS_NOWSDL_PROVIDER_OPERATION_NAME + " is " + theOperation );
+            }
+        }
+        
+        return theOperation;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.axis2.engine.AbstractDispatcher#findService(org.apache.axis2.context.MessageContext)
+     */
+    @Override
+    public AxisService findService(MessageContext messageContext) throws AxisFault {
+        // This dispatcher will not try to resolve and AxisService if one hasn't been
+        // resolved already
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.axis2.engine.AbstractDispatcher#initDispatcher()
+     */
+    @Override
+    public void initDispatcher() {
+        // No initialization necessary
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/GenericOperationProviderTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/GenericOperationProviderTest.java?view=auto&rev=550923
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/GenericOperationProviderTest.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/GenericOperationProviderTest.java Tue Jun 26 13:06:00 2007
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.axis2.jaxws.provider;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.jaxws.description.DescriptionFactory;
+import org.apache.axis2.jaxws.description.EndpointDescription;
+import org.apache.axis2.jaxws.description.EndpointInterfaceDescription;
+import org.apache.axis2.jaxws.description.OperationDescription;
+import org.apache.axis2.jaxws.description.ServiceDescription;
+import org.apache.axis2.jaxws.dispatchers.GenericProviderDispatcher;
+
+import javax.jws.WebService;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.Provider;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.http.HTTPBinding;
+
+import junit.framework.TestCase;
+
+/**
+ * 
+ */
+public class GenericOperationProviderTest extends TestCase {
+    
+    public void testGenericHTTPBindingOperation() {
+        // The HTTP binding supports a generic operation for WSDL-less endpoints.
+        ServiceDescription serviceDesc = DescriptionFactory.createServiceDescription(HTTPBindingProviderImpl.class);
+        assertNotNull(serviceDesc);
+        EndpointDescription endpointDesc = serviceDesc.getEndpointDescriptions_AsCollection().iterator().next();
+        assertNotNull(endpointDesc);
+        AxisService axisSvc = endpointDesc.getAxisService();
+        assertNotNull(axisSvc);
+        
+        EndpointInterfaceDescription interfaceDesc = endpointDesc.getEndpointInterfaceDescription();
+        assertNotNull(interfaceDesc);
+
+        // There should be a single OpDesc with a single AxisOperation with a specific name
+        OperationDescription opDescs[] = interfaceDesc.getOperations();
+        assertNotNull(opDescs);
+        assertEquals(1, opDescs.length);
+        AxisOperation axisOperation = opDescs[0].getAxisOperation();
+        assertNotNull(axisOperation);
+        assertEquals(EndpointInterfaceDescription.JAXWS_NOWSDL_PROVIDER_OPERATION_NAME, axisOperation.getName().getLocalPart());
+        
+        // Now verify that the special dispather can find this operation
+        GenericProviderDispatcher dispatcher = new GenericProviderDispatcher();
+        MessageContext messageContext = new MessageContext();
+        messageContext.setAxisService(axisSvc);
+        
+        try {
+            // The dispatcher will not try to resolve an AxisService
+            assertNull(dispatcher.findService(messageContext));
+            
+            // The dispatcher should find the special AxisOperation
+            assertEquals(axisOperation, dispatcher.findOperation(axisSvc, messageContext));
+        } catch (AxisFault e) {
+            fail("Unexpected exception" + e);
+        }
+    }
+    
+    public void testGenericSOAPBindingOperation() {
+        // REVIEW: Currently generic operations are not supported for SOAP Bindings
+        
+        ServiceDescription serviceDesc = DescriptionFactory.createServiceDescription(SOAPBindingProviderImpl.class);
+        assertNotNull(serviceDesc);
+        EndpointDescription endpointDesc = serviceDesc.getEndpointDescriptions_AsCollection().iterator().next();
+        assertNotNull(endpointDesc);
+        AxisService axisSvc = endpointDesc.getAxisService();
+        assertNotNull(axisSvc);
+        
+        // Since there's no WSDL, there will be no operations and no EndpointInterfaceDescription
+        // because this is a SOAPBinding.
+        EndpointInterfaceDescription interfaceDesc = endpointDesc.getEndpointInterfaceDescription();
+        assertNull(interfaceDesc);
+    }
+    
+    public void testSEIBasedEndpoint() {
+        ServiceDescription serviceDesc = DescriptionFactory.createServiceDescription(SEIBasedEndpoint.class);
+        assertNotNull(serviceDesc);
+        EndpointDescription endpointDesc = serviceDesc.getEndpointDescriptions_AsCollection().iterator().next();
+        assertNotNull(endpointDesc);
+        AxisService axisSvc = endpointDesc.getAxisService();
+        assertNotNull(axisSvc);
+        
+        EndpointInterfaceDescription interfaceDesc = endpointDesc.getEndpointInterfaceDescription();
+        assertNotNull(interfaceDesc);
+
+        // There should be a single OpDesc with a single AxisOperation based on the SEI below
+        // But it should not be the special named operation and the special dispatcher should not
+        // return null for operation dispatch
+        OperationDescription opDescs[] = interfaceDesc.getOperations();
+        assertNotNull(opDescs);
+        assertEquals(1, opDescs.length);
+        AxisOperation axisOperation = opDescs[0].getAxisOperation();
+        assertNotNull(axisOperation);
+        if (EndpointInterfaceDescription.JAXWS_NOWSDL_PROVIDER_OPERATION_NAME.equals(axisOperation.getName().getLocalPart())) {
+            fail("Operation has the generic provider name");
+        }
+        
+        // Now verify that the special dispather doesn't find the special operation
+        GenericProviderDispatcher dispatcher = new GenericProviderDispatcher();
+        MessageContext messageContext = new MessageContext();
+        messageContext.setAxisService(axisSvc);
+        
+        try {
+            // The dispatcher will not try to resolve an AxisService
+            assertNull(dispatcher.findService(messageContext));
+            
+            // The dispatcher should find the special AxisOperation
+            assertNull(dispatcher.findOperation(axisSvc, messageContext));
+        } catch (AxisFault e) {
+            fail("Unexpected exception" + e);
+        }
+        
+    }
+}
+
+
+// Notice no WSDL is specified
+@WebServiceProvider()
+@BindingType(value=HTTPBinding.HTTP_BINDING)
+@ServiceMode(value=javax.xml.ws.Service.Mode.MESSAGE)
+class HTTPBindingProviderImpl implements Provider<String> {
+
+    public String invoke(String obj) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+    
+}
+//Notice no WSDL is specified
+@WebServiceProvider()
+class SOAPBindingProviderImpl implements Provider<String> {
+
+    public String invoke(String obj) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+}
+
+// SEI based endpoint to make sure it doesn't get get the special generic provider operation added
+@WebService()
+class SEIBasedEndpoint {
+    public String echo() {
+        return null;
+    }
+}

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointInterfaceDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointInterfaceDescription.java?view=diff&rev=550923&r1=550922&r2=550923
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointInterfaceDescription.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointInterfaceDescription.java Tue Jun 26 13:06:00 2007
@@ -49,6 +49,14 @@
  */
 
 public interface EndpointInterfaceDescription {
+    
+    /**
+     * The name of a special operation added to EndpointInterfaceDescriptions for provider 
+     * endpoints that do not specify WSDL, and therefore do not have specific WSDL operations
+     * created. Note that this is currently only supported for HTTP bindings, not for SOAP bindings.
+     */
+    public static String JAXWS_NOWSDL_PROVIDER_OPERATION_NAME = "jaxwsNoWSDLProviderOperation";
+
     public abstract EndpointDescription getEndpointDescription();
 
     public abstract String getTargetNamespace();

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?view=diff&rev=550923&r1=550922&r2=550923
==============================================================================
--- 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 Tue Jun 26 13:06:00 2007
@@ -547,7 +547,15 @@
                 }
             }
         } else {
-            //TODO: process a WebServiceProvider
+            if (log.isDebugEnabled()) {
+                log.debug("WebServiceProvider without WSDL encountered");
+            }
+            // REVIEW: Currently this is only supported for HTTP Bindings; SOAPBindings
+            //     for providers currently require that there be WSDL.
+            String bindingType = getBindingType();
+            if (javax.xml.ws.http.HTTPBinding.HTTP_BINDING.equals(bindingType)) {
+                endpointInterfaceDescription = new EndpointInterfaceDescriptionImpl(composite, this);
+            }
         }
     }
 

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java?view=diff&rev=550923&r1=550922&r2=550923
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java Tue Jun 26 13:06:00 2007
@@ -18,7 +18,9 @@
 
 package org.apache.axis2.jaxws.description.impl;
 
+import org.apache.axis2.AxisFault;
 import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisOperationFactory;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.description.EndpointDescription;
@@ -30,6 +32,7 @@
 import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
 import org.apache.axis2.jaxws.description.builder.MDQConstants;
 import org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite;
+import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -124,10 +127,52 @@
             }
         }
     }
+    /**
+     * Construct as Provider-based endpoint which does not have specific WSDL operations.  Since there
+     * are no specific WSDL operations in this case, there will be a single generic operation that
+     * will accept any incoming operation.
+     * 
+     * @param dbc
+     * @param parent
+     */
+    EndpointInterfaceDescriptionImpl(DescriptionBuilderComposite dbc, 
+                                     EndpointDescriptionImpl parent) {
+        if (log.isDebugEnabled()) {
+            log.debug("Creating a EndpointInterfaceDescription for a generic WSDL-less provider");
+        }
+        parentEndpointDescription = parent;
+        this.dbc = dbc;
+        
+        // Construct the generic provider AxisOperation to use then construct
+        // an OperactionDescription for it.
+        AxisOperation genericProviderAxisOp = null;
+        try {
+            genericProviderAxisOp = 
+                AxisOperationFactory.getOperationDescription(WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_OUT);
+        } catch (AxisFault e) {
+            if (log.isDebugEnabled()) {
+                log.debug("Unable to build AxisOperation for generic Provider; caught exception.", e);
+            }
+            // TODO: NLS & RAS
+            throw ExceptionFactory.makeWebServiceException("Caught exception trying to create AxisOperation",
+                                                           e);
+        }
+        
+        genericProviderAxisOp.setName(new QName(JAXWS_NOWSDL_PROVIDER_OPERATION_NAME));
+        OperationDescription opDesc = new OperationDescriptionImpl(genericProviderAxisOp, this);
+        
+        addOperation(opDesc);
+        AxisService axisService = getEndpointDescription().getAxisService();
+        axisService.addOperation(genericProviderAxisOp);
+    }
 
     /**
-     * Build an EndpointInterfaceDescription from a DescriptionBuilderComposite
-     *
+     * Build an EndpointInterfaceDescription from a DescriptionBuilderComposite.  This EID has
+     * WSDL operations associated with it.  It could represent an SEI-based endpoint built from
+     * WSDL or annotations, OR it could represent a Provider-based enpoint built from WSDL.  It will
+     * not represent a Provider-based endpoint built without WSDL (which does not know about
+     * specific WSDL operations). For that type of EID, see:
+     * @see  #EndpointInterfaceDescriptionImpl(DescriptionBuilderComposite dbc, EndpointDescriptionImpl parent)
      * @param dbc
      * @param isClass
      * @param parent



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org