中按故障顺序访问此消息

中按故障顺序访问此消息

本文介绍了如何在 WSO2 ESB 中按故障顺序访问此消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何访问来自 WSO2 ESB 错误序列 ERROR_CODE 中的 wso2dss 端标准错误的错误文本?

我正常了,但是这个 ERROR_MESSAGE 给出了 NULL.我怎样才能做到这一点?

这是 WSO2DSS 标准错误消息:

<soapenv:代码><soapenv:Value>soapenv:Receiver</soapenv:Value></soapenv:代码><soapenv:原因><soapenv:Text xml:lang="en-US" xmlns:xml="http://www.w3.org/XML/1998/namespace">无效的emp_DataService服务不属于emp_DataService 服务组.</soapenv:Text></soapenv:原因><soapenv:Detail/></soapenv:Fault>

我想访问错误代码以及错误文本.为什么?因为我需要发邮件给后端部门,帮助他们尽快追踪错误.

如何在 WSO2ESB 中执行此操作?

我希望显示这两个节点:

  1. <soapenv:Value>soapenv:Receiver</soapenv:Value></soapenv:代码>

  2. 2.
 &ltsoapenv:Text xml:lang="en-US"xmlns:xml="http://www.w3.org/XML/1998/namespace">emp_DataService无效的服务不属于 emp_DataService服务组.&lt/soapenv:Text>

我如何访问它?有人知道吗?

解决方案

在 ESB 中,默认情况下无法识别 SOAP 错误.它只是将它作为基本的soap 消息传递.为了将其标识为 SOAP_FAULT,您应该设置属性

之后它将为传入的 SOAP_FAULT 触发故障序列.所以你必须声明即将到来的消息是一个 SOAP_FAULT,所以你必须说它是一个 SOAP_FAULT 并强制它进入错误序列.这在 [1] 一篇关于我的 Amila 的博客中有解释.

对于问题的第二部分,您可以使用有效载荷工厂转换.您可以使用以下顺序.

<日志级别=满"><property name="SEQUENCE" value="----------------DSS FAULT---"/></log><payloadFactory><参数><arg value="/soapenv:Fault/soapenv:Reason/soapenv:Text/text()"/></args></payloadFactory><header name="Action" value="urn:errormsg"/><property name="OUT_ONLY" value="true" scope="default" type="STRING"/><发送><端点><address uri="http://localhost:9765/services/DssService.SOAP11Endpoint/"/></端点></发送></序列>

可以指向您的任何电子邮件客户端.给定的 xpath 直接指向您在问题中发布的 SOAP 响应的错误消息.

要发送电子邮件,您可以使用 [2] 中的 wso2 esb 邮件传输.

[1].http://maharachchi.blogspot.com/2012/09/now-you-can-send-soapfaults-to-fault.html.

[2].http://wso2.org/library/knowledge-base/use-mail-transport-esb-convert-soap-message-plain-text-mail

How can I access this error text which is from wso2dss side standard error in WSO2 ESB fault sequence ERROR_CODE?

I am getting properly but this ERROR_MESSAGE giving NUll. How can I do this?

This is WSO2DSS standard ERROR message:

<soapenv:Fault xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Code>
      <soapenv:Value>soapenv:Receiver</soapenv:Value>
   </soapenv:Code>
   <soapenv:Reason>
      <soapenv:Text xml:lang="en-US" xmlns:xml="http://www.w3.org/XML/1998/namespace">The emp_DataService service, which is not valid, does not belong to the emp_DataService service group.</soapenv:Text>
   </soapenv:Reason>
   <soapenv:Detail/>
</soapenv:Fault>

I want to access the code of error as well as error text. Why? Because I need send a mail to backend department which will help them to trace a error as soon as possible.

How can I do this in WSO2ESB?

I want this two nodes to show:

  1. <soapenv:Code>
              <soapenv:Value>soapenv:Receiver</soapenv:Value>
           </soapenv:Code>
    

  2. 2.

How can I access this? Anyone know this?

解决方案

In ESB as default the SOAP error is not recognized. It just passes it as a basic soap Message.In order to identify it as a SOAP_FAULT you should set the property

<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true">

After wards it will trigger fault sequence for the incoming SOAP_FAULT.So you have to declare coming message is a SOAP_FAULT so you hace to say it is a SOAP_FAULT and force it to error sequence. This is explained in [1] a blog past my Amila.

For the second part of the question you can use payload Factory transformation.You can use following sequence.

<sequence xmlns="http://ws.apache.org/ns/synapse" name="ErrorTransformSequence">
   <log level="full">
      <property name="SEQUENCE" value="----------------DSS FAULT------------------"/>
   </log>
   <payloadFactory>
      <format>
         <m:errorMessage xmlns:m="http://dss.error">
            <m:error>
               <m:message>$1</m:message>
            </m:error>
         </m:errorMessage>
      </format>
      <args>
         <arg value="/soapenv:Fault/soapenv:Reason/soapenv:Text/text()"/>
      </args>
   </payloadFactory>
   <header name="Action" value="urn:errormsg"/>
   <property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
   <send>
      <endpoint>
         <address uri="http://localhost:9765/services/DssService.SOAP11Endpoint/"/>
      </endpoint>
   </send>
</sequence>

canbe pointed to any of your email client.The given xpath directly pointing to the error message of the SOAP response you have posted in your question.

And to senf the email you can use wso2 esb mail transport in [2].

[1]. http://maharachchi.blogspot.com/2012/09/now-you-can-send-soapfaults-to-fault.html.

[2]. http://wso2.org/library/knowledge-base/use-mail-transport-esb-convert-soap-message-plain-text-mail

这篇关于如何在 WSO2 ESB 中按故障顺序访问此消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 00:31