I have a following interceptor to log the requested Operation name.
public class ServiceLogPreInterceptor extends AbstractSoapInterceptor {
public static Logger logger = LoggerFactory
.getLogger(ServiceLogPreInterceptor.class);
public ServiceLogPreInterceptor() {
super(Phase.READ);
addAfter(StartBodyInterceptor.class.getName());
addAfter(ReadHeadersInterceptor.class.getName());
addAfter(EndpointSelectionInterceptor.class.getName());
}
@Override
public void handleMessage(SoapMessage message) throws Fault {
// I need Requested Operation name here!!
String opName = getOperationName(message);
logger.debug(opName);
}
private String getOperationName(String msg) {
return "??????";
}
}
Here is my interceptor chain
ServiceLogPreInterceptor(READ) -> AuthenticationInterceptor(SAAJInterceptor) --> authorizationInterceptor(PRE_INVOKE) --> and actual method call
bindingoperationinfos is available in my authorizationInterceptor however
There is no bindingoperationinfos available in my ServiceLogPreInterceptor and i don't know how to extract a operation name out of SoapMessage in a sensible way :).
I solved the problem. here is my solution.
public BindingOperationInfo extractBindingOperationInfo(Message message) {
DepthXMLStreamReader xmlReader = getXMLStreamReader(message);
DataReader<XMLStreamReader> dr = getDataReader(message);
boolean client = isRequestor(message);
Exchange exchange = message.getExchange();
BindingOperationInfo bop = null;
Service service = ServiceModelUtil.getService(message.getExchange());
try {
Endpoint ep = exchange.get(Endpoint.class);
ServiceInfo si = ep.getEndpointInfo().getService();
Collection<OperationInfo> operations = null;
operations = new ArrayList<OperationInfo>();
operations.addAll(si.getInterface().getOperations());
if (xmlReader == null || !StaxUtils.toNextElement(xmlReader)) {
// empty input
bop = getBindingOperationForEmptyBody(operations, ep, exchange);
return bop;
}
setDataReaderValidation(service, message, dr);
QName elName = xmlReader.getName();
bop = findMessagePart(exchange, operations, elName, client,
message);
} catch (Fault f) {
if (!isRequestor(message)) {
f.setFaultCode(Fault.FAULT_CODE_CLIENT);
}
throw f;
}
return bop;
}
and then extract the method from bindigOperationInfo.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.