本文整理汇总了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);
}
}
示例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);
}
示例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);
}
}
示例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();
}
示例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);
}