Skip to content

Commit

Permalink
[CXF-7653] Throw a more informative exception if the result could not…
Browse files Browse the repository at this point in the history
… be obtained from the response soap message
  • Loading branch information
dkulp committed Feb 23, 2018
1 parent 65f119d commit 1396f04
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
13 changes: 13 additions & 0 deletions core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,19 @@ protected Object[] processResult(Message message,
throw ex;
}

if (resList == null
&& oi != null && !oi.getOperationInfo().isOneWay()) {

BindingOperationInfo boi = oi;
if (boi.isUnwrapped()) {
boi = boi.getWrappedOperation();
}
if (!boi.getOutput().getMessageParts().isEmpty()) {
//we were supposed to get some output, but didn't
throw new IllegalStateException("Response message did not contain proper response data. Expected: "
+ boi.getOutput().getMessageParts().get(0).getConcreteName());
}
}
if (resList != null) {
return resList.toArray();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.soap.SOAPFaultException;

import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
Expand All @@ -35,7 +36,6 @@
/**
* Test what happens when we make an invocation and get back an empty SOAP Body (see CXF-7653)
*/
@org.junit.Ignore("Ignoring this until CXF-7653 is resolved")
public class EmptySOAPBodyTest extends AbstractBusClientServerTestBase {
static final String PORT = allocatePort(EmptySOAPBodyServer.class);

Expand Down Expand Up @@ -74,7 +74,13 @@ public void testPlaintext() throws Exception {
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);

port.doubleIt(25);
try {
port.doubleIt(25);
fail("Should have thown an exception");
} catch (SOAPFaultException t) {
assertTrue("Wrong exception cause " + t.getCause(),
t.getCause() instanceof IllegalStateException);
}

((java.io.Closeable)port).close();

Expand Down

0 comments on commit 1396f04

Please sign in to comment.