Tôi cố gắng để gọi dịch vụ RESTful của tôi sử dụng JAXRSClientFactory - và tôi bị mắc kẹt với cung cấp cấu hình cho yêu cầu/đáp ứng ánh xạ các loại (tôi cần phải serialize danh sách)Việc gửi yêu cầu tùy chỉnh marshallers để JAXRSClientFactory
Mã này trông như thế này :
JAXRSClientFactory.create("http://localhost:8080/", MyCoolService.class, "/path/to/client/config.xml");
các config.xml trông giống như:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
">
<jaxrs:client id="testClient" createdFromAPI="true">
<jaxrs:providers>
<bean class="my.provider.Class"/>
</jaxrs:providers>
</jaxrs:client>
</beans>
bây giờ khi gỡ lỗi mã khách hàng, tôi có thể thấy rằng trong vòng org.apache.cxf.jaxrs.provide r.ProviderFactory có cuộc gọi
MessageBodyWriter<T> mw = chooseMessageWriter(messageWriters,
bodyType,
parameterType,
parameterAnnotations,
mediaType,
m);
tuy nhiên messageWriters không chứa cung cấp của tôi. Điều gì là sai với mã của tôi và làm thế nào để cung cấp MessageBodyWriter một cách chính xác? Cảm ơn trước!
Phương thức config.getHttpConduit() làm sạch mã đó một chút. –