Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -58,6 +65,40 @@ public void testServerFactoryBean() throws Exception {
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,8 +864,8 @@ protected boolean initializeClassInfo(OperationInfo o, Method method, List<Strin
}
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;
}
Expand Down
Loading