當前位置: 首頁>>代碼示例>>Java>>正文


Java Fault.setFaultCode方法代碼示例

本文整理匯總了Java中org.apache.cxf.interceptor.Fault.setFaultCode方法的典型用法代碼示例。如果您正苦於以下問題:Java Fault.setFaultCode方法的具體用法?Java Fault.setFaultCode怎麽用?Java Fault.setFaultCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.cxf.interceptor.Fault的用法示例。


在下文中一共展示了Fault.setFaultCode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleMessage

import org.apache.cxf.interceptor.Fault; //導入方法依賴的package包/類
public void handleMessage(Message message)
    throws Fault
{
    // 通知流量監控模塊
    IMonitor monitor = ApplicationContextUtil.getBean("southFCMonitor");
    if (monitor != null)
    {
        monitor.reportStatus(1); // 增加一次SOAP調用
        IPerformer performer = ApplicationContextUtil.getBean("southFCPerformer");
        if (performer != null)
        {
            if (performer.doFilter(null))
            {
                monitor.reportStatus(-1); // 被流控消息不計入監控數據
                SOAPException soapExc = new SOAPException("");
                Fault fault = new Fault(soapExc);
                fault.setFaultCode(new QName(Integer.toString(ESDKErrorCodeConstant.ERROR_CODE_SDK_SYSBUSY)));
                throw fault;
            }
        }
    }
}
 
開發者ID:Huawei,項目名稱:eSDK_EC_SDK_Java,代碼行數:23,代碼來源:UCOBGOutInterceptor.java

示例2: 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

示例3: 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

示例4: handleMessage

import org.apache.cxf.interceptor.Fault; //導入方法依賴的package包/類
@Override
public void handleMessage(Message message)
    throws Fault
{
    // 通知流量監控模塊
    IMonitor monitor = ApplicationContextUtil.getBean("northFCMonitor");
    if (monitor != null)
    {
        monitor.reportStatus(1); // 增加一次SOAP調用
        IPerformer performer = ApplicationContextUtil.getBean("northFCPerformer");
        if (performer != null)
        {
            if (performer.doFilter(message))
            {
                monitor.reportStatus(-1); // 被流控消息不計入監控數據
                LOGGER.info("*****北向消息,線程id=*****" + Thread.currentThread().getId() + "被流控");
                SOAPException soapExc = new SOAPException("");
                Fault fault = new Fault(soapExc);
                fault.setFaultCode(new QName(Integer.toString(ESDKErrorCodeConstant.ERROR_CODE_SDK_SYSBUSY)));
                throw fault;
            }
        }
    }
    
    HttpServletRequest req = (HttpServletRequest)message.get("HTTP.REQUEST");
    String ip = req.getRemoteAddr();
    MessageContext mc = ThreadLocalHolder.get();
    if (null == mc)
    {
        mc = new MessageContext();
        ThreadLocalHolder.set(mc);
    }
    mc.getEntities().put(ESDKConstant.ESDK_CLIENT_IP, ip);
    
    String soapAction = req.getHeader("SOAPAction");
    if (null != soapAction)
    {
        String interfaceName = soapAction.substring(1, soapAction.length() - 1);
        // 記錄調用日誌
        String messageId = (String)message.getExchange().get(LoggingMessage.ID_KEY);
        if (messageId == null)
        {
            messageId = LoggingMessage.nextId();
            message.getExchange().put(LoggingMessage.ID_KEY, messageId);
        }
        
        LogBean bean = new LogBean();
        bean.setActionName(interfaceName);
        bean.setRequestTime(new Date());
        bean.setIp(req.getRemoteHost());
        bean.setPort(req.getRemotePort() + "");
        LogInterface log = ApplicationContextUtil.getBean("logManager");
        log.saveRequestLog(messageId, bean);
    }
    
}
 
開發者ID:Huawei,項目名稱:eSDK_EC_SDK_Java,代碼行數:57,代碼來源:UCInterceptor.java


注:本文中的org.apache.cxf.interceptor.Fault.setFaultCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。