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 wo...@apache.org on 2009/09/30 06:34:36 UTC

svn commit: r820172 - in /webservices/axis2/trunk/java/modules/metadata: src/org/apache/axis2/jaxws/description/impl/ test/org/apache/axis2/jaxws/description/ test/org/apache/axis2/jaxws/description/impl/

Author: woodroy
Date: Wed Sep 30 04:34:34 2009
New Revision: 820172

URL: http://svn.apache.org/viewvc?rev=820172&view=rev
Log:
Added a new test and modified OperationDescriptionImpl to use the targetNamespace from the Endpoint Interface when determining the QName for the operation. 

Added:
    webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/OperationDescriptionImplTests.java
Modified:
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java
    webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/DescriptionTestUtils.java

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?rev=820172&r1=820171&r2=820172&view=diff
==============================================================================
--- 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 Wed Sep 30 04:34:34 2009
@@ -247,7 +247,7 @@
 
                 AxisService axisService = getEndpointDescription().getAxisService();
                 AxisOperation axisOperation = axisService
-                        .getOperation(OperationDescriptionImpl.determineOperationQName(mdc));
+                        .getOperation(OperationDescriptionImpl.determineOperationQName(this, mdc));
 
                 OperationDescription operation =
                         new OperationDescriptionImpl(mdc, this, axisOperation);

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java?rev=820172&r1=820171&r2=820172&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java Wed Sep 30 04:34:34 2009
@@ -391,7 +391,7 @@
             throw ExceptionFactory.makeWebServiceException(Messages.getMessage("clientAxisOprErr"), e);
         }
 
-        newAxisOperation.setName(determineOperationQName(this.methodComposite));
+        newAxisOperation.setName(determineOperationQName(getEndpointInterfaceDescriptionImpl(),this.methodComposite));
         newAxisOperation.setSoapAction(this.getAction());
 
         //*************************************************************************************
@@ -821,13 +821,27 @@
     }
 
     static QName determineOperationQName(Method javaMethod) {
+        if (log.isDebugEnabled())
+        {
+          log.debug("Operation QName determined to be: "+new QName(determineOperationName(javaMethod)));
+        }
+
         return new QName(determineOperationName(javaMethod));
     }
 
