當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。