WSO2 DataService(数据源)返回自定义错误消息

时间:2019-06-28 03:02:53

标签: wso2 wso2is wso2-am wso2dss wso2ei

使用 WSO2 EI(6.5.0) DataService

时如何返回自定义错误响应

验证输入值时出现此错误:

{
    "Fault": {
        "faultcode": "axis2ns16:VALIDATION_ERROR",
        "faultstring": "DS Code: VALIDATION_ERROR\nNested Exception:-\njavax.xml.stream.XMLStreamException: DS Code: VALIDATION_ERROR\nSource Data Service:-\nName: MWGetBranchCodes\nLocation: \\MWGetBranchCodes.dbs\nDescription: N/A\nDefault Namespace: http://ws.wso2.org/dataservice\nCurrent Request Name: _post_getbankcodes\nCurrent Params: {SOURCE=source, REQUESTER=bond, FUNCTION=function, SECURITYCODE=1FE550839D5DD7933032340DA85F614}\nNested Exception:-\nSecuritycode and Function are not matched : \nField Name: SECURITYCODE\nField Value: 1FE550839D5DD7933032340DA85F614\n\n",
        "detail": ""
    }
}

我想要这个:

{
    "Error": {
        "ErrorCode": "0", 0-failed/ 1-success
        "ErrorMessage": "VALIDATION_ERROR : Securitycode is NULL",
        "detail": " \nField Name: SECURITYCODE\nField Value: null\n\n"
    }
}

请帮助我,谢谢。

1 个答案:

答案 0 :(得分:0)

我认为,对于该行为,您需要创建自定义验证器,请查看以下文章: http://mycodeideas.blogspot.com/2016/07/custom-validators-with-wso2-dss.html