How to use Odoo REST Services with JAX-RS?

I am trying to write a Java web application that runs on A Tomee application server. The application uses a number of Jakarta EE technologies such as JAX-RS, Jakarta Faces, and CDI. The basic application is running fine; I have no problems with that.

However, at one point, I need to update our Odoo server. Odoo provides a REST API as described here: Odoo External API

That page provides a number of examples for various programming languages, including Java. Unfortunately, the Java example uses the Apache XML-RPC package, which hasn’t been updated for about 14 years, and may have security vulnerabilities, as I understand from Maven Central.

So I would prefer not to use that, and am looking for some way of communicating with Odoo with the technology at hand, for example using the JAX-RS client.

The Odoo documentation provides an Apache XML-RPC example for obtaining the server version, which can be run without authentication:

final String url = "myServer";
final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
common_config.setServerURL(new URL(String.format("%s/xmlrpc/2/common", url)));
client.execute(common_config, "version", emptyList());

According to the documentation, executing the example should result in the following output:

{
    "server_version": "13.0",
    "server_version_info": [13, 0, 0, "final", 0],
    "server_serie": "13.0",
    "protocol_version": 1,
}

Note that I don’t have Apache XML RPC installed and haven’t tested this example. Instead, I tried to carry out the same action using the JAX-RS client using the following code:

private final static String pathCommon = "/xmlrpc/2/common";                       
private final static String odooServer = "http://my.server";
Client client = ClientBuilder.newClient();                         
WebTarget server = client.target(odooServer);                      
WebTarget common = server.path(pathCommon);                                                                                         
Invocation.Builder invoker = common.request(MediaType.TEXT_PLAIN);
Entity<String> e = Entity.text("version");                                                           
Response resp = invoker.post(e);                                     

This really didn’t work at all. The request did seem to make it to the Odoo server, and the Odoo server felt that it was being talked to, but the request format I sent was obviously wrong. The server responded as follows, which is not what was expected.

Response status: 200, Status type:OK, Status family:SUCCESSFUL, Status phrase:OK
 Length: 783, has entity: true
Data :
entity as string: 
<?xml version='1.0'?>
<methodResponse>
<fault>
<value><struct>
<member>
<name>faultCode</name>
<value><int>1</int></value>
</member>
<member>
<name>faultString</name>
<value><string>Traceback (most recent call last):
  File "/opt/odoo/odoo/odoo/addons/base/controllers/rpc.py", line 69, in xmlrpc_2
    response = self._xmlrpc(service)
  File "/opt/odoo/odoo/odoo/addons/base/controllers/rpc.py", line 48, in _xmlrpc
    params, method = loads(data)
  File "/usr/local/lib/python3.8/xmlrpc/client.py", line 1017, in loads
    p.close()
  File "/usr/local/lib/python3.8/xmlrpc/client.py", line 447, in close
    parser.Parse(b"", True) # end of data
xml.parsers.expat.ExpatError: syntax error: line 1, column 0
</string></value>
</member>
</struct></value>
</fault>
</methodResponse>

My best guess is that Odoo was expecting an XML message as input rather than text. But I cannot find any documentation at all about what message format would be expected. Can anyone provide a pointer to the Odoo documentation for the actual messages expected? I the JAX-RS client the proper tool to be using, or would there be a better alternative? Could anyone provide an example of using the Odoo REST API with Jax-RS? Does Odoo maybe have a Json-based REST interface?

Thank you for any help!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật