http:outbound-gateway
aracılığıyla bahar entegrasyonundan bir REST hizmetine bir JSON dizesi göndermeye çalışıyorum.DönüştürücüNotFoundException, ilkbahar entegrasyonu hizmetini dinlenmek üzere bir dize nesnesi gönderiliyor
Ama hatayı
yok dönüştürücü alma ilgili ayrıntıları
Paylaşımı <?>
org.springframework.http.ResponseEntity yazmak için tip java.lang.String dönüştürme yeteneğine bulundu
<int-http:outbound-gateway id="xtifygateway"
request-channel="requestchannel" request-factory="requestFactory"
url="${xtifyUrl}" http-method="POST">
</int-http:outbound-gateway>
<int:header-enricher input-channel="requestchannel">
<int:header name="Content-Type" value="application/json"/>
</int:header-enricher>
İstek göndermek için kullanılan arabirim,
public interface RequestGateway
{
ResponseEntity<?> pushNotification(String xtifyRequest);
}
Bu kodu java'da ve arabirim yöntemini kullanarak kullanıyorum.
ObjectMapper objectMapper = new ObjectMapper();
try {
String xtifyJson = objectMapper.writeValueAsString(xtifyRequest);
}
Bu konuda yardımcı olabilecek herhangi biri var mı? Burada neyi özlüyorum?
<xsd:attribute name="expected-response-type" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
The expected type to which the response body should be converted.
Default is 'org.springframework.http.ResponseEntity'.
This attribute cannot be provided if expected-response-type-expression has a value
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="direct">
<tool:expected-type type="java.lang.Class" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
bir taraftan String
yeterli olmalı, ama diğer bazı alan adı nesnesini kullanmak düşünün:
ObjectMapper objectMapper = new ObjectMapper(); try { Dize xtifyJson = objectMapper.writeValueAsString (xtifyRequest); } Bu kodu java'da ve arabirim yöntemini çağırarak kullanıyorum. Bunu kaldırmalı ve MappingJackson2HttpMessageConverter uygulamasını kullanmalı mıyım? – chungunuvavaa
Hayır, sorun değil. Sadece "beklenen cevap tipi" yi "java.lang.String" olarak belirtmeniz gerekir. –
Teşekkürler Artem .it çalıştı – chungunuvavaa