Java源码示例:com.sun.xml.internal.ws.model.CheckedExceptionImpl

示例1
private static Object createDetailFromUserDefinedException(CheckedExceptionImpl ce, Object exception) {
    Class detailBean = ce.getDetailBean();
    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);
    }
}
 
示例2
private static Object createDetailFromUserDefinedException(CheckedExceptionImpl ce, Object exception) {
    Class detailBean = ce.getDetailBean();
    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);
    }
}
 
示例3
private static Object createDetailFromUserDefinedException(CheckedExceptionImpl ce, Object exception) {
    Class detailBean = ce.getDetailBean();
    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);
    }
}
 
示例4
private static Object createDetailFromUserDefinedException(CheckedExceptionImpl ce, Object exception) {
    Class detailBean = ce.getDetailBean();
    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);
    }
}
 
示例5
private static Object createDetailFromUserDefinedException(CheckedExceptionImpl ce, Object exception) {
    Class detailBean = ce.getDetailBean();
    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);
    }
}
 
示例6
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);
    }
}
 
示例7
private static Object createDetailFromUserDefinedException(CheckedExceptionImpl ce, Object exception) {
    Class detailBean = ce.getDetailBean();
    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);
    }
}
 
示例8
private static Object createDetailFromUserDefinedException(CheckedExceptionImpl ce, Object exception) {
    Class detailBean = ce.getDetailBean();
    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);
    }
}
 
示例9
/**
 * This should be called from the client side to throw an {@link Exception} for a given soap mesage
 */
public Throwable createException(Map<QName, CheckedExceptionImpl> exceptions) throws JAXBException {
    DetailType dt = getDetail();
    Node detail = null;
    if(dt != null)  detail = dt.getDetail(0);

    //return ProtocolException if the detail is not present or there is no checked exception
    if(detail == null || exceptions == null){
        // No soap detail, doesnt look like its a checked exception
        // throw a protocol exception
        return attachServerException(getProtocolException());
    }

    //check if the detail is a checked exception, if not throw a ProtocolException
    QName detailName = new QName(detail.getNamespaceURI(), detail.getLocalName());
    CheckedExceptionImpl ce = exceptions.get(detailName);
    if (ce == null) {
        //No Checked exception for the received detail QName, throw a SOAPFault exception
        return attachServerException(getProtocolException());

    }

    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return attachServerException(createUserDefinedException(ce));

    }
    Class exceptionClass = ce.getExceptionClass();
    try {
        Constructor constructor = exceptionClass.getConstructor(String.class, (Class) ce.getDetailType().type);
        Exception exception = (Exception) constructor.newInstance(getFaultString(), getJAXBObject(detail, ce));
        return attachServerException(exception);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
}
 
示例10
private static Object getFaultDetail(CheckedExceptionImpl ce, Throwable exception) {
    if (ce == null)
        return null;
    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return createDetailFromUserDefinedException(ce, exception);
    }
    try {
        Method m = exception.getClass().getMethod("getFaultInfo");
        return m.invoke(exception);
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}
 
示例11
/**
 * Generates the WSDL portType
 */
protected void generatePortType() {

    PortType portType = portDefinitions.portType().name(model.getPortTypeName().getLocalPart());
    extension.addPortTypeExtension(portType);
    for (JavaMethodImpl method : model.getJavaMethods()) {
        Operation operation = portType.operation().name(method.getOperationName());
        generateParameterOrder(operation, method);
        extension.addOperationExtension(operation, method);
        switch (method.getMEP()) {
            case REQUEST_RESPONSE:
                // input message
                generateInputMessage(operation, method);
                // output message
                generateOutputMessage(operation, method);
                break;
            case ONE_WAY:
                generateInputMessage(operation, method);
                break;
            default:
                break;
        }
        // faults
        for (CheckedExceptionImpl exception : method.getCheckedExceptions()) {
            QName messageName = new QName(model.getTargetNamespace(), exception.getMessageName());
            FaultType paramType = operation.fault().message(messageName).name(exception.getMessageName());
            extension.addOperationFaultExtension(paramType, method, exception);
        }
    }
}
 
示例12
private static final String getFaultAction(JavaMethod method,
                                           CheckedException ce) {
    String faultaction = ((CheckedExceptionImpl)ce).getFaultAction();
    if (faultaction.equals("")) {
        faultaction = getDefaultFaultAction(method,ce);
    }
    return faultaction;
}
 
