내 Spring 통합 구성 파일을 갖는는 <INT-HTTP : 아웃 바운드 게이트웨이> 메시지 컨버터를 사용하는 방법을
<int-http:outbound-gateway request-channel="loadToFtpChannel"
url="http://localhost:8107/ftpService/processFTP"
http-method="POST" message-converters="ftpMessgaeConverter"
expected-response-type="java.lang.String">
</int-http:outbound-gateway>
<bean id="ftpMessgaeConverter" class="com.ftp.FTPMessgaeConverter" ></bean>
및
FTPMessageConverter
클래스
public class FTPMessgaeConverter implements HttpMessageConverter<JSONObject> {
private static final List<MediaType> MEDIA_TYPES = new ArrayList<MediaType>();
static {
MEDIA_TYPES.add(MediaType.parseMediaType("application/json"));
}
@Override
public boolean canRead(Class<?> clazz, MediaType mediaType) {
// TODO Auto-generated method stub
return String.class.equals(clazz);
}
@Override
public boolean canWrite(Class<?> clazz, MediaType mediaType) {
// TODO Auto-generated method stub
return false;
}
@Override
public List<MediaType> getSupportedMediaTypes() {
// TODO Auto-generated method stub
return MEDIA_TYPES;
}
@Override
public JSONObject read(Class<? extends JSONObject> clazz, HttpInputMessage inputMessage)
throws IOException, HttpMessageNotReadableException {
JSONObject body = null;
try {
body = new JSONObject(inputMessage.getBody().toString());
} catch (JSONException e) {
e.printStackTrace();
}
return body;
}
@Override
public void write(JSONObject t, MediaType contentType, HttpOutputMessage outputMessage)
throws IOException, HttpMessageNotWritableException {
System.out.println("outputMessage " + outputMessage.getBody());
System.out.println("JSONObject " + t);
System.out.println("contentType " + contentType);
}
의 던지기 봄 통합의 속성 오류
org.springframework.web.client.RestClientException: Could not write request: no suitable HttpMessageConverter found for request type [org.json.JSONObject] and content type [application/json]
있음 request-channel="loadToFtpChannel"
메시지가 Json 형식으로 표시됩니다.이 메시지는 소스 및 대상을
<int-http:inbound-gateway>
으로 준비해야하고 일단 인바운드 - 게이트웨이가 요청을 처리하면 응답을 송신 게이트웨이로 다시 보냅니다. message-converters="ftpMessgaeConverter"
을 통해 메시지를 읽으십시오. 누구든지이 문제를 해결할 수 있습니까?
@Override
public boolean canWrite(Class<?> clazz, MediaType mediaType) {
// TODO Auto-generated method stub
return false;
}
이 HttpMessageConverter
전혀 요청을 전송에 적합하지 않습니다 말한다 : 감사
스팸 차단 더 많은 정보로 질문을 수정할 수 있습니다. 올바른 형식을 사용하십시오. 그렇지 않으면 주석에있는 코드를 읽을 수 없습니다. 너를 돕기 위해 내 시간을 존중해라. –
고맙습니다. 변환 된 파일이 선택되었으며 정상적으로 작동합니다. – meps