@SuppressWarnings("unchecked") public T get() throws InterruptedException, ExecutionException { return (T)callback.get()[0]; } @SuppressWarnings("unchecked")
public boolean isCancelled() { return callback.isCancelled(); } public boolean isDone() {
public boolean cancel(boolean mayInterruptIfRunning) { return callback.cancel(mayInterruptIfRunning); } @SuppressWarnings("unchecked")
try { if (callback != null) { if (callback.isCancelled()) { getConduitSelector().complete(message.getExchange()); return; callback.start(message); responseContext.put(Thread.currentThread(), resCtx); callback.handleException(resCtx, error); null, resCtx); callback.handleResponse(resCtx, obj); } catch (Throwable ex) { callback.handleException(resCtx, ex);
cc.handleResponse(null, null);
@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()); }
/** * 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); ClientCallback callback = m.getExchange().get(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); } }
public boolean isDone() { return callback.isDone(); } }
break; case ASYNC: final ClientCallback callback = new ClientCallback(); final long workItemId = workItem.getId(); final String deploymentId = nonNull(((WorkItemImpl) workItem).getDeploymentId()); break; case ONEWAY: ClientCallback callbackFF = new ClientCallback();
try { if (callback != null) { if (callback.isCancelled()) { getConduitSelector().complete(message.getExchange()); return; callback.start(message); responseContext.put(Thread.currentThread(), resCtx); callback.handleException(resCtx, error); null, resCtx); callback.handleResponse(resCtx, obj); } catch (Throwable ex) { callback.handleException(resCtx, ex);
public void onMessage(Message message) { Exception ex = message.getContent(Exception.class); if (ex != null) { completeExchange(message.getExchange()); if (message.getContent(Exception.class) == null) { // handle the right response List<Object> resList = null; Message inMsg = message.getExchange().getInMessage(); Map<String, Object> ctx = responseContext.get(Thread.currentThread()); resList = CastUtils.cast(inMsg.getContent(List.class)); Object[] result = resList == null ? null : resList.toArray(); callback.handleResponse(ctx, result); return; } } outFaultObserver.onMessage(message); } });
/** * 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); } }
public boolean isDone() { return callback.isDone(); } }
break; case ASYNC: final ClientCallback callback = new ClientCallback(); final long workItemId = workItem.getId(); final String deploymentId = nonNull(((WorkItemImpl) workItem).getDeploymentId()); break; case ONEWAY: ClientCallback callbackFF = new ClientCallback();
try { if (callback != null) { if (callback.isCancelled()) { completeExchange(message.getExchange()); return; callback.start(message); callback.handleException(resCtx, error); null, resCtx); callback.handleResponse(resCtx, obj); } catch (Throwable ex) { callback.handleException(resCtx, ex);
public void onMessage(Message message) { Exception ex = message.getContent(Exception.class); if (ex != null) { completeExchange(message.getExchange()); if (message.getContent(Exception.class) == null) { // handle the right response List<Object> resList = null; Message inMsg = message.getExchange().getInMessage(); Map<String, Object> ctx = responseContext.get(Thread.currentThread()); resList = CastUtils.cast(inMsg.getContent(List.class)); Object[] result = resList == null ? null : resList.toArray(); callback.handleResponse(ctx, result); return; } } outFaultObserver.onMessage(message); } });
/** * 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); ClientCallback callback = m.getExchange().get(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); } }
@SuppressWarnings("unchecked") public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return (T)callback.get(timeout, unit)[0]; } public boolean isCancelled() {