/** * Create a MessageContext, and notify any registered ContextListener. * * @return a new MessageContext */ public MessageContext createMessageContext() { MessageContext msgCtx = new MessageContext(this); contextCreated(msgCtx); return msgCtx; }
/** * Create a MessageContext, and notify any registered ContextListener. * * @return a new MessageContext */ public MessageContext createMessageContext() { MessageContext msgCtx = new MessageContext(this); contextCreated(msgCtx); return msgCtx; }
protected MessageContext buildMessageContext(String opName) throws AxisFault { MessageContext msgCtx = new MessageContext(); AxisService svc = getAxisService(); msgCtx.setAxisService(svc); msgCtx.setAxisOperation(getAxisOperation(svc, opName)); return msgCtx; }
/** * Directly invoke a named operation with a Robust In-Only MEP. This method just sends your * supplied XML and possibly receives a fault. For more control, you can instead create a client * for the operation and use that client to execute the send. * * @param operation name of operation to be invoked (non-<code>null</code>) * @param elem XML to send * @throws AxisFault if something goes wrong while sending it or if a fault is received in * response (per the Robust In-Only MEP). * @see #createClient(QName) */ public void sendRobust(QName operation, OMElement elem) throws AxisFault { MessageContext mc = new MessageContext(); fillSOAPEnvelope(mc, elem); OperationClient mepClient = createClient(operation); mepClient.addMessageContext(mc); mepClient.execute(true); }
private String getTenantDomain(SynapseEnvironment synapseEnvironment) { TenantInfoConfigurator configurator = synapseEnvironment.getTenantInfoConfigurator(); if (configurator != null) { org.apache.axis2.context.MessageContext axisMessageContext = new org.apache.axis2.context.MessageContext(); MessageContext messageContext = new Axis2MessageContext(axisMessageContext, this, synapseEnvironment); configurator.extractTenantInfo(messageContext); if (messageContext.getProperty("tenant.info.domain") != null) { return (String) messageContext.getProperty("tenant.info.domain"); } } return null; }
private static MessageContext sendReceive(OMElement llomElement, ServiceClient serviceClient) throws AxisFault { MessageContext messageContext = new MessageContext(); fillSOAPEnvelope(messageContext, llomElement, serviceClient); OperationClient operationClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP); operationClient.addMessageContext(messageContext); operationClient.execute(true); MessageContext response = operationClient .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE); if (serviceClient.getOptions().isCallTransportCleanup()) { response.getEnvelope().build(); serviceClient.cleanupTransport(); return response; } else { return response; } }
/** * Inspired by {@link ServiceClient#sendReceive(QName, OMElement)}, * {@link ServiceClient#fireAndForget(QName, OMElement)} and others */ public MessageContext sendReceive2(final QName operation, final OMElement xmlPayload) throws AxisFault { final MessageContext messageContext = new MessageContext(); fillSOAPEnvelope(messageContext, xmlPayload); final OperationClient operationClient = createClient(operation); operationClient.addMessageContext(messageContext); // TODO use operationClient.setCallback(AxisCallback) and do not block // we would first need to add a thread pool to the configuration context to use our thread...? // no it doesn't make sense, if we have to block a thread, so let's block this one... or use the real async // send! (which seems a bit more complex... not sure it's a good idea for now) operationClient.execute(true); return operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE); }
private MessageContext createMessageContext() { org.apache.axis2.context.MessageContext axisMessageContext = new org.apache.axis2.context.MessageContext(); MessageContext synapseMessageContext = new Axis2MessageContext(axisMessageContext, null, null); axisMessageContext.setProperty("OPEN_CONNNECTIONS_MAP", createMap()); return synapseMessageContext; }
@Test public void testDoProcessing() throws Exception { MessageContext mc = new MessageContext(); mc.setFLOW(MessageContext.IN_FLOW); try { Handler.InvocationResponse invokeResp = handler.invoke(mc); assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp); } catch (Exception e) { fail(e.getMessage()); } verify(mockAppender, atLeastOnce()) .doAppend(captorLoggingEvent.capture()); List<LoggingEvent> events = captorLoggingEvent.getAllValues(); String msg = "doProcessing"; assertTrue(eventContainsMsg(events, Level.DEBUG, msg)); } }
public void testClonePartially() throws Exception { String key = "propKey"; MessageContext origMc = new MessageContext(); origMc.setProperty(key, "propValue"); MessageContext newMc = MessageHelper.clonePartially(origMc); Object result = newMc.getProperty(key); assertEquals(result, "propValue"); }
@Override public OMElement sendReceive(QName operationQName, OMElement xmlPayload) throws AxisFault { MessageContext messageContext = new MessageContext(); fillSOAPEnvelope(messageContext, xmlPayload); OperationClient operationClient = createClient(operationQName); operationClient.addMessageContext(messageContext); operationClient.execute(true); MessageContext response = operationClient .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE); if (super.getOptions().isCallTransportCleanup()) { response.getEnvelope().build(); cleanupTransport(); } return response.getEnvelope().getBody(); }
public void testClonePartiallyWithAttachments() throws Exception { MessageContext origMc = new MessageContext(); String contentId = origMc.addAttachment(new DataHandler("test", "text/html")); MessageContext newMc = MessageHelper.clonePartially(origMc); DataHandler dh = newMc.getAttachment(contentId); assertNotNull(dh); assertEquals("test", dh.getContent()); }
protected void setUp() throws Exception { super.setUp(); SynapseConfiguration synCfg = new SynapseConfiguration(); AxisConfiguration config = new AxisConfiguration(); testCtx = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synCfg, new Axis2SynapseEnvironment(new ConfigurationContext(config), synCfg)); ((Axis2MessageContext) testCtx).getAxis2MessageContext().setConfigurationContext(new ConfigurationContext(config)); }
protected void setUp() throws Exception { super.setUp(); SynapseConfiguration synCfg = new SynapseConfiguration(); AxisConfiguration config = new AxisConfiguration(); testCtx = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synCfg, new Axis2SynapseEnvironment(new ConfigurationContext(config), synCfg)); ((Axis2MessageContext) testCtx).getAxis2MessageContext().setConfigurationContext(new ConfigurationContext(config)); }
public void testCleanup() throws AxisFault { TransportSender sender = getTransportSender(); MessageContext msgContext = new MessageContext(); HttpGet httpMethod = new HttpGet(); msgContext.setProperty(HTTPConstants.HTTP_METHOD, httpMethod); assertNotNull("HttpMethod can not be null", msgContext.getProperty(HTTPConstants.HTTP_METHOD)); sender.cleanup(msgContext); assertNull("HttpMethod should be null", msgContext.getProperty(HTTPConstants.HTTP_METHOD)); } }
protected void setUp() throws Exception { super.setUp(); SynapseConfiguration synCfg = new SynapseConfiguration(); AxisConfiguration config = new AxisConfiguration(); testCtx = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synCfg, new Axis2SynapseEnvironment(new ConfigurationContext(config), synCfg)); ((Axis2MessageContext) testCtx).getAxis2MessageContext().setConfigurationContext(new ConfigurationContext(config)); SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope(); envelope.getBody().addChild(createOMElement("<describeSObjects/>")); testCtx.setEnvelope(envelope); }
protected void setUp() throws Exception { super.setUp(); SynapseConfiguration synCfg = new SynapseConfiguration(); AxisConfiguration config = new AxisConfiguration(); testCtx = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synCfg, new Axis2SynapseEnvironment(new ConfigurationContext(config), synCfg)); ((Axis2MessageContext) testCtx).getAxis2MessageContext().setConfigurationContext(new ConfigurationContext(config)); SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope(); envelope.getBody().addChild(createOMElement("<sendEmail/>")); testCtx.setEnvelope(envelope); }
private MessageContext getNewMessageContextUsingAxis2Info(CreateSequenceMessage createSequenceMessage) throws AxisFault, RMMessageBuildingException { MessageContext messageContext = new MessageContext(); messageContext.setServiceContext(this.axis2Info.getServiceContext()); messageContext.setEnvelope(createSequenceMessage.toSOAPEnvelope()); messageContext.setMessageID(UUIDGenerator.getUUID()); messageContext.setTransportIn(this.axis2Info.getTransportIn()); messageContext.setTransportOut(this.axis2Info.getTransportOut()); messageContext.setReplyTo(this.ackToEpr); messageContext.setProperty(MercuryConstants.PROCESS_RM_CONTROL_MESSAGE, Constants.VALUE_TRUE); messageContext.setOptions(new Options()); // set the correct options messageContext.getOptions().setTo(this.axis2Info.getOptions().getTo()); messageContext.getOptions().setUseSeparateListener(this.axis2Info.getOptions().isUseSeparateListener()); messageContext.setServerSide(this.axis2Info.isServerSide()); return messageContext; }
protected void setUp() throws Exception { super.setUp(); SynapseConfiguration synCfg = new SynapseConfiguration(); AxisConfiguration config = new AxisConfiguration(); testCtx = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synCfg, new Axis2SynapseEnvironment(new ConfigurationContext(config), synCfg)); ((Axis2MessageContext) testCtx).getAxis2MessageContext().setConfigurationContext(new ConfigurationContext(config)); SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope(); envelope.getBody().addChild(createOMElement("<queryResponse>" + "<result>" + "<done>false</done><queryLocator>01g9000000MVzggAAD-200</queryLocator>" + "<size>370</size>" + "</result>" + "</queryResponse>")); testCtx.setEnvelope(envelope); }
public static MessageContext createLightweightSynapseMessageContext( String payload, SynapseConfiguration config) throws Exception { org.apache.axis2.context.MessageContext mc = new org.apache.axis2.context.MessageContext(); SynapseEnvironment env = new Axis2SynapseEnvironment(config); MessageContext synMc = new Axis2MessageContext(mc, config, env); SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope(); OMDocument omDoc = OMAbstractFactory.getSOAP11Factory().createOMDocument(); omDoc.addChild(envelope); envelope.getBody().addChild(createOMElement(payload)); synMc.setEnvelope(envelope); return synMc; }