Вопрос

I am new to Mule,... I have a webservice that has a following request :-

<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>

My mule flow is somewhat likethe following :-

  <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>

Now my question is here in the SOAP request the ID and AGE attributes are integer and if I put any string value like <v1:Id>aaaa</v1:Id> it throws Fault like org.apache.cxf.interceptor.Fault: Unmarshalling Error: Not a number which is quite natural ... now how can I handle this Unmarshalling error and send custom message as response ... I tried by using catch exception block in Mule but I am unable to handle this CXF unmarshalling error

Это было полезно?

Решение

For this one approach would be to use Interceptors with CXF Jaxws service.

This following link gives more detials of the CXF module in Mule and reference to Interceptors.

<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>

Use Fault Interceptors to take control of the error processing.

Mule CXF Module Reference

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top