org.apache.axis2.context.MessageContext axis2MsgCtx =
((Axis2MessageContext) synCtx).getAxis2MessageContext();
String transport = axis2MsgCtx.getTransportIn().getName();
algorithm.setApplicationMembers(activeMembers);
Member currentMember = algorithm.getNextApplicationMember(algorithmContext);
faultHandler.setCurrentMember(currentMember);
if (currentMember != null) {
// URL rewrite
if (transport.equals("http") || transport.equals("https")) {
String address = to.getAddress();
if (address.indexOf(":") != -1) {
try {
address = new URL(address).getPath();
} catch (MalformedURLException e) {
String msg = "URL " + address + " is malformed";
log.error(msg, e);
throw new SynapseException(msg, e);
}
}
EndpointReference epr =
new EndpointReference(transport + "://" + currentMember.getHostName()
+ ":" + ("http".equals(transport) ? currentMember.getHttpPort() :
currentMember.getHttpsPort()) + address);
synCtx.setTo(epr);
if (failover) {
synCtx.getEnvelope().build();
}