/** * Adds Synapse Service to Axis2 configuration which enables the main message mediation. * * @throws AxisFault if an error occurs during Axis2 service initialization */ private void deploySynapseService() throws AxisFault { log.info("Deploying the Synapse service..."); // Dynamically initialize the Synapse Service and deploy it into Axis2 AxisConfiguration axisCfg = configurationContext.getAxisConfiguration(); AxisService synapseService = new AxisService(SynapseConstants.SYNAPSE_SERVICE_NAME); AxisOperation mediateOperation = new InOutAxisOperation( SynapseConstants.SYNAPSE_OPERATION_NAME); mediateOperation.setMessageReceiver(new SynapseMessageReceiver()); synapseService.addOperation(mediateOperation); List<String> transports = new ArrayList<String>(); transports.add(Constants.TRANSPORT_HTTP); transports.add(Constants.TRANSPORT_HTTPS); synapseService.setExposedTransports(transports); AxisServiceGroup synapseServiceGroup = new AxisServiceGroup(axisCfg); synapseServiceGroup.setServiceGroupName(SynapseConstants.SYNAPSE_SERVICE_NAME); synapseServiceGroup.addParameter(SynapseConstants.HIDDEN_SERVICE_PARAM, "true"); synapseServiceGroup.addService(synapseService); axisCfg.addServiceGroup(synapseServiceGroup); }
traceOrDebug(traceOn, "Synapse received a new message for message mediation..."); traceOrDebug(traceOn, "Received To: " + (mc.getTo() != null ? mc.getTo().getAddress() : "null")); traceOrDebug(traceOn, "SOAPAction: " + (mc.getSoapAction() != null ? mc.getSoapAction() : "null")); traceOrDebug(traceOn, "WSA-Action: " + (mc.getWSAAction() != null ? mc.getWSAAction() : "null")); warn(traceOn, "Executing fault handler due to exception encountered", synCtx); ((FaultHandler) synCtx.getFaultStack().pop()).handleFault(synCtx, syne); warn(traceOn, "Exception encountered but no fault handler found - " + "message dropped", synCtx); doPostInjectUpdates(synCtx);
traceOrDebug(traceOn, "Synapse received a new message for message mediation..."); traceOrDebug(traceOn, "Received To: " + (mc.getTo() != null ? mc.getTo().getAddress() : "null")); traceOrDebug(traceOn, "SOAPAction: " + (mc.getSoapAction() != null ? mc.getSoapAction() : "null")); traceOrDebug(traceOn, "WSA-Action: " + (mc.getWSAAction() != null ? mc.getWSAAction() : "null")); warn(traceOn, "Executing fault handler due to exception encountered", synCtx); ((FaultHandler) synCtx.getFaultStack().pop()).handleFault(synCtx, syne); warn(traceOn, "Exception encountered but no fault handler found - " + "message dropped", synCtx);
mc.setEnvelope(TestUtils.getTestContext("<empty/>").getEnvelope()); new SynapseMessageReceiver().receive(mc);
public void testFaultSequence() throws Exception { API api = new API("TestAPI", "/test"); Resource resource = new Resource(); resource.setDispatcherHelper(new URITemplateHelper("/~{user}")); SequenceMediator inSequence = getTestSequence("seq.in", "seq.in.value"); ((PropertyMediator) inSequence.getChild(0)).setScope("axis2"); XSLTMediator xsltMediator = new XSLTMediator(); xsltMediator.setXsltKey(new Value("/bogus/key")); inSequence.addChild(xsltMediator); resource.setInSequence(inSequence); SequenceMediator faultSequence = getTestSequence("seq.fault", "seq.fault.value"); ((PropertyMediator) faultSequence.getChild(0)).setScope("axis2"); resource.setFaultSequence(faultSequence); api.addResource(resource); SynapseConfiguration synapseConfig = new SynapseConfiguration(); synapseConfig.addAPI(api.getName(), api); synapseConfig.addSequence("main", getTestSequence("main.in", "main.value")); MessageContext synCtx = getMessageContext(synapseConfig, false, "/test/~foo", "GET"); MessageContextCreatorForAxis2.setSynConfig(synapseConfig); MessageContextCreatorForAxis2.setSynEnv(synCtx.getEnvironment()); org.apache.axis2.context.MessageContext mc = ((Axis2MessageContext) synCtx).getAxis2MessageContext(); mc.setConfigurationContext(((Axis2SynapseEnvironment) synCtx.getEnvironment()).getAxis2ConfigurationContext()); new SynapseMessageReceiver().receive(mc); assertEquals("seq.in.value", mc.getProperty("seq.in")); assertEquals("seq.fault.value", mc.getProperty("seq.fault")); } }
/** * Adds Synapse Service to Axis2 configuration which enables the main message mediation. * * @throws AxisFault if an error occurs during Axis2 service initialization */ private void deploySynapseService() throws AxisFault { log.info("Deploying the Synapse service..."); // Dynamically initialize the Synapse Service and deploy it into Axis2 AxisConfiguration axisCfg = configurationContext.getAxisConfiguration(); AxisService synapseService = new AxisService(SynapseConstants.SYNAPSE_SERVICE_NAME); AxisOperation mediateOperation = new InOutAxisOperation( SynapseConstants.SYNAPSE_OPERATION_NAME); mediateOperation.setMessageReceiver(new SynapseMessageReceiver()); synapseService.addOperation(mediateOperation); List<String> transports = new ArrayList<String>(); transports.add(Constants.TRANSPORT_HTTP); transports.add(Constants.TRANSPORT_HTTPS); synapseService.setExposedTransports(transports); AxisServiceGroup synapseServiceGroup = new AxisServiceGroup(axisCfg); synapseServiceGroup.setServiceGroupName(SynapseConstants.SYNAPSE_SERVICE_NAME); synapseServiceGroup.addParameter(SynapseConstants.HIDDEN_SERVICE_PARAM, "true"); synapseServiceGroup.addService(synapseService); axisCfg.addServiceGroup(synapseServiceGroup); }