Hi tiago
You may want to create a override, call customClass in axis2:
public class ConvertDateWithoutTimeZone extends ConverterUtil {
public static String convertToString(java.util.Date value) {
/*
* Since SimpleDateFormat is not thread-safe. We have to create a new
* instance every time we need to format a Date.
*/
return new SimpleDateFormat("yyyy-MM-dd").format(value);
}
}
1st approach
You may want to package your class into a JAR file, put it in the ${ivy.engine}/webapps/ivy/WEB-INF/ and follow the way to set the system property as described in http://stackoverflow.com/a/5484319/495558. The ConverterUtil calls Class.forName to instantiate your class at runtime but it may not work because your class is usually loaded by PMV ClassLoader. So putting the custom converter class in the webapps/WEB-INF enables it to be loaded.
2nd approach
Long time ago, our project also have a similar issue when we want to control the format of Date generating by axis2. After creating the custom class, before each WebService step, we invoke:
java.lang.reflect.Field isCustomClassPresentField = org.apache.axis2.databinding.utils.ConverterUtil.class
.getDeclaredField("isCustomClassPresent");
isCustomClassPresentField.setAccessible(true);
isCustomClassPresentField.setBoolean(null, true);
isCustomClassPresentField.setAccessible(false);
java.lang.reflect.Field customClassField = org.apache.axis2.databinding.utils.ConverterUtil.class
.getDeclaredField("customClass");
customClassField.setAccessible(true);
customClassField.set(null, ConvertDateWithoutTimeZone.class);
customClassField.setAccessible(false);
The idea is to replace the field isCustomClassPresent and the customClass using Reflection instead of using system property approach.
answered
30.08.2016 at 02:27
Genzer Hawker
(suspended)
accept rate:
66%
By now the only way i found to remove the timezone data was to modify the generated code. I also tried this solutions http://stackoverflow.com/a/6322336/1055375, http://stackoverflow.com/a/5484319/1055375 but it didnt worked for me