use of org.apache.axis2.addressing.EndpointReference in project wso2-synapse by wso2.
the class WSDLEndpoint method onFault.
public void onFault(MessageContext synCtx) {
boolean isRecursive = getParentEndpoint() instanceof FailoverEndpoint || getParentEndpoint() instanceof LoadbalanceEndpoint;
// For setting Car name (still for Proxy)
logSetter();
if (synCtx.getProperty(EPConstants.TENANT_INFO_ID) != null && ((int) synCtx.getProperty(EPConstants.TENANT_INFO_ID)) != EPConstants.SUPER_TENANT_ID) {
org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
Options options = axis2MessageContext.getOptions();
EndpointReference to = options.getTo();
if (to.getAddress() != null && to.getAddress().contains(EPConstants.LOCAL_TRANSPORT_IDENTIFIER)) {
// removing the local transport identifier from the uri scheme
options.setTo(new EndpointReference(to.getAddress().substring(EPConstants.LOCAL_TRANSPORT_IDENTIFIER.length())));
}
}
// is this an actual leaf endpoint
if (getParentEndpoint() != null) {
if (getContext().isMaxRetryLimitReached(isRecursive)) {
getContext().onFailoverRetryLimit(isRecursive);
} else {
// is this really a fault or a timeout/connection close etc?
if (isTimeout(synCtx)) {
getContext().onTimeout();
} else if (isSuspendFault(synCtx)) {
getContext().onFault();
}
}
}
setErrorOnMessage(synCtx, null, null);
super.onFault(synCtx);
}
use of org.apache.axis2.addressing.EndpointReference in project wso2-synapse by wso2.
the class DynamicLoadbalanceEndpoint method sendToApplicationMember.
protected void sendToApplicationMember(MessageContext synCtx, Member currentMember, DynamicLoadbalanceFaultHandler faultHandler, boolean newSession) {
// Rewriting the URL
org.apache.axis2.context.MessageContext axis2MsgCtx = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
// Removing the REST_URL_POSTFIX - this is a hack.
// In this loadbalance endpoint we create an endpoint per request by setting the complete url as the adress.
// If a REST message comes Axis2FlexibleMEPClient append the REST_URL_POSTFIX to the adress. Hence endpoint fails
// do send the request. e.g. http://localhost:8080/example/index.html/example/index.html
axis2MsgCtx.removeProperty(NhttpConstants.REST_URL_POSTFIX);
String transport = axis2MsgCtx.getTransportIn().getName();
String address = synCtx.getTo().getAddress();
int incomingPort = extractPort(synCtx, transport);
EndpointReference to = getEndpointReferenceAfterURLRewrite(currentMember, transport, address, incomingPort);
synCtx.setTo(to);
faultHandler.setTo(to);
faultHandler.setCurrentMember(currentMember);
synCtx.pushFaultHandler(faultHandler);
if (isFailover()) {
synCtx.getEnvelope().build();
}
Endpoint endpoint = getEndpoint(to, currentMember, synCtx);
faultHandler.setCurrentEp(endpoint);
if (isSessionAffinityBasedLB()) {
synCtx.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_DEFAULT_SESSION_TIMEOUT, getSessionTimeout());
synCtx.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_CURRENT_DISPATCHER, dispatcher);
prepareEndPointSequence(synCtx, endpoint);
if (newSession) {
synCtx.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_CURRENT_MEMBER, currentMember);
// we should also indicate that this is the first message in the session. so that
// onFault(...) method can resend only the failed attempts for the first message.
synCtx.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_FIRST_MESSAGE_IN_SESSION, Boolean.TRUE);
}
}
Map<String, String> memberHosts;
if ((memberHosts = (Map<String, String>) currentMember.getProperties().get(HttpSessionDispatcher.HOSTS)) == null) {
currentMember.getProperties().put(HttpSessionDispatcher.HOSTS, memberHosts = new HashMap<String, String>());
}
memberHosts.put(extractHost(synCtx), "true");
setupTransportHeaders(synCtx);
try {
endpoint.send(synCtx);
} catch (Exception e) {
if (e.getMessage().toLowerCase().contains("io reactor shutdown")) {
log.fatal("System cannot continue normal operation. Restarting", e);
// restart
System.exit(121);
} else {
throw new SynapseException(e);
}
}
}
use of org.apache.axis2.addressing.EndpointReference in project wso2-synapse by wso2.
the class URLRewriteMediatorTest method testUnconditionalRewriteScenario3.
public void testUnconditionalRewriteScenario3() throws Exception {
URLRewriteMediator mediator = new URLRewriteMediator();
mediator.setOutputProperty("outURL");
RewriteAction action1 = new RewriteAction();
action1.setValue(targetURL);
RewriteRule rule1 = new RewriteRule();
rule1.addRewriteAction(action1);
mediator.addRule(rule1);
RewriteAction action2 = new RewriteAction();
action2.setValue("/services/SimpleStockQuoteService");
action2.setFragmentIndex(URIFragments.PATH);
RewriteAction action3 = new RewriteAction();
action3.setXpath(new SynapseXPath("get-property('port')"));
action3.setFragmentIndex(URIFragments.PORT);
RewriteRule rule2 = new RewriteRule();
rule2.addRewriteAction(action2);
rule2.addRewriteAction(action3);
mediator.addRule(rule2);
MessageContext msgCtx = TestUtils.createLightweightSynapseMessageContext("<empty/>");
msgCtx.setTo(new EndpointReference("http://localhost:8280"));
msgCtx.setProperty("port", 9000);
mediator.mediate(msgCtx);
assertEquals(targetURL, msgCtx.getProperty("outURL"));
}
use of org.apache.axis2.addressing.EndpointReference in project wso2-synapse by wso2.
the class URLRewriteMediatorTest method testConditionalRewriteScenario4.
public void testConditionalRewriteScenario4() throws Exception {
URLRewriteMediator mediator = new URLRewriteMediator();
mediator.setOutputProperty("outURL");
RewriteAction action1 = new RewriteAction();
action1.setRegex("MyService");
action1.setValue("SimpleStockQuoteService");
action1.setFragmentIndex(URIFragments.PATH);
action1.setActionType(RewriteAction.ACTION_REPLACE);
RewriteRule rule1 = new RewriteRule();
rule1.addRewriteAction(action1);
EqualEvaluator eval1 = new EqualEvaluator();
SOAPEnvelopeTextRetriever txtRtvr1 = new SOAPEnvelopeTextRetriever("//symbol");
eval1.setTextRetriever(txtRtvr1);
eval1.setValue("IBM");
rule1.setCondition(eval1);
mediator.addRule(rule1);
MessageContext msgCtx = TestUtils.createLightweightSynapseMessageContext("<getQuote><symbol>IBM</symbol></getQuote>");
msgCtx.setTo(new EndpointReference("http://localhost:9000/services/MyService"));
mediator.mediate(msgCtx);
assertEquals(targetURL, msgCtx.getProperty("outURL"));
}
use of org.apache.axis2.addressing.EndpointReference in project wso2-synapse by wso2.
the class URLRewriteMediatorTest method testConditionalRewriteScenario1.
public void testConditionalRewriteScenario1() throws Exception {
URLRewriteMediator mediator = new URLRewriteMediator();
RewriteAction action = new RewriteAction();
action.setValue(targetURL);
RewriteRule rule = new RewriteRule();
EqualEvaluator eval = new EqualEvaluator();
URLTextRetriever txtRtvr = new URLTextRetriever();
txtRtvr.setSource(EvaluatorConstants.URI_FRAGMENTS.port.name());
eval.setTextRetriever(txtRtvr);
eval.setValue("8280");
rule.setCondition(eval);
rule.addRewriteAction(action);
mediator.addRule(rule);
MessageContext msgCtx = TestUtils.createLightweightSynapseMessageContext("<empty/>");
msgCtx.setTo(new EndpointReference("http://localhost:8280"));
mediator.mediate(msgCtx);
assertEquals(targetURL, msgCtx.getTo().getAddress());
}
Aggregations