public static void getAndSetOperation(SoapMessage message, String action) {
if (StringUtils.isEmpty(action)) {
return;
}
Exchange ex = message.getExchange();
Endpoint ep = ex.get(Endpoint.class);
if (ep == null) {
return;
}
BindingOperationInfo bindingOp = null;
Collection<BindingOperationInfo> bops = ep.getEndpointInfo()
.getBinding().getOperations();
if (bops != null) {
for (BindingOperationInfo boi : bops) {
if (isActionMatch(message, boi, action)) {
if (bindingOp != null) {
// more than one op with the same action, will need to parse normally
return;
}
bindingOp = boi;
}
Object o = boi.getOperationInfo().getInput().getExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME);
if (o == null) {
o = boi.getOperationInfo().getInput().getExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME);
}
if (o != null && action.equals(o.toString())) {
if (bindingOp != null && bindingOp != boi) {
//more than one op with the same action, will need to parse normally
return;
}
bindingOp = boi;
}
}
}
if (bindingOp == null) {
//we didn't match the an operation, we'll try again later to make
//sure the incoming message did end up matching an operation.
//This could occur in some cases like WS-RM and WS-SecConv that will
//intercept the message with a new endpoint/operation
message.getInterceptorChain().add(new SoapActionInAttemptTwoInterceptor());
return;
}
ex.put(BindingOperationInfo.class, bindingOp);
ex.put(OperationInfo.class, bindingOp.getOperationInfo());
}