示例13
/**
 * This should be called from the client side to throw an {@link Exception} for a given soap mesage
 */
public Throwable createException(Map<QName, CheckedExceptionImpl> exceptions) throws JAXBException {
    DetailType dt = getDetail();
    Node detail = null;
    if(dt != null)  detail = dt.getDetail(0);

    //return ProtocolException if the detail is not present or there is no checked exception
    if(detail == null || exceptions == null){
        // No soap detail, doesnt look like its a checked exception
        // throw a protocol exception
        return attachServerException(getProtocolException());
    }

    //check if the detail is a checked exception, if not throw a ProtocolException
    QName detailName = new QName(detail.getNamespaceURI(), detail.getLocalName());
    CheckedExceptionImpl ce = exceptions.get(detailName);
    if (ce == null) {
        //No Checked exception for the received detail QName, throw a SOAPFault exception
        return attachServerException(getProtocolException());

    }

    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return attachServerException(createUserDefinedException(ce));

    }
    Class exceptionClass = ce.getExceptionClass();
    try {
        Constructor constructor = exceptionClass.getConstructor(String.class, (Class) ce.getDetailType().type);
        Exception exception = (Exception) constructor.newInstance(getFaultString(), getJAXBObject(detail, ce));
        return attachServerException(exception);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
}
 
示例14
/**
 * This should be called from the client side to throw an {@link Exception} for a given soap mesage
 */
public Throwable createException(Map<QName, CheckedExceptionImpl> exceptions) throws JAXBException {
    DetailType dt = getDetail();
    Node detail = null;
    if(dt != null)  detail = dt.getDetail(0);

    //return ProtocolException if the detail is not present or there is no checked exception
    if(detail == null || exceptions == null){
        // No soap detail, doesnt look like its a checked exception
        // throw a protocol exception
        return attachServerException(getProtocolException());
    }

    //check if the detail is a checked exception, if not throw a ProtocolException
    QName detailName = new QName(detail.getNamespaceURI(), detail.getLocalName());
    CheckedExceptionImpl ce = exceptions.get(detailName);
    if (ce == null) {
        //No Checked exception for the received detail QName, throw a SOAPFault exception
        return attachServerException(getProtocolException());

    }

    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return attachServerException(createUserDefinedException(ce));

    }
    Class exceptionClass = ce.getExceptionClass();
    try {
        Constructor constructor = exceptionClass.getConstructor(String.class, (Class) ce.getDetailType().type);
        Exception exception = (Exception) constructor.newInstance(getFaultString(), getJAXBObject(detail, ce));
        return attachServerException(exception);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
}
 
示例15
private static Object getFaultDetail(CheckedExceptionImpl ce, Throwable exception) {
    if (ce == null)
        return null;
    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return createDetailFromUserDefinedException(ce, exception);
    }
    try {
        Method m = exception.getClass().getMethod("getFaultInfo");
        return m.invoke(exception);
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}
 
示例16
/**
 * Generates the WSDL portType
 */
protected void generatePortType() {

    PortType portType = portDefinitions.portType().name(model.getPortTypeName().getLocalPart());
    extension.addPortTypeExtension(portType);
    for (JavaMethodImpl method : model.getJavaMethods()) {
        Operation operation = portType.operation().name(method.getOperationName());
        generateParameterOrder(operation, method);
        extension.addOperationExtension(operation, method);
        switch (method.getMEP()) {
            case REQUEST_RESPONSE:
                // input message
                generateInputMessage(operation, method);
                // output message
                generateOutputMessage(operation, method);
                break;
            case ONE_WAY:
                generateInputMessage(operation, method);
                break;
            default:
                break;
        }
        // faults
        for (CheckedExceptionImpl exception : method.getCheckedExceptions()) {
            QName messageName = new QName(model.getTargetNamespace(), exception.getMessageName());
            FaultType paramType = operation.fault().message(messageName).name(exception.getMessageName());
            extension.addOperationFaultExtension(paramType, method, exception);
        }
    }
}
 
示例17
private static final String getFaultAction(JavaMethod method,
                                           CheckedException ce) {
    String faultaction = ((CheckedExceptionImpl)ce).getFaultAction();
    if (faultaction.equals("")) {
        faultaction = getDefaultFaultAction(method,ce);
    }
    return faultaction;
}
 
