में ऊंट से आरईएसटी कॉल (जेएसओएन बॉडी के साथ पोस्ट) का आह्वान कैसे करें आईबीएम वेबस्पियर पर चल रहे एक वेब प्रोजेक्ट में ServletContextListener में निम्नलिखित काम कर रहे कैमेल प्रवाह सेटअप के बाद, आने वाला एक्सएमएल जेएसओएन में परिवर्तित हो जाता है और प्रिंट किया जाता है System.out और report.txt पर मुद्रित। अब तक सब ठीक है।जावा डीएसएल
@WebListener
public class SetupCamel implements ServletContextListener {
private CamelContext camelContext;
@Override
public void contextInitialized(ServletContextEvent sce) {
System.out.println("SetupCamel:contextInitialized - enter");
try {
Context ctx = new InitialContext();
QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("jms/TestConnectionFactory");
camelContext = new DefaultCamelContext();
JmsConfiguration jmsConfiguration = new JmsConfiguration(qcf);
JmsComponent jmsComponent = new JmsComponent(jmsConfiguration);
camelContext.addComponent("jms", jmsComponent);
final XmlJsonDataFormat xmlJsonFormat = new XmlJsonDataFormat();
xmlJsonFormat.setEncoding("UTF-8");
xmlJsonFormat.setForceTopLevelObject(false);
xmlJsonFormat.setTrimSpaces(true);
xmlJsonFormat.setRootName("newRoot");
xmlJsonFormat.setSkipNamespaces(true);
xmlJsonFormat.setRemoveNamespacePrefixes(true);
camelContext.addRoutes(new RouteBuilder() {
public void configure() {
onException(Exception.class)
.to("log:GeneralError?level=ERROR")
.end();
from("jms:queue:TestQueue?concurrentConsumers=1")
.marshal(xmlJsonFormat)
.to("file:/tmp/messages?fileName=report.txt&fileExist=Append")
.to("stream:out")
;
}
});
camelContext.start();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("SetupCamel:contextInitialized - leaving");
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
System.out.println("SetupCamel:contextDestroyed - enter");
try {
if (camelContext != null) {
camelContext.stop();
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("SetupCamel:contextDestroyed - leaving");
}
}
मुझे जेएसओएन को एक आरईएसटी सेवा/उपभोक्ता को पोस्ट करने के लिए प्रवाह का विस्तार करना है। (बाकी संसाधन का परीक्षण और काम करता है ..)
खोज (वेब) दस्तावेज मुझे एक अच्छा/पूरा जावा डीएसएल उदाहरण नहीं देता है जिसे मैं उपयोग करने में सक्षम हूं। मैं क्या मिला के आधार पर, मुझे लगता है कि यह की तरह एक अंत बिंदु जोड़ने के लिए कुछ इसी तरह होना चाहिए:
.to("cxfrs://http://localhost:9080/WebContext/TestResource")
लेकिन यह काम नहीं करता और मैं शरीर के रूप में परिवर्तित JSON सेट करने का तरीका समझते हैं और यह नहीं बनाते हैं एक पोस्ट अनुरोध। कोई अपवाद मुद्रित भी नहीं है।
मैं इस प्रवाह में जेएसओएन बॉडी के साथ एक पोस्ट के रूप में आरईएसटी कॉल कैसे जोड़ सकता हूं?
आईबीएम WebSphere v8.5.5, आईबीएम JDK 1.7x में चल रहा है, कैमल 2.11.2
निम्नलिखित जार फ़ाइलों वेब-INF/lib classpath में कर रहे हैं:
camel-core-2.11.2.jar
camel-cxf-2.11.2.jar
camel-cxf-transport-2.11.2.jar
camel-jms-2.11.2.jar
camel-servletlistener-2.11.2.jar
camel-spring-2.11.2.jar
camel-stream-2.11.2.jar
camel-xmljson-2.11.2.jar
com.ibm.ws.prereq.jackson.jar
commons-beanutils-1.8.0.jar
commons-collections-3.2.1.jar
commons-lang-2.5.jar
commons-logging-1.1.1.jar
cxf-api-2.7.6.jar
cxf-rt-frontend-jaxrs-2.7.6.jar
ezmorph-1.0.6.jar
json-lib-2.4-jdk15.jar
slf4j-api-1.7.5.jar
spring-beans-3.1.4.RELEASE.jar
spring-context-3.1.4.RELEASE.jar
spring-core-3.1.4.RELEASE.jar
spring-jms-3.1.4.RELEASE.jar
spring-tx-3.1.4.RELEASE.jar
xom-1.2.5.jar
धन्यवाद।
यदि आप ऐसा करने का प्रबंधन किया? – geekprogrammer