Search in sources :

Example 1 with SerializationException

use of com.sun.xml.ws.encoding.soap.SerializationException in project metro-jax-ws by eclipse-ee4j.

the class SOAPFaultBuilder method createDetailFromUserDefinedException.

private static Object createDetailFromUserDefinedException(CheckedExceptionImpl ce, Object exception) {
    Class detailBean = ce.getDetailBean();
    if (ce.getExceptionClass().equals(detailBean))
        return exception;
    Field[] fields = detailBean.getDeclaredFields();
    try {
        Object detail = detailBean.newInstance();
        for (Field f : fields) {
            Method em = exception.getClass().getMethod(getReadMethod(f));
            try {
                Method sm = detailBean.getMethod(getWriteMethod(f), em.getReturnType());
                sm.invoke(detail, em.invoke(exception));
            } catch (NoSuchMethodException ne) {
                // Try to use exception bean's public field to populate the value.
                Field sf = detailBean.getField(f.getName());
                sf.set(detail, em.invoke(exception));
            }
        }
        return detail;
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}
Also used : Field(java.lang.reflect.Field) SerializationException(com.sun.xml.ws.encoding.soap.SerializationException) Method(java.lang.reflect.Method) ProtocolException(jakarta.xml.ws.ProtocolException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) WebServiceException(jakarta.xml.ws.WebServiceException) SerializationException(com.sun.xml.ws.encoding.soap.SerializationException) JAXBException(jakarta.xml.bind.JAXBException)

Aggregations

SerializationException (com.sun.xml.ws.encoding.soap.SerializationException)1 JAXBException (jakarta.xml.bind.JAXBException)1 ProtocolException (jakarta.xml.ws.ProtocolException)1 WebServiceException (jakarta.xml.ws.WebServiceException)1 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1