camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abhi <iloveabhi...@rediffmail.com>
Subject How to call CXF web service from Camel
Date Fri, 22 Mar 2013 15:21:02 GMT
Hi All,
I am new to Apache Camel and I am trying to call CXF web service from Camel.

Here is my camel-context.xml
----------------------------------
	<route id="test3">
	    
	    <from uri="stream:in?promptMessage=Enter Something:"/>
            <to uri="cxf:bean:HelloService"/>
	    <to uri="bean:myBean?method=myMethod"/>
      
	</route>

	</camel:camelContext>

    <cxf:cxfEndpoint id="HelloService" 
    address="http://localhost:8080/HelloWeb/Hello"
    wsdlURL="http://localhost:8080/HelloWeb/Hello?wsdl"
    serviceClass="com.server.HelloFirst" 
    />
     
    <bean id="myBean" class="org.test.MyBean"/>

</beans>


Below are the source code of my web service 
HelloFirst.java
----------------------------------------------
package com.server;

import javax.jws.WebService;

@WebService
public interface HelloFirst {
	public String myHello(String str);
}


HelloFirstImpl.java
----------------------------------------------
package com.server;

import javax.jws.WebService;

@WebService(endpointInterface = "com.server.HelloFirst")
public class HelloFirstImpl {
	public String myHello(String str){
		return "HelloFirstImpl: Hello :"+str;
	}
}


cxf.xml
-----------------------------------------
<?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:jaxws="http://cxf.apache.org/jaxws"
    xsi:schemaLocation="
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
    
    <jaxws:endpoint id="Hello"
        implementor="com.server.HelloFirstImpl" address="/Hello" />

</beans>



Using a java client I am able to invoke above web service but when I try to
do it through Camel it gives me following error:

Exception in thread "main"
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'HelloService': Initialization of bean failed; nested exception is
org.springframework.beans.TypeMismatchException: Failed to convert property
value of type 'java.lang.String' to required type 'java.lang.Class' for
property 'serviceClass'; nested exception is
java.lang.IllegalArgumentException: Cannot find class
[com.server.HelloFirst]
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:526)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
	at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
	at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
	at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
	at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
	at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
	at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
	at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
	at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
	at
org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:186)
	at org.apache.camel.spring.Main.doStart(Main.java:140)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
	at org.apache.camel.main.MainSupport.run(MainSupport.java:141)
	at org.test.CamelFirstCXF.main(CamelFirstCXF.java:30)
Caused by: org.springframework.beans.TypeMismatchException: Failed to
convert property value of type 'java.lang.String' to required type
'java.lang.Class' for property 'serviceClass'; nested exception is
java.lang.IllegalArgumentException: Cannot find class
[com.server.HelloFirst]
	at
org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:486)
	at
org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:518)
	at
org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:512)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1373)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1332)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1085)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:516)
	... 15 more
Caused by: java.lang.IllegalArgumentException: Cannot find class
[com.server.HelloFirst]
	at
org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:293)
	at
org.springframework.beans.propertyeditors.ClassEditor.setAsText(ClassEditor.java:63)
	at
org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:421)
	at
org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:393)
	at
org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:161)
	at
org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:466)
	... 21 more
Caused by: java.lang.ClassNotFoundException: com.server.HelloFirst
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at org.springframework.util.ClassUtils.forName(ClassUtils.java:257)
	at
org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:290)
	... 26 more
Mar 22, 2013 8:25:29 PM org.apache.camel.main.MainSupport$HangupInterceptor
run
INFO: Received hang up - stopping the main instance.




*******************************

Can you let me know what exactly I am doing wrong? I am new to Camel so
facing lot of issues.
I did lot of googling but not able to get it running.

Thanks in advance !!!!!

Regards,
Abhijit 



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-call-CXF-web-service-from-Camel-tp5729692.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message