示例18
private static final String getFaultAction(JavaMethod method,
                                           CheckedException ce) {
    String faultaction = ((CheckedExceptionImpl)ce).getFaultAction();
    if (faultaction.equals("")) {
        faultaction = getDefaultFaultAction(method,ce);
    }
    return faultaction;
}
 
示例19
/**
 * Create the Message with the specified faultCode
 *
 * @see #createSOAPFaultMessage(SOAPVersion, CheckedExceptionImpl, Throwable)
 */
public static Message createSOAPFaultMessage(SOAPVersion soapVersion, CheckedExceptionImpl ceModel, Throwable ex, QName faultCode) {
    Object detail = getFaultDetail(ceModel, ex);
    if(soapVersion == SOAPVersion.SOAP_12)
        return createSOAP12Fault(soapVersion, ex, detail, ceModel, faultCode);
    return createSOAP11Fault(soapVersion, ex, detail, ceModel, faultCode);
}
 
示例20
private static Object getFaultDetail(CheckedExceptionImpl ce, Throwable exception) {
    if (ce == null)
        return null;
    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return createDetailFromUserDefinedException(ce, exception);
    }
    try {
        Method m = exception.getClass().getMethod("getFaultInfo");
        return m.invoke(exception);
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}
 
示例21
/**
 * Generates the WSDL portType
 */
protected void generatePortType() {

    PortType portType = portDefinitions.portType().name(model.getPortTypeName().getLocalPart());
    extension.addPortTypeExtension(portType);
    for (JavaMethodImpl method : model.getJavaMethods()) {
        Operation operation = portType.operation().name(method.getOperationName());
        generateParameterOrder(operation, method);
        extension.addOperationExtension(operation, method);
        switch (method.getMEP()) {
            case REQUEST_RESPONSE:
                // input message
                generateInputMessage(operation, method);
                // output message
                generateOutputMessage(operation, method);
                break;
            case ONE_WAY:
                generateInputMessage(operation, method);
                break;
            default:
                break;
        }
        // faults
        for (CheckedExceptionImpl exception : method.getCheckedExceptions()) {
            QName messageName = new QName(model.getTargetNamespace(), exception.getMessageName());
            FaultType paramType = operation.fault().message(messageName).name(exception.getMessageName());
            extension.addOperationFaultExtension(paramType, method, exception);
        }
    }
}
 
示例22
private static final String getFaultAction(JavaMethod method,
                                           CheckedException ce) {
    String faultaction = ((CheckedExceptionImpl)ce).getFaultAction();
    if (faultaction.equals("")) {
        faultaction = getDefaultFaultAction(method,ce);
    }
    return faultaction;
}
 
示例23
/**
 * This should be called from the client side to throw an {@link Exception} for a given soap mesage
 */
public Throwable createException(Map<QName, CheckedExceptionImpl> exceptions) throws JAXBException {
    DetailType dt = getDetail();
    Node detail = null;
    if(dt != null)  detail = dt.getDetail(0);

    //return ProtocolException if the detail is not present or there is no checked exception
    if(detail == null || exceptions == null){
        // No soap detail, doesnt look like its a checked exception
        // throw a protocol exception
        return attachServerException(getProtocolException());
    }

    //check if the detail is a checked exception, if not throw a ProtocolException
    QName detailName = new QName(detail.getNamespaceURI(), detail.getLocalName());
    CheckedExceptionImpl ce = exceptions.get(detailName);
    if (ce == null) {
        //No Checked exception for the received detail QName, throw a SOAPFault exception
        return attachServerException(getProtocolException());

    }

    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return attachServerException(createUserDefinedException(ce));

    }
    Class exceptionClass = ce.getExceptionClass();
    try {
        Constructor constructor = exceptionClass.getConstructor(String.class, (Class) ce.getDetailType().type);
        Exception exception = (Exception) constructor.newInstance(getFaultString(), getJAXBObject(detail, ce));
        return attachServerException(exception);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
}
 
示例24
/**
 * Create the Message with the specified faultCode
 *
 * @see #createSOAPFaultMessage(SOAPVersion, CheckedExceptionImpl, Throwable)
 */
