Apache CXF(Mule)映射中的QName无效:SOAP-ENV:Client

时间:2014-12-15 01:19:38

标签: soap cxf mule

我在Mule ESB 3.5.0 CE中使用Apache CXF 2.5.9作为Web服务客户端。如果soap消息验证在服务器上失败,我会得到一个肥皂错误(自然地),如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Fault xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
   <faultcode>SOAP-ENV:Client</faultcode>
   <faultstring>https://10.1.104.105:8444/DohvatiIzOIBaF2FAServiceTest: cvc-simple-type 1: element {http://www.apis-it.hr/fin/2008/elements/DohvatIzOIBa}OIB value '716500116650' is not a valid instance of type {http://www.apis-it.hr/fin/2008/types/f63}String11BrojType</faultstring>
   <faultactor>OIB CIS pristupni čvor</faultactor>
</soapenv:Fault>

..但是当客户端尝试解组故障时,我得到了这个例外:

2014-12-13 13:52:34,199 [WARN] org.apache.cxf.phase.PhaseInterceptorChain - Interceptor for {http://www.apis-it.hr/fin/2010/services/DohvatiIzOIBaF2FAService}DohvatiIzOIBaF2ServicePortTypeService#{http://www.apis-it.hr/fin/2010/services/DohvatiIzOIBaF2FAService}DohvatiFOPoOIBu has thrown exception, unwinding now
java.lang.RuntimeException: Invalid QName in mapping: SOAP-ENV:Client
    at org.apache.cxf.staxutils.StaxUtils.readQName(StaxUtils.java:1399)
    at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:59)
    at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:46)
    at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:35)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
    at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:114)
    at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:69)
    at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
    at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:801)

我希望CXF客户端将soap故障解组为异常。如何解决这个错误?

3 个答案:

答案 0 :(得分:1)

尝试制作SOAP-ENV:客户端类似于12345,使故障代码为我解决了这个问题。

答案 1 :(得分:0)

Mule不会自己捕获异常。 您应该使用cxf fault interceptor。从那里你可以撰写你期待的信息。

答案 2 :(得分:0)

或者,您可以使用CXF transform feature

您需要: <entry key="faultcode" value="faultcode=soapenv:Client"/>

这会将来自服务器的原始无效故障映射到以下有效故障,以便cxf客户端可以接受

<soapenv:Fault>
 <faultcode>soapenv:Client</faultcode>
 <faultstring>An error occurred</faultstring>
</soapenv:Fault>