3

I'm using the HAPI-FHIR library's generic RESTful client to communicate with a FHIR server which is occasionally delivering some unclean XML, but the errors can be avoided if I use JSON.

This is easy to override in client.search() by adding .encodedJson() to the fluent chain (as mentioned on the documentation intro page). However, some methods (e.g. client.read(...)) don't seem to have any way to set the encoding, so they accept whatever the server sends by default.

Is there perhaps a way to set a default encoding in the context or client creation so it applies wherever they are used?

4

1 回答 1

3

你知道吗?流利的客户端有一种方法来设置默认编码(以及漂亮的打印行为),但它没有公开它。诡异的。我会确保我们为下一个版本的 HAPI FHIR 修复这个问题。

同时,以下解决方法应设置此:

((BaseClient)client).setEncoding(EncodingEnum.JSON);

于 2015-03-19T11:13:19.823 回答