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


Java MessageContext.setProcessingFault方法代码示例

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


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

示例1: handleResponse

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * Used to handle the HTTP Response
 *
 * @param msgContext - The MessageContext of the message
 * @param method     - The HTTP method used
 * @throws IOException - Thrown in case an exception occurs
 */
private void handleResponse(MessageContext msgContext,
                            HttpMethodBase method) throws IOException {
    int statusCode = method.getStatusCode();
    HTTPStatusCodeFamily family = getHTTPStatusCodeFamily(statusCode);
    log.trace("Handling response - " + statusCode);
    Set<Integer>nonErrorCodes = (Set<Integer>) msgContext.getProperty(HTTPConstants.NON_ERROR_HTTP_STATUS_CODES);    
    Set<Integer> errorCodes = new HashSet<Integer>();
    String strRetryErrorCodes = (String) msgContext.getProperty(HTTPConstants.ERROR_HTTP_STATUS_CODES); // Fixing
                                                                                            // ESBJAVA-3178
    if (strRetryErrorCodes != null && !strRetryErrorCodes.trim().equals("")) {
        for (String strRetryErrorCode : strRetryErrorCodes.split(",")) {
            try {
                errorCodes.add(Integer.valueOf(strRetryErrorCode));
            } catch (NumberFormatException e) {
                log.warn(strRetryErrorCode + " is not a valid status code");
            }
        }
    }
    if (HTTPStatusCodeFamily.SUCCESSFUL.equals(family)) {
        // Save the HttpMethod so that we can release the connection when cleaning up
        // HTTP 202 Accepted should support body based on ESBJAVA-4370 as spec does not strictly enforce
        // no-entity-body with 202 Accepted response.
        msgContext.setProperty(HTTPConstants.HTTP_METHOD, method);
        processResponse(method, msgContext);
    } else if (!errorCodes.contains(statusCode)
            && (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR
                    || statusCode == HttpStatus.SC_BAD_REQUEST || statusCode == HttpStatus.SC_CONFLICT)) {
        // Save the HttpMethod so that we can release the connection when cleaning up
        msgContext.setProperty(HTTPConstants.HTTP_METHOD, method);
        Header contenttypeHeader =
                method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
        String value = null;
        if (contenttypeHeader != null) {
            value = contenttypeHeader.getValue();
        }
         OperationContext opContext = msgContext.getOperationContext();
        if(opContext!=null){
            MessageContext inMessageContext =
                    opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
            if(inMessageContext!=null){
                inMessageContext.setProcessingFault(true);
            }
        }
        if (value != null) {

            processResponse(method, msgContext);
        }
        
        if (org.apache.axis2.util.Utils.isClientThreadNonBlockingPropertySet(msgContext)) {
        	 throw new AxisFault(Messages.getMessage("transportError",
                     String.valueOf(statusCode),
                     method.getStatusText()));
        }
    } else if (nonErrorCodes != null && nonErrorCodes.contains(statusCode)) {
        msgContext.setProperty(HTTPConstants.HTTP_METHOD, method);
        processResponse(method, msgContext);
        return;
    } else {
        // Since we don't process the response, we must release the connection immediately
        method.releaseConnection();
        //solving CARBON-16056
        msgContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE, method.getStatusCode());
        AxisFault axisFault = new AxisFault(
                Messages.getMessage("transportError", String.valueOf(statusCode), method.getStatusText()),
                msgContext);
        axisFault.setFaultCode(String.valueOf(method.getStatusCode()));
        throw axisFault;
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:77,代码来源:HTTPSender.java


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