【问题标题】:How to handle CXF unmarshalling errors in Mule Exception-Strategy如何处理 Mule Exception-Strategy 中的 CXF 解组错误
【发布时间】:2014-04-10 18:04:59
【问题描述】:

我是 Mule 的新手,...我有一个 Web 服务,它有以下请求:-

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://services.test.com/schema/MainData/V1">
   <soapenv:Header/>
   <soapenv:Body>
      <v1:insertDataRequest>
         <v1:Id>6</v1:Id>
         <v1:Name>abc</v1:Name>
         <v1:Age>4</v1:Age>
         <v1:Designation>SE</v1:Designation>
      </v1:insertDataRequest>
   </soapenv:Body>
</soapenv:Envelope>

我的骡流有点像以下:-

  <flow name="MuleDbInsertFlow1" doc:name="MuleDbInsertFlow1">
            <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP"/>
    <cxf:jaxws-service serviceClass="com.test.services.v1.GetCalculation" doc:name="SOAP"/>
            <component class="com.test.services.v1.GetCalculationImpl" doc:name="Java"/>

 <catch-exception-strategy doc:name="Catch Exception Strategy">

   <set-payload value="Error occoured!!!!" doc:name="Set Payload"/>

 </catch-exception-strategy>


</flow>

现在我的问题是在 SOAP 请求中,ID 和 AGE 属性是整数,如果我输入任何字符串值,如 &lt;v1:Id&gt;aaaa&lt;/v1:Id&gt;,它会抛出错误,如 org.apache.cxf.interceptor.Fault: Unmarshalling Error:不是一个很自然的数字...现在我该如何处理这个Unmarshalling error 并发送自定义消息作为响应...我尝试在Mule 中使用catch 异常块,但我无法处理这个CXF 解组错误

【问题讨论】:

    标签: xml soap cxf mule mule-studio


    【解决方案1】:

    对于这种方法,将拦截器与 CXF Jaxws 服务一起使用。

    以下链接提供了 Mule 中 CXF 模块的更多详细信息以及对拦截器的引用。

    <cxf:jaxws-service .... ....>
      <cxf:inInterceptors>
        <spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
      </cxf:inInterceptors>
      <cxf:outInterceptors>
        <spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
      </cxf:outInterceptors>
    </cxf:jaxws-service>
    

    使用故障拦截器来控制错误处理。

    Mule CXF Module Reference

    【讨论】:

    • 嗨..谢谢您的回复..您能否详细定义如何处理此异常,以便我可以在响应时发送自定义消息..我已经实现了 但无法处理异常.. 请定义下一步需要做什么来处理异常,因为我是 Mule 的新手
    • 我提供了 LoggindInInterceptors 作为在 cxf mule 中显示拦截器配置的示例。日志拦截器应替换为故障拦截器以捕获错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-29
    • 2016-10-20
    • 2017-01-16
    相关资源
    最近更新 更多