如何在camel-spring-ws中捕获SOAP故障详细信息

huangapple 未分类评论47阅读模式
英文:

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

问题

<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>
英文:

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.

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

答案1

得分: 0

Camel在异常和故障之间进行区分(出于历史原因)。不幸的是,这一点在Camel文档中似乎缺失。

如果你希望Camel将故障视为与异常相同(由Camel错误处理程序处理),你需要设置:

.handleFault()

你可以在Camel上下文全局设置,也可以在特定路由上设置。另请参阅本页底部的评论

英文:

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

huangapple
  • 本文由 发表于 2020年5月2日 12:57:06
  • 转载请务必保留本文链接:https://java.coder-hub.com/61554669.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定