camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eholsinger <eric.holsin...@metronaviation.com>
Subject xmljson convert XML from file to JSON straight into MongoDB issue
Date Thu, 14 Nov 2013 13:51:55 GMT
Hi,

Found this link on the web and thought I'd try it, seems straightforward
enough, but I haven't gotten it to work yet: 
http://www.andreagirardi.it/blog/route-a-message-to-mongodb/


What i include in this post is:
-my full camel-context.xml
-the XML directly from the file i'm trying to push into mongo with the route
described
-the JSON from a xmljson file > file route that does work

Any insight would be appreciated.

Thx, Eric



*My camel-context.xml file:*
<?xml version="1.0" encoding="UTF-8"?>


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">


  <camel:camelContext id="camelContext"
xmlns="http://camel.apache.org/schema/spring">
  
  	
  	<dataFormats>
		<xmljson id="xmljsonWithOptions" forceTopLevelObject="true"
skipWhitespace="true" trimSpaces="true" skipNamespaces="true"
        	removeNamespacePrefixes="true"/>  
	</dataFormats> 

        
        <route>
  	  <from uri="file:/C:/____temp/xmlfiles?noop=true"/>
    	  <marshal ref="xmljsonWithOptions"/>   	
    	  <to
uri="file:/C:/____temp/jsonfiles?fileName=${file:name.noext}_${date:now:MMddyyyy_HHmmss}.json"
/> 
	</route> 
	
	
        
 	<route> 
  	  <from uri="file:/C:/____temp/xmlfiles?noop=true"/>
    	  <marshal ref="xmljsonWithOptions"/>		
	  <convertBodyTo type="java.lang.String"/> 				
	   <to
uri="mongodb:myDb?database=test&amp;collection=aixm&amp;operation=save" />
	</route>      
    
  </camel:camelContext>

  	
	<bean id="myDb" class="com.mongodb.Mongo">
		<constructor-arg index="0" value="localhost"/>
	</bean>


</beans>


*The XML from the file:*
<root><aps><alert>this is a test
message</alert></aps><key3>value3</key3><key2>value2</key2><key1>value1</key1></root>

*The JSON from the file > file route that does work:*
{"root":{"aps":["this is a
testmessage"],"key3":"value3","key2":"value2","key1":"value1"}}




--
View this message in context: http://camel.465427.n5.nabble.com/xmljson-convert-XML-from-file-to-JSON-straight-into-MongoDB-issue-tp5743285.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message