Hi ,
I think I found the key of this issue.
It is you bean.xml's definition. If you want to define the value of
simple:[EMAIL PROTECTED] with a spring bean's reference, you need to
use the prefix '#' for the bean's name, and they should be in the same
application context.
If you take the CXF wiki's [1] as an example , you need to put the
contents in the cxf.xml into beans.xml.
Here is an example for it beans.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:simple="http://cxf.apache.org/simple"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://cxf.apache.org/simple
http://cxf.apache.org/schemas/simple.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<bean id="helloService" class="com.comp.HelloWorldImpl">
</bean>
<simple:server id="hello" address="/hello"
serviceClass="com.comp.HelloWorldNew"
serviceBean="#helloService">
</simple:server>
</beans>
[1]http://cwiki.apache.org/CXF20DOC/writing-a-service-with-spring.html
Willem.
mule1 wrote:
Hello Wellem,
I really don't have anything extra on sever side. To make testing this
problem simple, I added the HelloWorld sample code in my server side code
and it just seems that the client code when trying to use it when deployed
on web application gives the error.
The configuration on server side is as follow:
1. --------- I have a cxf.xml which has following:
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:simple="http://cxf.apache.org/simple"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://cxf.apache.org/simple
http://cxf.apache.org/schemas/simple.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<simple:server id="hello" address="/hello"
serviceClass="com.comp.HelloWorldNew"
serviceBean="helloService">
</simple:server>
</beans>
2. ------- I have bean.xml, which has ----------
<bean id="helloService" class="com.comp.HelloWorldImpl">
</bean>
-------------CXF Sample Client changes done to call the HelloWorld service
deployed in tomcat appserv
I also tried updating the sample hello world spring client as follow to test
this from the sample client:
1. Updates to Client.java
public final class Client {
private Client() {
}
public static void main(String args[]) throws Exception {
// START SNIPPET: client
ClassPathXmlApplicationContext context
= new ClassPathXmlApplicationContext(new String[]
{"demo/spring/client/client-beans.xml"});
HelloWorld client = (HelloWorld)context.getBean("client");
// NOTE: If I use this call, I get the error for
"javax.xml.ws.WebServiceException: Could not find operation info for web
method "
//String response = client.sayHi("Joe");
//NOTE: If I use this call, I get the error for "Caused by:
java.lang.IllegalArgumentException: object is not an instance of declaring
class "
ClientProxyFactoryBean cf = new ClientProxyFactoryBean();
cf.setAddress("http://localhost:8080/services/hello");
cf.setServiceClass(HelloWorld.class); // Optionally specify the
service interface
HelloWorld service = (HelloWorld) cf.create();
String test = "Hello World Test in Tomcat appserv";
String response = service.sayHi(test);
System.out.println("Response: " + response);
System.exit(0);
// END SNIPPET: client
}
}
2. Updates to client-beans.java
<bean id="client" class="com.comp.HelloWorldNew"
factory-bean="clientFactory" factory-method="create"/>
<bean id="clientFactory"
class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="com.comp.HelloWorldNew"/>
<property name="address"
value="http://localhost:8080/services/hello"/>
</bean>