2
我想通過點擊在http://someotherhost
網站上提供的REST Web服務來使用REST結果。我已經爲它寫了一個代理客戶端Apache CXFRS和CAMEL配置
我想使用apache CXFRS客戶端命中上述REST服務並將結果寫入文件。爲此,我正在做以下工作,是否有人可以查看下面的內容,並評論我做錯的事情。
a)用阿帕奇CXF我的駱駝上下文配置是如下
<jaxrs:client address="http://someotherhost/test/" id="cityServiceClient" username="test"
password="pwd"
serviceClass="com.santosh.proxy.service.city.CityService">
<jaxrs:features>
<ref bean="loggingFeature" />
</jaxrs:features>
</jaxrs:client>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<package>com.santosh.routes</package>
<routeBuilder ref="cityserviceroutebuilder" />
</camelContext>
B)MY代理服務接口
@Path(value="/getCities")
public interface CityService {
@POST
@Produces(value="text/xml")
public String getCities(@QueryParam("countrycode") String countryCode);
}
c)中召喚而
CityService cityService = (CityService) context.getBean("cityServiceClient");
cityService.getCities("ae");
d)駱駝路線
public class CityRoutes extends RouteBuilder {
public void configure() throws Exception {
//ROUTES
from("cxfbean:cityServiceClient")
.to("file://data/xmls/cities?fileName=test.xml");
}
}
得到了最後解決 –