use of org.apache.cxf.endpoint.ClientImpl.IllegalEmptyResponseException in project cxf by apache.
the class DispatchImpl method invoke.
@SuppressWarnings("unchecked")
public T invoke(T obj, boolean isOneWay) {
checkError();
try {
if (obj instanceof SOAPMessage) {
SOAPMessage msg = (SOAPMessage) obj;
if (msg.countAttachments() > 0) {
client.getRequestContext().put(AttachmentOutInterceptor.WRITE_ATTACHMENTS, Boolean.TRUE);
}
} else if (context != null) {
Boolean unwrapProperty = obj instanceof JAXBElement ? Boolean.FALSE : Boolean.TRUE;
getRequestContext().put("unwrap.jaxb.element", unwrapProperty);
}
QName opName = (QName) getRequestContext().get(MessageContext.WSDL_OPERATION);
boolean hasOpName;
if (opName == null) {
hasOpName = false;
opName = isOneWay ? INVOKE_ONEWAY_QNAME : INVOKE_QNAME;
} else {
hasOpName = true;
BindingOperationInfo bop = client.getEndpoint().getBinding().getBindingInfo().getOperation(opName);
if (bop == null) {
addInvokeOperation(opName, isOneWay);
}
}
Holder<T> holder = new Holder<>(obj);
opName = calculateOpName(holder, opName, hasOpName);
Object[] ret = client.invokeWrapped(opName, holder.value);
if (isOneWay || ret == null || ret.length == 0) {
return null;
}
return (T) ret[0];
} catch (IllegalEmptyResponseException ie) {
return null;
} catch (Exception ex) {
throw mapException(ex);
}
}
use of org.apache.cxf.endpoint.ClientImpl.IllegalEmptyResponseException in project cxf by apache.
the class EmptySOAPBodyTest method testPlaintext.
@org.junit.Test
public void testPlaintext() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = EmptySOAPBodyTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = EmptySOAPBodyTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItPlaintextPort");
DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);
try {
port.doubleIt(25);
fail("Should have thown an exception");
} catch (SOAPFaultException t) {
assertTrue("Wrong exception cause " + t.getCause(), t.getCause() instanceof IllegalEmptyResponseException);
}
((java.io.Closeable) port).close();
bus.shutdown(true);
}
Aggregations