当前位置: 首页>>代码示例>>Java>>正文


Java Fault.getCause方法代码示例

本文整理汇总了Java中org.apache.cxf.interceptor.Fault.getCause方法的典型用法代码示例。如果您正苦于以下问题:Java Fault.getCause方法的具体用法?Java Fault.getCause怎么用?Java Fault.getCause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cxf.interceptor.Fault的用法示例。


在下文中一共展示了Fault.getCause方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleMessage

import org.apache.cxf.interceptor.Fault; //导入方法依赖的package包/类
@Override
public void handleMessage(SoapMessage message) throws Fault {
    Fault fault = (Fault) message.getContent(Exception.class);
    LOG.warn("Error: " + fault, fault);

    if (fault.getCause() instanceof SonosSoapFault) {
        SonosSoapFault cause = (SonosSoapFault) fault.getCause();
        fault.setFaultCode(new QName(cause.getFaultCode()));
        fault.setMessage(cause.getFaultCode());

        Document document = DOMUtils.createDocument();
        Element details = document.createElement("detail");
        fault.setDetail(details);

        details.appendChild(document.createElement("ExceptionInfo"));

        Element sonosError = document.createElement("SonosError");
        sonosError.setTextContent(String.valueOf(cause.getSonosError()));
        details.appendChild(sonosError);
    }
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:22,代码来源:SonosFaultInterceptor.java

示例2: handleMessage

import org.apache.cxf.interceptor.Fault; //导入方法依赖的package包/类
@Override
public void handleMessage(final SoapMessage message) throws Fault {
    final Fault fault = (Fault) message.getContent(Exception.class);
    // Only change the fault code if it was not generated by Cyclos
    if (!WebServiceHelper.isFromCyclos(fault)) {
        final Throwable exception = fault.getCause() == null ? fault : fault.getCause();
        final SoapFault soapFault = WebServiceHelper.fault(exception);
        fault.setDetail(null);
        fault.setFaultCode(soapFault.getFaultCode());
        fault.setMessage(message(exception));
    }
    // there are cases where this interceptor is invoked but the context wasn't initialized
    // (e.g.: there is a unmarshalling error when CXF is trying to convert the request parameters)
    //
    if (WebServiceContext.isInitialized()) {
        final HttpServletRequest request = WebServiceContext.getRequest();
        request.setAttribute("soapFault", fault);
    }
    webServiceHelper.error(fault);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:21,代码来源:CustomFaultInterceptor.java

示例3: handleMessage

import org.apache.cxf.interceptor.Fault; //导入方法依赖的package包/类
@Override
public void handleMessage(SoapMessage soapMessage) throws Fault {
    Fault fault = (Fault) soapMessage.getContent(Exception.class);
    Throwable faultCause = fault.getCause();
    String faultMessage = fault.getMessage();

    if (containsFaultIndicatingNotSchemeCompliantXml(faultCause, faultMessage)) { 
    	LOG.schemaValidationError(FaultConst.SCHEME_VALIDATION_ERROR, faultMessage);
    	WeatherSoapFaultHelper.buildWeatherFaultAndSet2SoapMessage(soapMessage, FaultConst.SCHEME_VALIDATION_ERROR);
    } else if (containsFaultIndicatingSyntacticallyIncorrectXml(faultCause)) {
    	LOG.schemaValidationError(FaultConst.SYNTACTICALLY_INCORRECT_XML_ERROR, faultMessage);
    	WeatherSoapFaultHelper.buildWeatherFaultAndSet2SoapMessage(soapMessage, FaultConst.SYNTACTICALLY_INCORRECT_XML_ERROR);	        
    }
}
 
开发者ID:jonashackt,项目名称:tutorial-soap-spring-boot-cxf,代码行数:15,代码来源:CustomSoapFaultInterceptor.java

示例4: handleMessage

import org.apache.cxf.interceptor.Fault; //导入方法依赖的package包/类
public void handleMessage( Message message ) throws Fault
{
    Fault fault = (Fault) message.getContent( Exception.class );
    Throwable ex = fault.getCause();
    
    if ( !(ex instanceof SecurityException) )
    {
        throw new RuntimeException( "Security Exception is expected:" + ex );
    }

    HttpServletResponse response = (HttpServletResponse) message.getExchange().getInMessage()
        .get( AbstractHTTPDestination.HTTP_RESPONSE );
    int status = ex instanceof AccessDeniedException ? 403 : 401;
    response.setStatus( status );
    
    try
    {
        response.getOutputStream().write( ex.getMessage().getBytes() );
        response.getOutputStream().flush();
    }
    catch ( IOException iex )
    {
        // ignore
    }

    message.getInterceptorChain().abort();
}
 
开发者ID:apache,项目名称:directory-fortress-enmasse,代码行数:28,代码来源:SecurityOutFaultInterceptor.java

示例5: handleMessage

import org.apache.cxf.interceptor.Fault; //导入方法依赖的package包/类
@Override
public void handleMessage(SoapMessage msg) throws Fault {
    // noinspection ThrowableResultOfMethodCallIgnored
    Fault fault = ((Fault) msg.getContent(Exception.class));
    Throwable faultCause;

    if (((faultCause = fault.getCause()) == null) || !MessageUtils.getContextualBoolean(msg, WsPropertyNames.ERROR_STACK_TRACE, false)) {
        return;
    }

    Element faultDetailElem = fault.getOrCreateDetail();
    Document faultDetailDoc = faultDetailElem.getOwnerDocument();
    // noinspection ThrowableResultOfMethodCallIgnored
    ValidationException faultValidationCause = SdcctExceptionUtils.findCause(faultCause, ValidationException.class);

    if (faultValidationCause != null) {
        try {
            this.xmlCodec.encode(faultValidationCause.getResult(), new DOMResult(faultDetailElem), null);
        } catch (Exception e) {
            LOGGER.error("Unable to build SOAP Fault Detail validation result child element.", e);
        }
    }

    Element faultDetailStacktraceElem =
        faultDetailDoc.createElementNS(SdcctUris.SDCCT_WS_URN_VALUE, SdcctQnameUtils.buildQualifiedName(WsXmlQnames.STACK_TRACE));
    faultDetailStacktraceElem
        .appendChild(faultDetailDoc.createCDATASection((StringUtils.LF + SdcctExceptionUtils.buildRootCauseStackTrace(faultCause) + StringUtils.LF)));
    faultDetailElem.appendChild(faultDetailStacktraceElem);
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:30,代码来源:RfdSoapFaultInterceptor.java


注:本文中的org.apache.cxf.interceptor.Fault.getCause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。