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


Java Fault.setMessage方法代码示例

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


在下文中一共展示了Fault.setMessage方法的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: buildWeatherFaultAndSet2SoapMessage

import org.apache.cxf.interceptor.Fault; //导入方法依赖的package包/类
public static void buildWeatherFaultAndSet2SoapMessage(SoapMessage message, FaultConst faultContent) {
	Fault exceptionFault = (Fault) message.getContent(Exception.class);
	String originalFaultMessage = exceptionFault.getMessage();
	exceptionFault.setMessage(faultContent.getMessage());
	exceptionFault.setDetail(createFaultDetailWithWeatherException(originalFaultMessage, faultContent));
	message.setContent(Exception.class, exceptionFault);
}
 
开发者ID:jonashackt,项目名称:tutorial-soap-spring-boot-cxf,代码行数:8,代码来源:WeatherSoapFaultHelper.java

示例4: checkFailure

import org.apache.cxf.interceptor.Fault; //导入方法依赖的package包/类
private void checkFailure(org.apache.camel.Exchange camelExchange, Exchange cxfExchange) throws Fault {
    final Throwable t;
    if (camelExchange.isFailed()) {
        org.apache.camel.Message camelMsg = camelExchange.hasOut() ? camelExchange.getOut() : camelExchange.getIn();
        if (camelMsg.isFault()) {
            t = camelMsg.getBody(Throwable.class);
        } else {
            t = camelExchange.getException();
        }
        cxfExchange.getInMessage().put(FaultMode.class, FaultMode.UNCHECKED_APPLICATION_FAULT);
        if (t instanceof Fault) {
            cxfExchange.getInMessage().put(FaultMode.class, FaultMode.CHECKED_APPLICATION_FAULT);
            throw (Fault)t;
        } else if (t != null) {
            // This is not a CXF Fault. Build the CXF Fault manually.
            Fault fault = new Fault(t);
            if (fault.getMessage() == null) {
                // The Fault has no Message. This is the case if it has
                // no message, for example was a NullPointerException.
                fault.setMessage(t.getClass().getSimpleName());
            }
            WebFault faultAnnotation = t.getClass().getAnnotation(WebFault.class);
            Object faultInfo = null;
            try {
                Method method = t.getClass().getMethod("getFaultInfo");
                faultInfo = method.invoke(t, new Object[0]);
            } catch (Exception e) {
                // do nothing here
            }
            if (faultAnnotation != null && faultInfo == null) {
                // t has a JAX-WS WebFault annotation, which describes
                // in detail the Web Service Fault that should be thrown. Add the
                // detail.
                Element detail = fault.getOrCreateDetail();
                Element faultDetails = detail.getOwnerDocument()
                    .createElementNS(faultAnnotation.targetNamespace(), faultAnnotation.name());
                detail.appendChild(faultDetails);
            }

            throw fault;
        }

    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:45,代码来源:CxfConsumer.java

示例5: handleMessage

import org.apache.cxf.interceptor.Fault; //导入方法依赖的package包/类
@Override
public void handleMessage(Message message) throws Fault {

    Fault fault = (Fault) message.getContent(Exception.class);
    String logCorrId = randomUUID().toString();
    fault.setMessage(transformMessage(fault, logCorrId));
    message.put("respiro.logCorrelationId", logCorrId);


}
 
开发者ID:kantega,项目名称:respiro,代码行数:11,代码来源:LogCorrelationInterceptor.java


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