public static Message createSOAPFaultMessage(SOAPVersion soapVersion, CheckedExceptionImpl ceModel, Throwable ex, QName faultCode) {
    Object detail = getFaultDetail(ceModel, ex);
    if(soapVersion == SOAPVersion.SOAP_12)
        return createSOAP12Fault(soapVersion, ex, detail, ceModel, faultCode);
    return createSOAP11Fault(soapVersion, ex, detail, ceModel, faultCode);
}
 
示例25
private static Object getFaultDetail(CheckedExceptionImpl ce, Throwable exception) {
    if (ce == null)
        return null;
    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return createDetailFromUserDefinedException(ce, exception);
    }
    try {
        Method m = exception.getClass().getMethod("getFaultInfo");
        return m.invoke(exception);
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}
 
示例26
/**
 * Generates the WSDL portType
 */
protected void generatePortType() {

    PortType portType = portDefinitions.portType().name(model.getPortTypeName().getLocalPart());
    extension.addPortTypeExtension(portType);
    for (JavaMethodImpl method : model.getJavaMethods()) {
        Operation operation = portType.operation().name(method.getOperationName());
        generateParameterOrder(operation, method);
        extension.addOperationExtension(operation, method);
        switch (method.getMEP()) {
            case REQUEST_RESPONSE:
                // input message
                generateInputMessage(operation, method);
                // output message
                generateOutputMessage(operation, method);
                break;
            case ONE_WAY:
                generateInputMessage(operation, method);
                break;
            default:
                break;
        }
        // faults
        for (CheckedExceptionImpl exception : method.getCheckedExceptions()) {
            QName messageName = new QName(model.getTargetNamespace(), exception.getMessageName());
            FaultType paramType = operation.fault().message(messageName).name(exception.getMessageName());
            extension.addOperationFaultExtension(paramType, method, exception);
        }
    }
}
 
示例27
private static final String getFaultAction(JavaMethod method,
                                           CheckedException ce) {
    String faultaction = ((CheckedExceptionImpl)ce).getFaultAction();
    if (faultaction.equals("")) {
        faultaction = getDefaultFaultAction(method,ce);
    }
    return faultaction;
}
 
示例28
/**
 * This should be called from the client side to throw an {@link Exception} for a given soap mesage
 */
public Throwable createException(Map<QName, CheckedExceptionImpl> exceptions) throws JAXBException {
    DetailType dt = getDetail();
    Node detail = null;
    if(dt != null)  detail = dt.getDetail(0);

    //return ProtocolException if the detail is not present or there is no checked exception
    if(detail == null || exceptions == null){
        // No soap detail, doesnt look like its a checked exception
        // throw a protocol exception
        return attachServerException(getProtocolException());
    }

    //check if the detail is a checked exception, if not throw a ProtocolException
    QName detailName = new QName(detail.getNamespaceURI(), detail.getLocalName());
    CheckedExceptionImpl ce = exceptions.get(detailName);
    if (ce == null) {
        //No Checked exception for the received detail QName, throw a SOAPFault exception
        return attachServerException(getProtocolException());

    }

    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return attachServerException(createUserDefinedException(ce));

    }
    Class exceptionClass = ce.getExceptionClass();
    try {
        Constructor constructor = exceptionClass.getConstructor(String.class, (Class) ce.getDetailType().type);
        Exception exception = (Exception) constructor.newInstance(getFaultString(), getJAXBObject(detail, ce));
        return attachServerException(exception);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
}
 
示例29
/**
 * Create the Message with the specified faultCode
 *
 * @see #createSOAPFaultMessage(SOAPVersion, CheckedExceptionImpl, Throwable)
 */
public static Message createSOAPFaultMessage(SOAPVersion soapVersion, CheckedExceptionImpl ceModel, Throwable ex, QName faultCode) {
    Object detail = getFaultDetail(ceModel, ex);
    if(soapVersion == SOAPVersion.SOAP_12)
        return createSOAP12Fault(soapVersion, ex, detail, ceModel, faultCode);
    return createSOAP11Fault(soapVersion, ex, detail, ceModel, faultCode);
}
 
示例30
private static Object getFaultDetail(CheckedExceptionImpl ce, Throwable exception) {
    if (ce == null)
        return null;
    if (ce.getExceptionType().equals(ExceptionType.UserDefined)) {
        return createDetailFromUserDefinedException(ce, exception);
    }
    try {
        return ce.getFaultInfoGetter().invoke(exception);
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}