2017-07-26 82 views
0

概述之間的對象。
我的駱駝設置調用兩種服務方法。第一個響應被傳遞到第二個響應,然後輸出最終響應爲json網頁。相當簡單沒有太複雜。休息駱駝傳遞終點

進一步細分提供一些更多的上下文。 Method_1。採用scanId。這工作正常。它產生一個名爲ScheduledScan.class Method_2的對象。引入ScheduledScan .class的先前實例並返回ConvertedScans掃描列表。然後想顯示該列表的代碼的

說明

@Override 
public void configure() throws Exception { 

    restConfiguration().bindingMode(RestBindingMode.json); 

    rest("/publish") 
     .get("/scheduled-scan/{scanId}") 
     .to("bean:SentinelImportService?method=getScheduledScan").outType(ScheduledScan .class) 
     .to("bean:SentinelImportService?method=convertScheduledScan"); 
} 

被稱爲樣子以下

ScheduledScan getScheduledScan(@Header("scanId") long scanId); 
List<ConvertedScans > convertScheduledScan(@Body ScheduledScan scheduledScans); 

它返回了以下錯誤

沒有方法body可用的類型:路徑。 .ScheduledScan但值:
類型:java.lang.String on:HttpMessage @ 0x63c2fd04。產生的原因:無可用

下運行沒有錯誤的類型轉換器,即沒有方法2。所以,我認爲,即時通訊幾乎沒有。

rest("/publish") 
.get("/scheduled-scan/{scanId}") 
.to("bean:SentinelImportService?method=getScheduledScan"); 

現在從閱讀錯誤它看起來像即時傳遞HttpMessage而不是java對象?我對接下來要做什麼感到困惑?任何建議非常感謝。

我發現這個消息的一些類似的問題。不過,我正在尋找將java對象直接傳遞給服務方法。

camel-rest-bean-chaining

how-to-share-an-object-between-methods-on-different-camel-routes

回答

1

,您應該設置的outType作爲最後的輸出,例如什麼REST的反應是,這是一個列表/陣列,而不是一個單一的POJO。所以請改用.outTypeList(ConvertedScans.class)