cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject svn commit: r475594 - in /incubator/cxf/trunk/rt/frontend/jaxws/src: main/java/org/apache/cxf/jaxws/support/ test/java/org/apache/cxf/jaxws/support/ test/resources/ test/resources/wsdl/
Date Thu, 16 Nov 2006 06:34:51 GMT
Author: tli
Date: Wed Nov 15 22:34:50 2006
New Revision: 475594

URL: http://svn.apache.org/viewvc?view=rev&rev=475594
Log:
fix bug of wrong default part name used to find part if WebParam or WebResult missing

Added:
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java
  (with props)
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/wsdl/
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/wsdl/default_partname_test.wsdl
  (with props)
Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java?view=diff&rev=475594&r1=475593&r2=475594
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
Wed Nov 15 22:34:50 2006
@@ -177,7 +177,7 @@
             return null;
         }
         
-        return getPartName(op, method, paramNumber, "in");
+        return getPartName(op, method, paramNumber, "arg" + paramNumber);
     }
 
     @Override
@@ -186,26 +186,27 @@
             return null;
         }
         
-        return getParameterName(op, method, paramNumber, "in");
+        return getParameterName(op, method, paramNumber, "arg" + paramNumber);
     }
 
     private QName getPartName(OperationInfo op, Method method, int paramNumber, String prefix)
{
         WebParam param = getWebParam(method, paramNumber);
+        String tns = op.getName().getNamespaceURI();
         if (param != null) {
-            String tns = op.getName().getNamespaceURI();
+//            if (param.targetNamespace().length() > 0) {
+//                tns = param.targetNamespace();
+//            }
             String local = param.partName();
-
             if (local.length() == 0) {
                 local = param.name();
             }
-
             if (local.length() == 0) {
                 getDefaultLocalName(op, method, paramNumber, prefix);
             }
-
             return new QName(tns, local);
-        }
-        return null;
+        } else {
+            return new QName(tns, prefix);
+        }        
     }
 
     private QName getParameterName(OperationInfo op, Method method, int paramNumber, String
prefix) {
@@ -260,7 +261,7 @@
     @Override
     public QName getOutParameterName(OperationInfo op, Method method, int paramNumber) {
         if (paramNumber >= 0) {
-            return getParameterName(op, method, paramNumber, "out");
+            return getParameterName(op, method, paramNumber, "return");
         } else {
             WebResult webResult = getWebResult(method);
 
@@ -273,7 +274,7 @@
                 }
 
                 if (local.length() == 0) {
-                    local = getDefaultLocalName(op, method, paramNumber, "out");
+                    local = getDefaultLocalName(op, method, paramNumber, "return");
                 }
 
                 return new QName(tns, local);
@@ -285,25 +286,26 @@
     @Override
     public QName getOutPartName(OperationInfo op, Method method, int paramNumber) {
         if (paramNumber >= 0) {
-            return getPartName(op, method, paramNumber, "out");
+            return getPartName(op, method, paramNumber, "return");
         } else {
             WebResult webResult = getWebResult(method);
-
+            String tns = op.getName().getNamespaceURI();
             if (webResult != null) {
-                String tns = op.getName().getNamespaceURI();
                 String local = webResult.partName();
-
+//                if (webResult.targetNamespace().length() > 0) {
+//                    tns = webResult.targetNamespace();
+//                }
                 if (local.length() == 0) {
                     local = webResult.name();
                 }
-
                 if (local.length() == 0) {
-                    local = getDefaultLocalName(op, method, paramNumber, "out");
+                    local = getDefaultLocalName(op, method, paramNumber, "return");
                 }
                 return new QName(tns, local);
+            } else {
+                return new QName(tns, "return");
             }
-        }
-        return super.getOutPartName(op, method, paramNumber);
+        }        
     }
 
     @Override

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java?view=auto&rev=475594
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java
Wed Nov 15 22:34:50 2006
@@ -0,0 +1,115 @@
+/**
+ * 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.cxf.jaxws.support;
+
+import java.lang.reflect.Method;
+
+import java.util.Iterator;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.wsdl.Definition;
+import javax.wsdl.Service;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.transport.DestinationFactoryManager;
+import org.apache.cxf.wsdl11.WSDLServiceBuilder;
+import org.apache.cxf.wsdl4jutils.WSDLLocatorImpl;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+
+public class JaxWsServiceConfigurationTest extends TestCase {
+
+    public void setUp() throws Exception {
+
+    }
+
+    public void testGetInPartName() throws Exception {
+        QName opName = new QName("http://cxf.com/", "sayHello");
+        Method sayHelloMethod = Hello.class.getMethod("sayHello", new Class[]{String.class,
String.class});
+        ServiceInfo si = getMockedServiceModel("/wsdl/default_partname_test.wsdl");
+        JaxWsServiceConfiguration jwsc = new JaxWsServiceConfiguration();
+        QName partName = jwsc.getInPartName(si.getInterface().getOperation(opName), sayHelloMethod,
0);
+        assertEquals("get wrong in partName for first param", new QName("http://cxf.com/",
"arg0"), partName);
+        partName = jwsc.getInPartName(si.getInterface().getOperation(opName), sayHelloMethod,
1);
+        assertEquals("get wrong in partName for first param", new QName("http://cxf.com/",
"arg1"), partName);
+    }
+
+    public void testGetOutPartName() throws Exception {
+        QName opName = new QName("http://cxf.com/", "sayHi");
+        Method sayHiMethod = Hello.class.getMethod("sayHi", new Class[]{});
+        ServiceInfo si = getMockedServiceModel("/wsdl/default_partname_test.wsdl");
+        JaxWsServiceConfiguration jwsc = new JaxWsServiceConfiguration();
+        QName partName = jwsc.getOutPartName(si.getInterface().getOperation(opName), sayHiMethod,
-1);
+        assertEquals("get wrong return partName", new QName("http://cxf.com/", "return"),
partName);
+    }
+
+    private ServiceInfo getMockedServiceModel(String wsdlUrl) throws Exception {
+        WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+        wsdlReader.setFeature("javax.wsdl.verbose", false);
+        Definition def = wsdlReader.readWSDL(new WSDLLocatorImpl(wsdlUrl));
+
+        IMocksControl control = EasyMock.createNiceControl();
+        Bus bus = control.createMock(Bus.class);
+        BindingFactoryManager bindingFactoryManager = control.createMock(BindingFactoryManager.class);
+        DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
+        WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
+
+        Service service = null;
+        for (Iterator<?> it = def.getServices().values().iterator(); it.hasNext();)
{
+            Object obj = it.next();
+            if (obj instanceof Service) {
+                service = (Service) obj;
+                break;
+            }
+        }
+
+        EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
+        EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
+        control.replay();
+
+        ServiceInfo serviceInfo = wsdlServiceBuilder.buildService(def, service);
+        serviceInfo.setProperty(WSDLServiceBuilder.WSDL_DEFINITION, null);
+        serviceInfo.setProperty(WSDLServiceBuilder.WSDL_SERVICE, null);
+        return serviceInfo;
+    }
+
+    @WebService(name = "Hello", targetNamespace = "http://cxf.com/")
+    public interface Hello {
+        @SOAPBinding(parameterStyle = javax.jws.soap.SOAPBinding.ParameterStyle.BARE, 
+                style = javax.jws.soap.SOAPBinding.Style.RPC, use = javax.jws.soap.SOAPBinding.Use.LITERAL)
+        @WebMethod(operationName = "sayHi", exclude = false)
+        String sayHi();
+
+        @SOAPBinding(parameterStyle = javax.jws.soap.SOAPBinding.ParameterStyle.BARE, 
+                style = javax.jws.soap.SOAPBinding.Style.RPC, use = javax.jws.soap.SOAPBinding.Use.LITERAL)
+        @WebMethod(operationName = "sayHello", exclude = false)
+        String sayHello(String arg0, String arg1);
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceConfigurationTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/wsdl/default_partname_test.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/wsdl/default_partname_test.wsdl?view=auto&rev=475594
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/wsdl/default_partname_test.wsdl
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/wsdl/default_partname_test.wsdl
Wed Nov 15 22:34:50 2006
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<wsdl:definitions targetNamespace="http://cxf.com/" xmlns:tns="http://cxf.com/" xmlns:ns1="http://cxf.com/"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+    <wsdl:types>
+        <xsd:schema targetNamespace="http://cxf.com/" version="1.0"
+            xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+            <xs:element name="sayHiResponse" nillable="true" type="xs:string" />
+        </xsd:schema>
+    </wsdl:types>
+    <wsdl:message name="sayHi"></wsdl:message>
+    <wsdl:message name="sayHiResponse">
+        <wsdl:part name="return" type="xsd:string"></wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="sayHello">
+        <wsdl:part name="arg0" type="xsd:string"></wsdl:part>
+        <wsdl:part name="arg1" type="xsd:string"></wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="sayHelloResponse">
+        <wsdl:part name="return" type="xsd:string"></wsdl:part>
+    </wsdl:message>
+    <wsdl:portType name="Hello">
+        <wsdl:operation name="sayHi">
+            <wsdl:input name="sayHi" message="tns:sayHi"></wsdl:input>
+            <wsdl:output name="sayHiResponse" message="tns:sayHiResponse"></wsdl:output>
+        </wsdl:operation>
+        <wsdl:operation name="sayHello">
+            <wsdl:input name="sayHello" message="tns:sayHi"></wsdl:input>
+            <wsdl:output name="sayHelloResponse" message="tns:sayHelloResponse"></wsdl:output>
+        </wsdl:operation>
+
+    </wsdl:portType>
+    <wsdl:binding name="HelloBinding" type="tns:Hello">
+        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"
/>
+        <wsdl:operation name="sayHi">
+            <soap:operation style="rpc" />
+            <wsdl:input name="sayHi">
+                <soap:body use="literal" />
+            </wsdl:input>
+            <wsdl:output name="sayHiResponse">
+                <soap:body use="literal" />
+            </wsdl:output>
+        </wsdl:operation>
+        <wsdl:operation name="sayHello">
+            <soap:operation style="rpc" />
+            <wsdl:input name="sayHello">
+                <soap:body use="literal" />
+            </wsdl:input>
+            <wsdl:output name="sayHelloResponse">
+                <soap:body use="literal" />
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="HelloService">
+        <wsdl:port name="HelloPort" binding="tns:HelloBinding">
+            <soap:address location="http://localhost:9000/Hello" />
+        </wsdl:port>
+    </wsdl:service>
+</wsdl:definitions>

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/wsdl/default_partname_test.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/wsdl/default_partname_test.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/wsdl/default_partname_test.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message