处理 CXF JAX-RS 客户端中的异常
我想在 CXF Rest 客户端中将 HTTP 状态代码转换为 Java 异常。根据 官方文档 我需要使用 ResponseExceptionMapper,但没有示例使其工作。我的理解是我需要将其注册为提供者,但是如何使用代理类型的客户端来做到这一点?我尝试了以下代码,
//create a proxy client
locationService = JAXRSClientFactory.create(applicationURI + "/rest/", LocationService.class);
//registering my ResponseExceptionMapper
ProviderFactory.getSharedInstance().registerUserProvider(LocationResponseExceptionMapper.getInstance());
但它不起作用,因为 ProviderFactory.getSharedInstance() 返回与我的客户端使用的实例不同的 ProviderFactory 实例。
I want to convert HTTP status codes to Java Exceptions in my CXF rest client. According to the official documentation I need to use ResponseExceptionMapper, but there is no example to make it work. My understanding is that I need to register it as a provider, but how can I do that with a proxy type of client? I tried the following code
//create a proxy client
locationService = JAXRSClientFactory.create(applicationURI + "/rest/", LocationService.class);
//registering my ResponseExceptionMapper
ProviderFactory.getSharedInstance().registerUserProvider(LocationResponseExceptionMapper.getInstance());
but it is not working, because ProviderFactory.getSharedInstance() returns a different ProviderFactory instance then the instance used by my client.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 此签名:
Supply exception mapper to proxy factory using this signature: