How to get JAX-WS Web Service Method Name

I'm not sure if this will always work, but here is some sample code that I put into a Handler to log the web service method name that is being called. I wanted to be able to track each method, and see which ones were getting use.

This web service was running on IBM WebSphere 6.1.

public boolean handleMessage(LogicalMessageContext context) {
	String webMethodOperationName = null;
	try {
		Field mepCtxField = context.getMessage().getClass().getDeclaredField("mepCtx");
		Object mepCtx = mepCtxField.get(context.getMessage());
		Field requestMCField = mepCtx.getClass().getDeclaredField("requestMC");
		Object requestMC = requestMCField.get(mepCtx);
		Field operationDescField = requestMC.getClass().getDeclaredField("operationDesc");
		Object operationDesc = operationDescField.get(requestMC);
		Field webMethodOperationNameField = operationDesc.getClass().getDeclaredField("webMethodOperationName");
		webMethodOperationName = (String) webMethodOperationNameField.get(operationDesc);
	catch (Exception e) {
		log.warn("Cannot find method name of operation.");
	return true;

Leave a Reply