WSO2 API管理器验证错误的内容类型 [英] WSO2 API Manager Auth error content type

查看:416
本文介绍了WSO2 API管理器验证错误的内容类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有WSO2 API管理器中配置,一切似乎很好地工作。

I have WSO2 API Manager configured and everything seems to work fine.

困扰着我唯一的问题是,在一个验证异常情况下,API经理总是返回XML内容类型,例如响应。

The only issues bothering me is that in case of an Auth exception, the API manager always returns the response with XML content type, e.g.,

<ams:fault xmlns:ams="http://wso2.org/apimanager/security"><ams:code>900904</ams:code><ams:message>Access Token Inactive</ams:message><ams:description>Access failure for API: /exchange, version: 1.0 with key: 1139a466ebfd825aca953ad7259b9f45</ams:description></ams:fault>

在客户端的情况下,用JSON格式我的Web服务通信,XML响应看起来有点怪怪的。

In case of client communicates with my web service with JSON format, the XML response will look a little bit strange.

有什么想法如何使API经理提供JSON格式的错误响应?

Is there any ideas how to make API Manager provide error response in JSON format?

推荐答案

这有得到解决在最新版本的API管理器。验证错误可以通过添加或更新 error_message_type 属性设置为JSON格式WSO2HOME/repository/deployment/server/synapse-configs/default/sequences/_auth_failure_handler_.xml:

This has been addressed in recent versions of API Manager. Auth errors can be set to json format by adding or updating the error_message_type property in WSO2HOME/repository/deployment/server/synapse-configs/default/sequences/_auth_failure_handler_.xml:

<property name="error_message_type" value="application/json"/>

我发现这也要求 JSONBuilder JSONMessageFormatter 来选择在Axis2中JSON内容类型。 XML(这是默认设置)。

I've found this also requires JSONBuilder and JSONMessageFormatter to be selected for the json content type in axis2.xml (which is the default setting).

对于旧版本,本文介绍如何手动做。

For older versions, this article explains how to manually do the same.

这篇关于WSO2 API管理器验证错误的内容类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