如何从WSO2获取有关ERROR的信息?

时间:2019-06-17 13:48:19

标签: configuration wso2

我正在编写WSO2的日志记录系统。当我发送GET请求时,我收到一条信息(请求时间,方法名称等),为此,我制作了以下配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="jms_in_flow" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
    <property name="transactionId" expression="get-property('MessageID')"/>
    <clone continueParent="true">
        <target>
            <sequence>
                <property action="set" name="OUT_ONLY" value="true"/>
                <property expression="$ctx:api.ut.api_version" name="api_version" scope="transport" type="STRING"/>
                <property expression="$ctx:api.ut.version" name="api_short_version" scope="transport" type="STRING"/>
                <property expression="$ctx:api.ut.requestTime" name="api_request_time" scope="transport" type="STRING"/>
                <property expression="$ctx:REST_API_CONTEXT" name="api_context" scope="transport" type="STRING"/>
                <call>
                    <endpoint>
                        <address uri="jms:/WSO2.Logi"/>
                    </endpoint>
                </call>
                <drop/>
            </sequence>
        </target>
    </clone>
</sequence>

我从WSO2中将日志发送到队列中,并且可以正常工作,但是我不知道错误处理的方式。 我试试这个:

<sequence xmlns="http://ws.apache.org/ns/synapse" name="convert">
    <payloadFactory media-type="xml">
        <format>
            <am:fault xmlns:am="http://wso2.org/apimanager">
                <am:code>$1</am:code>
                <am:type>Status report</am:type>
                <am:message>Runtime Error</am:message>
                <am:description>$2</am:description>
            </am:fault>
        </format>
        <args>
            <arg evaluator="xml" expression="$ctx:ERROR_CODE"/>
            <arg evaluator="xml" expression="$ctx:ERROR_MESSAGE"/>
        </args>
    </payloadFactory>
    <property name="RESPONSE" value="true"/>
    <header name="To" action="remove"/>
    <property name="HTTP_SC" value="555" scope="axis2"/>
    <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
    <property name="ContentType" scope="axis2" action="remove"/>
    <property name="Authorization" scope="transport" action="remove"/>
    <property name="Access-Control-Allow-Origin" value="*" scope="transport"/>
    <property name="Host" scope="transport" action="remove"/>
    <property name="Accept" scope="transport" action="remove"/>
    <property name="X-JWT-Assertion" scope="transport" action="remove"/>
    <property name="messageType" value="application/json" scope="axis2"/>
    <send>
    <endpoint>
        <address uri="jms:/WSO2.Logi"/>
    </endpoint>
    </send>
</sequence>

我在哪里出错? 说明文件: https://docs.wso2.com/display/AM220/Error+Handling

UPD: 我按顺序应用了Fault,但这对我没有帮助

<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="fault_format" trace="disable">
  <payloadFactory media-type="xml">
    <format>
      <Fault>
        <ERROR_CODE>$1</ERROR_CODE>
        <ERROR_MESSAGE>$2</ERROR_MESSAGE>
        <ERROR_DETAIL>$3</ERROR_DETAIL>
      </Fault>
    </format>
    <args>
      <arg evaluator="xml" expression="get-property('ERROR_CODE')"/>
      <arg evaluator="xml" expression="get-property('ERROR_MESSAGE')"/>
      <arg evaluator="xml" expression="get-property('ERROR_DETAIL')"/>
    </args>
  </payloadFactory>
  <send>
    <endpoint>
        <address uri="jms:/WSO2.LOG.TEST"/>
    </endpoint>
    </send>
</sequence>

0 个答案:

没有答案