class SoapMethodArgumentResolver implements MethodArgumentResolver {

	@Override
	public Object resolveArgument(MessageContext messageContext, MethodParameter parameter) {
		Assert.isInstanceOf(SoapMessage.class, messageContext.getRequest());
		SoapMessage request = (SoapMessage) messageContext.getRequest();

		Class<?> parameterType = parameter.getParameterType();

		if (SoapMessage.class.equals(parameterType)) {
			return request;
		} else if (SoapBody.class.equals(parameterType)) {
			return request.getSoapBody();
		} else if (SoapEnvelope.class.equals(parameterType)) {
			return request.getEnvelope();
		} else if (SoapHeader.class.equals(parameterType)) {
			return request.getSoapHeader();
		}
		// should not happen
		throw new UnsupportedOperationException();
	}

}