You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2026/10/15 15:12:35 UTC

(cxf) 01/01: CXF-6737: Fix binding of void operations when simple frontend client uses a WSDL

This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch coheigea/CXF-6737
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 4075f018e3bc63f167f3b340bba40376df86b618
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Thu Oct 15 16:12:03 2026 +0100

    CXF-6737: Fix binding of void operations when simple frontend client uses a WSDL
---
 .../apache/cxf/service/factory/RountripTest.java   | 41 ++++++++++++++++++++++
 .../factory/ReflectionServiceFactoryBean.java      |  4 +--
 2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/RountripTest.java b/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/RountripTest.java
index de77dd6f270..a65fc810065 100644
--- a/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/RountripTest.java
+++ b/rt/frontend/simple/src/test/java/org/apache/cxf/service/factory/RountripTest.java
@@ -18,13 +18,20 @@
  */
 package org.apache.cxf.service.factory;
 
+import java.io.File;
+import java.io.Writer;
 import java.net.URL;
+import java.nio.file.Files;
 
+import javax.wsdl.Definition;
 import javax.xml.namespace.QName;
 
+import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.frontend.ClientFactoryBean;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.wsdl.WSDLManager;
+import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
 import org.apache.hello_world_doc_lit.Greeter;
 import org.apache.hello_world_doc_lit.GreeterImplDoc;
 
@@ -58,6 +65,40 @@ public class RountripTest extends AbstractSimpleFrontendTest {
         assertEquals("hello", client.echo("hello"));
     }
 
+    @Test
+    public void testVoidMethodWithWsdl() throws Exception {
+        ServerFactoryBean svrBean = new ServerFactoryBean();
+        svrBean.setAddress("http://localhost/HelloWsdl");
+        svrBean.setTransportId("http://schemas.xmlsoap.org/soap/http");
+        svrBean.setServiceBean(new HelloServiceImpl());
+        svrBean.setServiceClass(HelloService.class);
+        svrBean.setBus(getBus());
+
+        Server server = svrBean.create();
+
+        Definition def = new ServiceWSDLBuilder(getBus(),
+            server.getEndpoint().getService().getServiceInfos()).build();
+        File wsdlFile = File.createTempFile("hello", ".wsdl");
+        wsdlFile.deleteOnExit();
+        try (Writer w = Files.newBufferedWriter(wsdlFile.toPath())) {
+            getBus().getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter().writeWSDL(def, w);
+        }
+
+        ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
+        ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
+        clientBean.setAddress("http://localhost/HelloWsdl");
+        clientBean.setTransportId("http://schemas.xmlsoap.org/soap/http");
+        clientBean.setServiceClass(HelloService.class);
+        clientBean.setWsdlURL(wsdlFile.toURI().toString());
+        clientBean.setBus(getBus());
+
+        HelloService client = (HelloService) proxyFactory.create();
+
+        assertEquals("hello", client.sayHello());
+        assertEquals("hello", client.echo("hello"));
+        client.ping();
+    }
+
     @Test
     public void testOneWay() throws Exception {
         ServerFactoryBean svrBean = new ServerFactoryBean();
diff --git a/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ReflectionServiceFactoryBean.java b/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ReflectionServiceFactoryBean.java
index 096f607829c..ef6b53a1136 100644
--- a/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ReflectionServiceFactoryBean.java
+++ b/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ReflectionServiceFactoryBean.java
@@ -864,8 +864,8 @@ public class ReflectionServiceFactoryBean extends org.apache.cxf.service.factory
         }
         setIndexes(o.getInput());
         sendEvent(Event.OPERATIONINFO_IN_MESSAGE_SET, origOp, method, origOp.getInput());
-        // Initialize return type
-        if (o.hasOutput()
+        // Initialize return type (a void method has no return part to map)
+        if (o.hasOutput() && !void.class.equals(method.getReturnType())
             && !initializeParameter(o, method, -1, method.getReturnType(), method.getGenericReturnType())) {
             return false;
         }