/** * Create an {@link Exchange} instance for the target service operation. * @param handler The ExchangeHandler to be used on the Exchange. * @return The Exchange instance. */ public Exchange createExchange(ExchangeHandler handler) { return createExchange(null, handler); }
/** * Set the response handler. * @param handler The response handler. * @return This invoker instance. */ public Invoker responseHandler(ExchangeHandler handler) { if (handler != null) { _exchangeHandlerProxy = createHandlerProxy(handler); } return this; }
/** * Sets a property at {@link Scope.MESSAGE}. * @param name the name * @param value the value * @return This invoker instance. */ public Invoker property(String name, Object value) { return property(name, value, null); }
/** * Send an IN_OUT message to the target Service. * @param messagePayload The message payload. * @return The response message. * @throws InvocationFaultException if the message exchange produces a fault */ public Message sendInOut(Object messagePayload) throws InvocationFaultException { ExchangeHandlerProxy exchangeHandlerProxy = _exchangeHandlerProxy; ResponseCatcher responseCatcher = null; if (exchangeHandlerProxy == null) { responseCatcher = new ResponseCatcher(); exchangeHandlerProxy = createHandlerProxy(responseCatcher); } Exchange exchange = createExchange(ExchangePattern.IN_OUT, exchangeHandlerProxy._exchangeHandlerProxy); Message message = exchange.createMessage().setContent(messagePayload); setProperties(exchange, message); addAttachments(message); exchange.send(message); exchangeHandlerProxy._proxyInvocationHandler.waitForResponse(_timeoutMillis); if (responseCatcher != null) { if (responseCatcher._isFault) { throw new InvocationFaultException(responseCatcher._response); } else { return responseCatcher._response; } } return null; }
/** * Create a new {@link Invoker} instance for invoking a Service in the test ServiceDomain. * @param serviceName The target Service name. * @return The invoker instance. */ public Invoker newInvoker(QName serviceName) { return new Invoker(getServiceDomain(), serviceName); }
/** * Send an IN_OUT message to the target Service. * @param messagePayload The message payload. * @return The response message. * @throws InvocationFaultException if the message exchange produces a fault */ public Message sendInOut(Object messagePayload) throws InvocationFaultException { ExchangeHandlerProxy exchangeHandlerProxy = _exchangeHandlerProxy; ResponseCatcher responseCatcher = null; if (exchangeHandlerProxy == null) { responseCatcher = new ResponseCatcher(); exchangeHandlerProxy = createHandlerProxy(responseCatcher); } Exchange exchange = createExchange(ExchangePattern.IN_OUT, exchangeHandlerProxy._exchangeHandlerProxy); Message message = exchange.createMessage().setContent(messagePayload); setProperties(exchange, message); addAttachments(message); exchange.send(message); exchangeHandlerProxy._proxyInvocationHandler.waitForResponse(_timeoutMillis); if (responseCatcher != null) { if (responseCatcher._isFault) { throw new InvocationFaultException(responseCatcher._response); } else { return responseCatcher._response; } } return null; }
/** * Create a new {@link Invoker} instance for invoking a Service in the test ServiceDomain. * @param serviceName The target Service name. * @return The invoker instance. */ public Invoker newInvoker(QName serviceName) { return new Invoker(getServiceDomain(), serviceName); }
/** * Send an IN_ONLY message to the target Service. * @param messagePayload The message payload. * @throws InvocationFaultException if the message exchange produces a fault */ public void sendInOnly(Object messagePayload) throws InvocationFaultException { ExchangeHandlerProxy exchangeHandlerProxy = _exchangeHandlerProxy; ResponseCatcher responseCatcher = null; if (exchangeHandlerProxy == null) { responseCatcher = new ResponseCatcher(); exchangeHandlerProxy = createHandlerProxy(responseCatcher); } Exchange exchange = createExchange(ExchangePattern.IN_ONLY, exchangeHandlerProxy._exchangeHandlerProxy); Message message = exchange.createMessage().setContent(messagePayload); setProperties(exchange, message); addAttachments(message); exchange.send(message); if (exchange.getState().equals(ExchangeState.FAULT)) { throw new InvocationFaultException(exchange.getMessage()); } }
/** * Set the response handler. * @param handler The response handler. * @return This invoker instance. */ public Invoker responseHandler(ExchangeHandler handler) { if (handler != null) { _exchangeHandlerProxy = createHandlerProxy(handler); } return this; }
/** * Sets a property at {@link Scope.MESSAGE}. * @param name the name * @param value the value * @return This invoker instance. */ public Invoker property(String name, Object value) { return property(name, value, null); }
/** * Create an {@link Exchange} instance for the target service operation. * @param handler The ExchangeHandler to be used on the Exchange. * @return The Exchange instance. */ public Exchange createExchange(ExchangeHandler handler) { return createExchange(null, handler); }
/** * Send an IN_ONLY message to the target Service. * @param messagePayload The message payload. * @throws InvocationFaultException if the message exchange produces a fault */ public void sendInOnly(Object messagePayload) throws InvocationFaultException { ExchangeHandlerProxy exchangeHandlerProxy = _exchangeHandlerProxy; ResponseCatcher responseCatcher = null; if (exchangeHandlerProxy == null) { responseCatcher = new ResponseCatcher(); exchangeHandlerProxy = createHandlerProxy(responseCatcher); } Exchange exchange = createExchange(ExchangePattern.IN_ONLY, exchangeHandlerProxy._exchangeHandlerProxy); Message message = exchange.createMessage().setContent(messagePayload); setProperties(exchange, message); addAttachments(message); exchange.send(message); if (exchange.getState().equals(ExchangeState.FAULT)) { throw new InvocationFaultException(exchange.getMessage()); } }