use of org.apache.cxf.endpoint.ClientCallback in project cxf by apache.
the class ClientOutFaultObserver method onMessage.
/**
* override the super class method
*/
public void onMessage(Message m) {
if (m.get(Message.INBOUND_MESSAGE).equals(Boolean.TRUE)) {
// it's outbound fault observer so only take care of outbound fault
return;
}
Exception ex = m.getContent(Exception.class);
// remove callback so that it won't be invoked twice
ClientCallback callback = m.getExchange().remove(ClientCallback.class);
if (callback != null) {
Map<String, Object> resCtx = CastUtils.cast((Map<?, ?>) m.getExchange().getOutMessage().get(Message.INVOCATION_CONTEXT));
resCtx = CastUtils.cast((Map<?, ?>) resCtx.get(Client.RESPONSE_CONTEXT));
callback.handleException(resCtx, ex);
}
}
use of org.apache.cxf.endpoint.ClientCallback in project cxf by apache.
the class JaxWsDynamicClientTest method testInvocation.
@Test
public void testInvocation() throws Exception {
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
URL wsdlURL = new URL("http://localhost:" + PORT + "/NoBodyParts/NoBodyPartsService?wsdl");
Client client = dcf.createClient(wsdlURL);
byte[] bucketOfBytes = IOUtils.readBytesFromStream(getClass().getResourceAsStream("/wsdl/no_body_parts.wsdl"));
Operation1 parameters = new Operation1();
parameters.setOptionString("opt-ion");
parameters.setTargetType("tar-get");
Object[] rparts = client.invoke("operation1", parameters, bucketOfBytes);
Operation1Response r = (Operation1Response) rparts[0];
assertEquals(md5(bucketOfBytes), r.getStatus());
ClientCallback callback = new ClientCallback();
client.invoke(callback, "operation1", parameters, bucketOfBytes);
rparts = callback.get();
r = (Operation1Response) rparts[0];
assertEquals(md5(bucketOfBytes), r.getStatus());
}
use of org.apache.cxf.endpoint.ClientCallback in project cxf by apache.
the class DispatchImpl method invokeAsync.
public Future<?> invokeAsync(T obj, AsyncHandler<T> asyncHandler) {
checkError();
client.setExecutor(getClient().getEndpoint().getExecutor());
ClientCallback callback = new JaxwsClientCallback<T>(asyncHandler, this);
Response<T> ret = new JaxwsResponseCallback<T>(callback);
try {
boolean hasOpName;
QName opName = (QName) getRequestContext().get(MessageContext.WSDL_OPERATION);
if (opName == null) {
hasOpName = false;
opName = INVOKE_QNAME;
} else {
hasOpName = true;
BindingOperationInfo bop = client.getEndpoint().getBinding().getBindingInfo().getOperation(opName);
if (bop == null) {
addInvokeOperation(opName, false);
}
}
Holder<T> holder = new Holder<T>(obj);
opName = calculateOpName(holder, opName, hasOpName);
client.invokeWrapped(callback, opName, holder.value);
return ret;
} catch (Exception ex) {
throw mapException(ex);
}
}
use of org.apache.cxf.endpoint.ClientCallback in project cxf by apache.
the class JaxWsClientProxy method invokeAsync.
@SuppressWarnings("unchecked")
private Object invokeAsync(Method method, BindingOperationInfo oi, Object[] params) throws Exception {
client.setExecutor(getClient().getEndpoint().getExecutor());
AsyncHandler<Object> handler;
if (params.length > 0 && params[params.length - 1] instanceof AsyncHandler) {
handler = (AsyncHandler<Object>) params[params.length - 1];
Object[] newParams = new Object[params.length - 1];
for (int i = 0; i < newParams.length; i++) {
newParams[i] = params[i];
}
params = newParams;
} else {
handler = null;
}
ClientCallback callback = new JaxwsClientCallback<Object>(handler, this);
Response<Object> ret = new JaxwsResponseCallback<Object>(callback);
client.invoke(callback, oi, params);
return ret;
}
Aggregations