Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ public InvocationResponse invoke(MessageContext msgctx) throws AxisFault {
}
}
}
// A RelatesTo that correlates to no operation context, such as a reply or
// fault sent on to a ReplyTo or FaultTo, still binds the service from the To
// here. Left unbound, the Dispatch phase binds it from that same To after the
// Security phase has run without it.
if (msgctx.getOperationContext() == null) {
response = super.invoke(msgctx);
}
}
//Else we will try to dispatch based on the WS-A Action
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
import junit.framework.TestCase;

import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.addressing.RelatesTo;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisService;

public class AddressingBasedDispatcherTest extends TestCase {

Expand All @@ -39,4 +44,23 @@ public void testValidateActionFlag() throws Exception {
AddressingBasedDispatcher dispatcher = new AddressingBasedDispatcher();
dispatcher.invoke(mc);
}

/**
* A RelatesTo that correlates to no operation context must not stop the service
* being bound from the To here, in the Addressing phase. Otherwise the Dispatch
* phase binds it from the same To after the Security phase has run with no
* service, and that service's security handlers never see the message.
*/
public void testUncorrelatedRelatesToStillDispatchesOnTo() throws Exception {
ConfigurationContext cc = ConfigurationContextFactory.createEmptyConfigurationContext();
cc.getAxisConfiguration().addService(new AxisService("Service1"));
MessageContext mc = cc.createMessageContext();
mc.setTo(new EndpointReference("http://127.0.0.1:8080/axis2/services/Service1"));
mc.addRelatesTo(new RelatesTo("urn:uuid:no-such-operation-context"));

new AddressingBasedDispatcher().invoke(mc);

assertNotNull("the service must be bound from the To", mc.getAxisService());
assertEquals("Service1", mc.getAxisService().getName());
}
}