You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "vs.souza" <vs...@gmail.com> on 2012/04/04 02:07:39 UTC

CXFRS to consume OSVDB Restful APIs

Hello Friends,

I am trying to use CXFRS to consume the OSVDB Vulnerability Database API but
things doesn't seem to work out. First problem is that it complains that
there is no cxf.xml under META-INF/cxf. I tried to add this file but it is
not working yet (if I add the file it complains that I should declare beans
there). And I get the following errors if I don't add the file:

21:00:00,453 | INFO  | camel-9_Worker-1 | alidationXmlBeanDefinitionReader |
66 - org.springframework.beans - 3.0.6.RELEASE | Loading XML bean
definitions from class path resource [META-INF/cxf/cxf.xml]
21:00:00,456 | WARN  | camel-9_Worker-1 | SpringBusFactory                 |
137 - org.apache.cxf.bundle - 2.4.4 | Initial attempt to create application
context was unsuccessful.
org.springframework.beans.factory.BeanDefinitionStoreException: IOException
parsing XML document from class path resource [META-INF/cxf/cxf.xml]; nested
exception is java.io.FileNotFoundException: class path resource
[META-INF/cxf/cxf.xml] cannot be opened because it does not exist
	at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)


----------------------------------------------------------------------------------------------------------------------


21:00:01,085 | WARN  | camel-9_Worker-1 | PhaseInterceptorChain            |
137 - org.apache.cxf.bundle - 2.4.4 | Interceptor for
{http://osvdb.org/api/vulns_added_since_osvdb_id/i3z5onUTaayfLBzjXtZ5epLlWf/}WebClient
has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: .No message body writer has been found for
class : class org.springframework.util.LinkedCaseInsensitiveMap, ContentType
: application/xml.

The restful service URL I am trying to consume is this:

http://osvdb.org/api/vulns_added_since_osvdb_id/i3z5onUTaayfLBzjXtZ5epLlWf/?osvdb_id=78316

And this is my camel route:


<?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"
       xmlns:cxf="http://camel.apache.org/schema/cxf"
       xmlns:jaxrs="http://cxf.apache.org/jaxrs"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
       http://camel.apache.org/schema/cxf
http://camel.apache.org/schema/cxf/camel-cxf.xsd
       http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">

  <bean id="sql" class="org.apache.camel.component.sql.SqlComponent">
	<property name="dataSource" ref="osvdbDS" />
  </bean>

  <bean id="osvdbDS" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
	<property name="driverClassName" value="com.mysql.jdbc.Driver" />
	<property name="url" value="jdbc:mysql://localhost:3306/osvdb" />
	<property name="username" value="root"/>
	<property name="password" value="mysql"/>
  </bean>

  <camelContext xmlns="http://camel.apache.org/schema/spring" trace="false">
    <package>com.test.general.osvdb.service</package>
    <route>
      <camel:from
uri="quartz://generalDS/osvdbUpdateTimer?cron=0+*+*+*+*+?"/>
      <camel:to uri="sql:SELECT max(osvdb_id) FROM
`osvdb`.`vulnerabilities`?dataSourceRef=osvdbDS"/>
      <camel:to
uri="cxfrs://http://osvdb.org/api/vulns_added_since_osvdb_id/i3z5onUTaayfLBzjXtZ5epLlWf/?osvdb_id=78316"/>
      <camel:to uri="log:org.osvdb.update?level=WARN"/>
      
      
    </route>
  </camelContext>

</beans>

I already tried to follow the camel-cxfrs documentation without success and
couldn't find an example from camel examples folder.

Do you have any ideas about where I can find a solution or a full example to
follow?

Thanks and regards.

--
View this message in context: http://camel.465427.n5.nabble.com/CXFRS-to-consume-OSVDB-Restful-APIs-tp5616658p5616658.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXFRS to consume OSVDB Restful APIs

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 04/04/12 03:07, vs.souza wrote:
> Hello Friends,
>
> I am trying to use CXFRS to consume the OSVDB Vulnerability Database API but
> things doesn't seem to work out. First problem is that it complains that
> there is no cxf.xml under META-INF/cxf. I tried to add this file but it is
> not working yet (if I add the file it complains that I should declare beans
> there). And I get the following errors if I don't add the file:
>
> 21:00:00,453 | INFO  | camel-9_Worker-1 | alidationXmlBeanDefinitionReader |
> 66 - org.springframework.beans - 3.0.6.RELEASE | Loading XML bean
> definitions from class path resource [META-INF/cxf/cxf.xml]
> 21:00:00,456 | WARN  | camel-9_Worker-1 | SpringBusFactory                 |
> 137 - org.apache.cxf.bundle - 2.4.4 | Initial attempt to create application
> context was unsuccessful.
> org.springframework.beans.factory.BeanDefinitionStoreException: IOException
> parsing XML document from class path resource [META-INF/cxf/cxf.xml]; nested
> exception is java.io.FileNotFoundException: class path resource
> [META-INF/cxf/cxf.xml] cannot be opened because it does not exist
> 	at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
>

I wonder if you need to import cxf.xml given it is CXF 2.4.4

<import resource="classpath:META-INF/cxf/cxf.xml"/>,
that might help

Cheers, Sergey

>
> ----------------------------------------------------------------------------------------------------------------------
>
>
> 21:00:01,085 | WARN  | camel-9_Worker-1 | PhaseInterceptorChain            |
> 137 - org.apache.cxf.bundle - 2.4.4 | Interceptor for
> {http://osvdb.org/api/vulns_added_since_osvdb_id/i3z5onUTaayfLBzjXtZ5epLlWf/}WebClient
> has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: .No message body writer has been found for
> class : class org.springframework.util.LinkedCaseInsensitiveMap, ContentType
> : application/xml.
>
> The restful service URL I am trying to consume is this:
>
> http://osvdb.org/api/vulns_added_since_osvdb_id/i3z5onUTaayfLBzjXtZ5epLlWf/?osvdb_id=78316
>
> And this is my camel route:
>
>
> <?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"
>         xmlns:cxf="http://camel.apache.org/schema/cxf"
>         xmlns:jaxrs="http://cxf.apache.org/jaxrs"
>         xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>         http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd
>         http://camel.apache.org/schema/cxf
> http://camel.apache.org/schema/cxf/camel-cxf.xsd
>         http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
>
>    <bean id="sql" class="org.apache.camel.component.sql.SqlComponent">
> 	<property name="dataSource" ref="osvdbDS" />
>    </bean>
>
>    <bean id="osvdbDS" class="org.apache.commons.dbcp.BasicDataSource"
> destroy-method="close">
> 	<property name="driverClassName" value="com.mysql.jdbc.Driver" />
> 	<property name="url" value="jdbc:mysql://localhost:3306/osvdb" />
> 	<property name="username" value="root"/>
> 	<property name="password" value="mysql"/>
>    </bean>
>
>    <camelContext xmlns="http://camel.apache.org/schema/spring" trace="false">
>      <package>com.test.general.osvdb.service</package>
>      <route>
>        <camel:from
> uri="quartz://generalDS/osvdbUpdateTimer?cron=0+*+*+*+*+?"/>
>        <camel:to uri="sql:SELECT max(osvdb_id) FROM
> `osvdb`.`vulnerabilities`?dataSourceRef=osvdbDS"/>
>        <camel:to
> uri="cxfrs://http://osvdb.org/api/vulns_added_since_osvdb_id/i3z5onUTaayfLBzjXtZ5epLlWf/?osvdb_id=78316"/>
>        <camel:to uri="log:org.osvdb.update?level=WARN"/>
>
>
>      </route>
>    </camelContext>
>
> </beans>
>
> I already tried to follow the camel-cxfrs documentation without success and
> couldn't find an example from camel examples folder.
>
> Do you have any ideas about where I can find a solution or a full example to
> follow?
>
> Thanks and regards.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXFRS-to-consume-OSVDB-Restful-APIs-tp5616658p5616658.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: CXFRS to consume OSVDB Restful APIs

Posted by "vs.souza" <vs...@gmail.com>.
Thanks for the help.

I added the import and this error is gone. Thanks again, my friends.

Willen.Jiang... I followed your advice and decided to use camel-restlet to
send a request against the server. I have to bind the XML answer to a couple
of java objects. How can I do that with camel-restlet? Should I use a bean
with a couple of xqueries? Can I do that automatically with cxfrs?

Thanks and my best regards.

--
View this message in context: http://camel.465427.n5.nabble.com/CXFRS-to-consume-OSVDB-Restful-APIs-tp5616658p5617869.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXFRS to consume OSVDB Restful APIs

Posted by Willem Jiang <wi...@gmail.com>.
Hi

If you just want to send a RESTFul request to server, you can use the 
camel-http component directly.
Back to the issue of "META-INF/cxf/cxf.xml]", did your bundle imports 
package of "META-INF.cxf" ?

On Wed Apr  4 08:07:39 2012, vs.souza wrote:
> Hello Friends,
>
> I am trying to use CXFRS to consume the OSVDB Vulnerability Database API but
> things doesn't seem to work out. First problem is that it complains that
> there is no cxf.xml under META-INF/cxf. I tried to add this file but it is
> not working yet (if I add the file it complains that I should declare beans
> there). And I get the following errors if I don't add the file:
>
> 21:00:00,453 | INFO  | camel-9_Worker-1 | alidationXmlBeanDefinitionReader |
> 66 - org.springframework.beans - 3.0.6.RELEASE | Loading XML bean
> definitions from class path resource [META-INF/cxf/cxf.xml]
> 21:00:00,456 | WARN  | camel-9_Worker-1 | SpringBusFactory                 |
> 137 - org.apache.cxf.bundle - 2.4.4 | Initial attempt to create application
> context was unsuccessful.
> org.springframework.beans.factory.BeanDefinitionStoreException: IOException
> parsing XML document from class path resource [META-INF/cxf/cxf.xml]; nested
> exception is java.io.FileNotFoundException: class path resource
> [META-INF/cxf/cxf.xml] cannot be opened because it does not exist
> 	at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
>
>
> ----------------------------------------------------------------------------------------------------------------------
>
>
> 21:00:01,085 | WARN  | camel-9_Worker-1 | PhaseInterceptorChain            |
> 137 - org.apache.cxf.bundle - 2.4.4 | Interceptor for
> {http://osvdb.org/api/vulns_added_since_osvdb_id/i3z5onUTaayfLBzjXtZ5epLlWf/}WebClient
> has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: .No message body writer has been found for
> class : class org.springframework.util.LinkedCaseInsensitiveMap, ContentType
> : application/xml.
>
> The restful service URL I am trying to consume is this:
>
> http://osvdb.org/api/vulns_added_since_osvdb_id/i3z5onUTaayfLBzjXtZ5epLlWf/?osvdb_id=78316
>
> And this is my camel route:
>
>
> <?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"
>         xmlns:cxf="http://camel.apache.org/schema/cxf"
>         xmlns:jaxrs="http://cxf.apache.org/jaxrs"
>         xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>         http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd
>         http://camel.apache.org/schema/cxf
> http://camel.apache.org/schema/cxf/camel-cxf.xsd
>         http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
>
>    <bean id="sql" class="org.apache.camel.component.sql.SqlComponent">
> 	<property name="dataSource" ref="osvdbDS" />
>    </bean>
>
>    <bean id="osvdbDS" class="org.apache.commons.dbcp.BasicDataSource"
> destroy-method="close">
> 	<property name="driverClassName" value="com.mysql.jdbc.Driver" />
> 	<property name="url" value="jdbc:mysql://localhost:3306/osvdb" />
> 	<property name="username" value="root"/>
> 	<property name="password" value="mysql"/>
>    </bean>
>
>    <camelContext xmlns="http://camel.apache.org/schema/spring" trace="false">
>      <package>com.test.general.osvdb.service</package>
>      <route>
>        <camel:from
> uri="quartz://generalDS/osvdbUpdateTimer?cron=0+*+*+*+*+?"/>
>        <camel:to uri="sql:SELECT max(osvdb_id) FROM
> `osvdb`.`vulnerabilities`?dataSourceRef=osvdbDS"/>
>        <camel:to
> uri="cxfrs://http://osvdb.org/api/vulns_added_since_osvdb_id/i3z5onUTaayfLBzjXtZ5epLlWf/?osvdb_id=78316"/>
>        <camel:to uri="log:org.osvdb.update?level=WARN"/>
>
>
>      </route>
>    </camelContext>
>
> </beans>
>
> I already tried to follow the camel-cxfrs documentation without success and
> couldn't find an example from camel examples folder.
>
> Do you have any ideas about where I can find a solution or a full example to
> follow?
>
> Thanks and regards.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXFRS-to-consume-OSVDB-Restful-APIs-tp5616658p5616658.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