I am trying to have my jax-ws client (using Apache CXF) injected via the @WebServiceRef. I have gone through the following steps:
1. Generated the stubs from the WSDL.
2. Created the following <jaxws:client> entry in my applicationContext.xml on the Interface generated through the WSDL.
3. Inserted an @WebServiceRef annotation to inject the web service.
This isn't working and I am getting an exception saying that the Bean is not of the required type, and that it should be of type javax.xml.ws.Service. What am I doing wrong?
The following is my code snippet.
applicationContext.xml
MyClient.javaCode:<?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"> <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 class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor"/> <jaxws:client id="myService" serviceClass="mt.com.go.springtest.MyService" address="http://localhost:8080/MyService" name="myService"/> <bean class="example.MyClient" name="myClient" /> </beans>
Exception stacktrace:Code:public class MyClient { @WebServiceRef MyService myService; ...
Code:Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'myService' must be of type [javax.xml.ws.Service], but was actually of type [$Proxy62] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:348) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) ...


Reply With Quote
