Author: ningjiang
Date: Tue Jun 10 19:59:37 2008
New Revision: 666509
URL: http://svn.apache.org/viewvc?rev=666509&view=rev
Log:
Added snippet tags for camel-cxf wiki page
Modified:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerRouterTest.java
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonProcessor.java
Modified:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerRouterTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerRouterTest.java?rev=666509&r1=666508&r2=666509&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerRouterTest.java
(original)
+++
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerRouterTest.java
Tue Jun 10 19:59:37 2008
@@ -79,8 +79,10 @@
public void testInvokingSimpleServerWithParams() throws Exception {
+ // START SNIPPET: sending
Exchange senderExchange = new DefaultExchange(context,
ExchangePattern.InOut);
final List<String> params = new ArrayList<String>();
+ // Prepare the request message for the camel-cxf procedure
params.add(TEST_MESSAGE);
senderExchange.getIn().setBody(params);
senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAME,
ECHO_OPERATION);
@@ -88,12 +90,15 @@
Exchange exchange = template.send("direct:EndpointA", senderExchange);
org.apache.camel.Message out = exchange.getOut();
+ // The response message's body is an object array which first element
is the return value of the operation,
+ // If there are some holder parameters, the holder parameter will be
filled in the reset of array.
Object[] output = (Object[])out.getBody();
LOG.info("Received output text: " + output[0]);
Map<String, Object> responseContext =
CastUtils.cast((Map)out.getHeader(Client.RESPONSE_CONTEXT));
assertNotNull(responseContext);
assertEquals("We should get the response context here", "UTF-8",
responseContext.get(org.apache.cxf.message.Message.ENCODING));
assertEquals("Reply body on Camel is wrong", "echo " + TEST_MESSAGE,
output[0]);
+ // END SNIPPET: sending
}
public void testInvokingSimpleServerWithMessageDataFormat() throws
Exception {
Modified:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonProcessor.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonProcessor.java?rev=666509&r1=666508&r2=666509&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonProcessor.java
(original)
+++
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonProcessor.java
Tue Jun 10 19:59:37 2008
@@ -25,33 +25,39 @@
import org.apache.commons.logging.LogFactory;
import org.apache.cxf.message.MessageContentsList;
+// START SNIPPET: personProcessor
public class PersonProcessor implements Processor {
private static final transient Log LOG =
LogFactory.getLog(PersonProcessor.class);
public void process(Exchange exchange) throws Exception {
LOG.info("processing exchange in camel");
-
+ // Get the parameters list which element is the holder.
MessageContentsList msgList =
(MessageContentsList)exchange.getIn().getBody();
Holder<String> personId = (Holder<String>)msgList.get(0);
Holder<String> ssn = (Holder<String>)msgList.get(1);
Holder<String> name = (Holder<String>)msgList.get(2);
if (personId.value == null || personId.value.length() == 0) {
- // only wrote the rubbish above to get into this section
LOG.info("person id 123, so throwing exception");
+ // Try to throw out the soap fault message
org.apache.camel.wsdl_first.types.UnknownPersonFault personFault =
new org.apache.camel.wsdl_first.types.UnknownPersonFault();
personFault.setPersonId("");
org.apache.camel.wsdl_first.UnknownPersonFault fault =
new org.apache.camel.wsdl_first.UnknownPersonFault("Get the
null value of person name", personFault);
+ // Since camel has its own exception handler framework, we can't
throw the exception to trigger it
+ // We just set the fault message in the exchange for camel-cxf
component handling
exchange.getFault().setBody(fault);
}
name.value = "Bonjour";
ssn.value = "123";
LOG.info("setting Bonjour as the response");
+ // Set the response message, first element is the return value of the
operation,
+ // the others are the holders of method parameters
exchange.getOut().setBody(new Object[] {null, personId, ssn, name});
}
}
+// END SNIPPET: personProcessor