RestTemplate을 사용하여 REST 서비스에 액세스하는 데 문제가 있습니다. 이미 다른 서비스에 액세스하기 위해 MarshallingConverter 사용자를 관리했으며 모든 것이 잘 작동했습니다. 이 기능을 복사하고 내가받은 XSD 스키마에서 Model 클래스를 생성했습니다. 그러나 적절한 변환기를 찾을 수 없다는 예외가 있습니다. RestTemplate은 내 서비스 클라이언트 클래스 구현에Spring RestTemplate - 응답 유형 [..] 및 컨텐츠 유형 [application/xml]에 적합한 HttpMessageConverter가 없습니다.
<bean id="marshallingConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
<property name="marshaller" ref="jaxbMarshaller" />
<property name="unmarshaller" ref="jaxbMarshaller" />
</bean>
<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
... here are my model classes ...
</list>
</property>
</bean>
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<property name="messageConverters">
<list>
<ref bean="marshallingConverter" />
</list>
</property>
</bean>
를 autowire가있다 : 여기 내 구성은 (그 중요한 경우 내가 만약 angel와 관련하여 봄 3.0.6를 사용하고 있습니다)입니다. 내가 여기서 무엇을 놓치고 있니? 응답을 확인하고 콘텐츠 유형이 application/xml로 설정되어 있고 모델 클래스가 자동 생성되었으므로 구성이 올바르게되어 있어야합니다. 어떤 도움을 주셔서 감사합니다.
한 가지 더요, 나는 모델 클래스를 생성하는 데 사용되는 XSD 스키마에 대해 들어오는 XML을 확인했으며 모든 것이 유효합니다. –
그래서 JAXB가 들어오는 XML에서 객체를 생성 할 수 없다는 점을 발견했습니다. 그러나 모든 모델 클래스는 xjc 도구를 사용하여 XSD 스키마에서 자동 생성되며 XML은 스키마에 대해 유효합니다. 정말 이상해. 모델 클래스의 일부 주석이 누락 된 것 같습니다. 누구나 비슷한 문제가 있습니까? –