camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: How to invoke CXF webservice from processor bean
Date Sat, 28 Jul 2012 01:23:05 GMT
Yeah, this example is setting the right headers on the message which is 
passed by the exchange.

On Sat Jul 28 06:17:56 2012, ychawla wrote:
> I have something like this working in a unit test.  Maybe you can try
> something similar:
>
> 	public static final String CXF_OPERATION_NAME = "operation";
> 	public static final String CXF_OPERATION_NAMESPACE = "http://opNamespace";
>
> 	@Test
> 	@DirtiesContext
>      public void myTest() throws Exception
>      {
>
>      	String
> pathToFileForExchangeBody="src/test/resources/xmlInstances/mypayload.xml";
>      	
>      	Exchange senderExchange = createCXFExchange(pathToFileForExchangeBody);
> 	
> 	//Send the one-way exchange.  Using template.send will send a one way
> message
>         Exchange returnExchange =
> template.send("cxf:bean:mybean?dataFormat=PAYLOAD&loggingFeatureEnabled=true&synchronous=true",
> senderExchange);
> 		
> 		//Use getException to see if we received an exception
> 		if (returnExchange.getException() != null)
> 		{	
> 			throw new Exception(returnExchange.getException());
> 		}	
>      }
>
>      private Exchange createCXFExchange(String pathToFileForExchangeBody)
>      {
>      	//Create a new exchange
>      	Exchange senderExchange = new DefaultExchange(context);
> 		
> 	//Set the operation name and operation namespace for the CXF exchange
> 	    senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAME,
> CXF_OPERATION_NAME);
> 	    senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAMESPACE,
> CXF_OPERATION_NAMESPACE);
> 	
> 	    //Read the icotns request file from the file system, this one has no
> endpoint to route to
> 	    File inputFile = new File(pathToFileForExchangeBody);
> 	
> 	    assertTrue(inputFile.exists());
> 	    log.debug("Does input file exist: " + inputFile.exists());
> 	
> 	    //Set it as the message message body
> 	    senderExchange.getIn().setBody(inputFile);
> 	
> 	    return senderExchange;
>
>      }
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-invoke-CXF-webservice-from-processor-bean-tp5716272p5716569.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang


Mime
View raw message