我有一个Mule应用程序,它使用Apache CXF来使用外部Web服务。
我正在尝试注册一个Fault Interceptor,如下所示。
<cxf:proxy-client payload="body" doc:name="SOAP">
<!-- outgoing interceptor chain for the client and an incoming chain for the cxf server -->
<cxf:outFaultInterceptors>
<spring:ref bean="faultOutInterceptor" />
</cxf:outFaultInterceptors>
</cxf:proxy-client>
<spring:bean id="faultOutInterceptor" name="faultOutInterceptor" class="mypackage.soap.FaultOutInterceptor"/>
faultOutInterceptor是......
public class FaultOutInterceptor extends AbstractSoapInterceptor {
private static final Logger log = LoggerFactory.getLogger(FaultOutInterceptor.class);
public FaultOutInterceptor() {
super(Phase.USER_LOGICAL);
}
@Override
public void handleMessage(SoapMessage m) throws Fault {
log.info("Start in Fault Interceptor");
log.info("SoapMessage Interceptor" + m);
Fault fault = (Fault) m.getContent(Exception.class);
log.info("Received fault response from error: " + fault);
}
}
当抛出SOAP错误时,不会调用此拦截器。肯定有其他拦截器被调用但不幸的是不是我的。请参阅下面的日志......
DEBUG org.apache.cxf.phase.PhaseInterceptorChain - Chain org.apache.cxf.phase.PhaseInterceptorChain@10b0c88f was modified. Current flow:
setup [PolicyOutInterceptor, CopyAttachmentOutInterceptor]
pre-logical [OutputPayloadInterceptor, SoapHeaderOutFilterInterceptor]
post-logical [SoapPreProtocolOutInterceptor]
prepare-send [MessageSenderInterceptor]
pre-stream [AttachmentOutInterceptor, MuleProtocolHeadersOutInterceptor, StaxOutInterceptor, org.mule.module.cxf.transport.MuleUniversalConduit$2]
pre-protocol [MuleHeadersOutInterceptor]
write [SoapOutInterceptor]
marshal [BareOutInterceptor]
write-ending [SoapOutEndingInterceptor]
pre-stream-ending [StaxOutEndingInterceptor]
prepare-send-ending [MessageSenderEndingInterceptor]
DEBUG org.apache.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor org.apache.cxf.interceptor.BareOutInterceptor@3a2f22eb
DEBUG org.apache.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor$SoapOutEndingInterceptor@4a09a8da
DEBUG org.apache.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor org.apache.cxf.interceptor.StaxOutEndingInterceptor@5d175938
DEBUG org.apache.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor@18c65fc3
有人可以帮助我,我可能做错了吗?
感谢
答案 0 :(得分:0)
我认为你需要在Intercepter中注册一个而不是像下面的Intercepter那样注册
<cxf:jaxws-client serviceClass="com.mulesoft.example.HelloWorld"
operation="sayHello" port="HelloWorldPort">
<cxf:inInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
</cxf:inInterceptors>
</cxf:jaxws-client>