我正在尝试将 Jersey 1.0 客户端应用程序迁移到 Jersey 2.0。到目前为止,除了 content-type 之外,一切正常:/application/fastinfoset
我使用了 Jeysey 2.21.1 BOM,所以 jersey fastinfoset 包含在依赖项中。
我的问题是我没有找到如何注册 FastInfoSet。
我获得 MessageReaderBody 异常。
我正在尝试将 Jersey 1.0 客户端应用程序迁移到 Jersey 2.0。到目前为止,除了 content-type 之外,一切正常:/application/fastinfoset
我使用了 Jeysey 2.21.1 BOM,所以 jersey fastinfoset 包含在依赖项中。
我的问题是我没有找到如何注册 FastInfoSet。
我获得 MessageReaderBody 异常。
您需要注册符合 Jersey 2 标准的 FI 提供商。就像是
private Client client() {
ClientConfig config = new ClientConfig();
config.register(FastInfosetJAXBElementProvider.class);
config.register(FastInfosetRootElementProvider.class);
config.property(ClientProperties.CONNECT_TIMEOUT, 5000);
config.property(ClientProperties.READ_TIMEOUT, 15000);
return JerseyClientBuilder.createClient(config);
}
提供者类来自这个 repo:
https://github.com/jecklgamis/jersey-fastinfoset-provider
希望这可以帮助。
我为我在 JIRA for Jersey 上创建的问题创建了一个演示。该代码适用于 application/fastinfoset https://java.net/jira/browse/JERSEY-3053
我为实体和输入流工作。我还没有介绍 MessageBodyCover。