class MarshallingUtils {

	public static Object unmarshal(Unmarshaller unmarshaller, WebServiceMessage message) throws IOException {
		Source payload = message.getPayloadSource();
		if (payload == null) {
			return null;
		} else if (unmarshaller instanceof MimeUnmarshaller && message instanceof MimeMessage) {
			MimeUnmarshaller mimeUnmarshaller = (MimeUnmarshaller) unmarshaller;
			MimeMessageContainer container = new MimeMessageContainer((MimeMessage) message);
			return mimeUnmarshaller.unmarshal(payload, container);
		} else {
			return unmarshaller.unmarshal(payload);
		}
	}

	private  MarshallingUtils();

}