【问题标题】:WSO2 DataService (DataSource) Return Custom Error MessageWSO2 DataService (DataSource) 返回自定义错误信息
【发布时间】:2019-06-28 03:02:53
【问题描述】:

使用 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"
    }
}

请帮帮我,谢谢。

【问题讨论】:

    标签: wso2 wso2is wso2-am wso2dss wso2ei


    【解决方案1】:

    我认为对于这种行为,您需要创建自定义验证器,请查看此帖子: http://mycodeideas.blogspot.com/2016/07/custom-validators-with-wso2-dss.html

    【讨论】:

    • 但它会抛出 Validationexception 吗?在故障序列中使用代理服务如何处理,如果wso2 EI DS返回故障异常,那么Wso2代理服务这个DS返回哪个类的错误json消息?
    猜你喜欢
    • 2017-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-31
    • 1970-01-01
    • 1970-01-01
    • 2013-07-26
    • 1970-01-01
    相关资源
    最近更新 更多