-    public static QName determineOperationQName(MethodDescriptionComposite mdc) {
-        return new QName(determineOperationName(mdc));
+    //According to section 4.1.1 of JSR181, the Operation should inherit
+    //the target namespace from the @WebService annotation on the SEI or
+    //service implementation bean.  However, changing the above method
+    //currently causes problems with the clients and leaving it as is
+    //does not seem to have produced any issues (as of yet.)
+    public static QName determineOperationQName(EndpointInterfaceDescription eid, MethodDescriptionComposite mdc) {
+        if (log.isDebugEnabled())
+        {
+          log.debug("Operation QName determined to be: "+((eid!= null)?new QName(eid.getTargetNamespace(), determineOperationName(mdc)):new QName(determineOperationName(mdc))));
+        }
+        return ((eid!= null)?new QName(eid.getTargetNamespace(), determineOperationName(mdc)):new QName(determineOperationName(mdc)));
     }
-
+    
     private static String determineOperationName(Method javaMethod) {
 
         String operationName = null;

Modified: webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/DescriptionTestUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/DescriptionTestUtils.java?rev=820172&r1=820171&r2=820172&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/DescriptionTestUtils.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/DescriptionTestUtils.java Wed Sep 30 04:34:34 2009
@@ -65,7 +65,7 @@
         return wsdlURL;
     }
 
-    static Definition createWSDLDefinition(URL wsdlURL) {
+    static public Definition createWSDLDefinition(URL wsdlURL) {
         Definition wsdlDefinition = null;
         try {
             WSDLFactory factory = WSDLFactory.newInstance();

Added: webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/OperationDescriptionImplTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/OperationDescriptionImplTests.java?rev=820172&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/OperationDescriptionImplTests.java (added)
+++ webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/OperationDescriptionImplTests.java Wed Sep 30 04:34:34 2009
@@ -0,0 +1,105 @@
+/*
+ * 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.description.impl;
+
+import org.apache.axis2.jaxws.description.DescriptionFactory;
+import org.apache.axis2.jaxws.description.DescriptionTestUtils;
+import org.apache.axis2.jaxws.description.EndpointInterfaceDescription;
+import org.apache.axis2.jaxws.description.ServiceDescription;
+import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
+import org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite;
+import org.apache.axis2.jaxws.description.builder.ParameterDescriptionComposite;
+import org.apache.axis2.jaxws.description.builder.WebServiceAnnot;
+
+import javax.xml.namespace.QName;
+
+import javax.jws.WebService;
+import javax.wsdl.Definition;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * This test validates the error checking and internal functioning of the OperationDescription class
+ * and serves as a blueprint for how the code should function.
+ * Direct tests of the functionality of an OperationDescription and other
+ * Description classes is done in WSDLDescriptionTests.
+ */
+public class OperationDescriptionImplTests extends TestCase
+{
+  public void testDetermineOperationQName()
+  {
+    String wsdlRelativeLocation = "test-resources/wsdl/";
+    String wsdlFileName = "BindingNamespaceDefaults.wsdl";
+    String targetNamespace = "http://nonanonymous.complextype.test.org";
+    String wsdlLocation = wsdlRelativeLocation + wsdlFileName;
+
+    // Build up a DBC, including the WSDL Definition and the annotation information for 
+    // the impl class.
+    DescriptionBuilderComposite dbc = new DescriptionBuilderComposite();
+
+    URL wsdlURL = DescriptionTestUtils.getWSDLURL(wsdlFileName);
+    Definition wsdlDefn = DescriptionTestUtils.createWSDLDefinition(wsdlURL);
+    assertNotNull(wsdlDefn);
+
+    WebServiceAnnot webServiceAnnot = WebServiceAnnot.createWebServiceAnnotImpl();
+    assertNotNull(webServiceAnnot);
+    webServiceAnnot.setWsdlLocation(wsdlLocation);
+    webServiceAnnot.setTargetNamespace(targetNamespace);
+    webServiceAnnot.setServiceName("EchoMessageService");
+    webServiceAnnot.setPortName("EchoMessagePort");
+
+    MethodDescriptionComposite mdc = new MethodDescriptionComposite();
+    mdc.setMethodName("echoMessage");
+    mdc.setReturnType("java.lang.String");
+
+    ParameterDescriptionComposite pdc1 = new ParameterDescriptionComposite();
+    pdc1.setParameterType("java.lang.String");
+
+    mdc.addParameterDescriptionComposite(pdc1);
+
+    dbc.addMethodDescriptionComposite(mdc);
+    dbc.setWebServiceAnnot(webServiceAnnot);
+    dbc.setClassName(BindingNSImpl.class.getName());
+    dbc.setWsdlDefinition(wsdlDefn);
+    dbc.setwsdlURL(wsdlURL);
+    HashMap<String, DescriptionBuilderComposite> dbcMap =
+            new HashMap<String, DescriptionBuilderComposite>();
+    dbcMap.put(dbc.getClassName(), dbc);
+    List<ServiceDescription> serviceDescList =
+            DescriptionFactory.createServiceDescriptionFromDBCMap(dbcMap);
+    ServiceDescription sd = serviceDescList.get(0);
+    EndpointInterfaceDescription eid = new EndpointInterfaceDescriptionImpl(dbc, new EndpointDescriptionImpl(null, new QName(targetNamespace,"EchoMessagePort"), (ServiceDescriptionImpl)sd));
+      
+    assertEquals(new QName(targetNamespace, "echoMessage"), OperationDescriptionImpl.determineOperationQName(eid, mdc));
+
+  }
+  
+  @WebService(serviceName = "EchoMessageService", portName = "EchoMessagePort", targetNamespace = "http://nonanonymous.complextype.test.org", wsdlLocation = "test-resources/wsdl/BindingNamespace.wsdl")
+  public class BindingNSImpl {
+      public String echoMessage(String arg) {
+          return arg;
+      }
+  }
+  
+}