简体   繁体   中英

how to capture soap fault detail in camel-spring-ws

I am using camel framework 2.22.0 and camel-spring-ws in my spring boot microservice to convert xml into soap at runtime and make a request to backend and same time receive the soap response and coverts it back to XML before sending the response back to calling system.

Success scenarios are all working fine but when soap fault it only logs the soap string and can't see any soap response been populated. soap response is not getting captured and doesn't get back to calling system apart from http status code 500.

The below is what backend system is sending as soap fault. I can't see anything in camel exchange body populated with soap fault. I need to capture the xml response in detail tag section and to send back to calling system.

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <soap:Fault>
          <faultcode>soap:Server</faultcode>
          <faultstring>abc-complex-type.x.x: Value '0' of attribute 'schemaVersion' of element 'ABCSubmission:ABCSubmission' is not valid with respect to the corresponding attribute use. Attribute 'schemaVersion' has a fixed value of '1'.</faultstring>
          <detail>
            <ns2:ABCSubmissionException xmlns:ns2="java:com.webservice.ejb" xmlns="ABCintegration.xdt">
              <ns2:ABCIntegrationError schemaVersionMajor="1" schemaVersionMinor="0">
                <ErrorName>ABCMessageSyntaxInvalid</ErrorName>
                <ErrorDescription>cvc-complex-type.3.1: Value '0' of attribute 'schemaVersion' of element 'ABCSubmission:ABCSubmission' is not valid with respect to the corresponding attribute use. Attribute 'schemaVersion' has a fixed value of '1'.</ErrorDescription>
              </ns2:ABCIntegrationError>
            </ns2:ABCSubmissionException>
          </detail>
        </soap:Fault>
      </soap:Body>
    </soap:Envelope>

Camel differentiates between Exceptions and Faults (historic reasons). Unfortunately this seems to be missing in the Camel Documentation.

If you want that Camel treats Faults the same as Exceptions (handled by the Camel error handler), you have to set

.handleFault()

You can set this globally on the Camel Context or on specific routes. See also the comment at the bottom of this page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM