如何用xfire做一个webService用jaxb2绑定

我是一个SOA新学者,用xfire的jaxb2绑定做了一个例子,总是报错,也不清楚为什么了!
希望大家多给我一点意见,谢谢!

例子如下:
PO类:
package com.xxx.services;

import java.io.Serializable;

public class User implements Serializable {
	private String name;
	private int age;
	
	public int getAge() {
		return age;
	}
	......//getter() or setter();
}


Service Interface类:
package com.xxx.services;

import java.util.List;

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService(name="UserServiceIntf", targetNamespace="http://www.webservicex.net")
public interface UserService {
	@WebMethod
	public User getUser();
	@WebMethod
	public List getUsers();
}


Service Interface Implement类:
package com.xxx.services;

import java.util.List;
import java.util.Vector;

import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
@WebService(endpointInterface="org.codehaus.xfire.jaxb.UserService", serviceName="UserService")
@SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE)
public class UserServiceImpl implements UserService {
	public User getUser(){
		User user = new User("tom",23);
		return user;
	}
	public List getUsers(){
		List list=new Vector();
		User user1 = new User("tom",23);
		User user2 = new User("jerry",26);
		list.add(user1);
		list.add(user2);
		return list;
	}
}


src\META-INF\xfire\services.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xfire.codehaus.org/config/1.0">
    <service>
    	<name>UserService</name>
    	<namespace>http://com.xxx.services/UserService</namespace>
    	<serviceBean>com.xxx.services.UserServiceImpl</serviceBean>
		<serviceFactory>#jaxbServiceFactory</serviceFactory>
    </service>
    
    <bean name="jaxbServiceFactory" class="org.codehaus.xfire.jaxb2.JaxbServiceFactory">
    	<constructor-arg ref="xfire.transportManager"/>
  	</bean>
</beans>


web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 
	xmlns="http://java.sun.com/xml/ns/j2ee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
	http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

	<servlet>
         <servlet-name>XFireServlet</servlet-name>
         <servlet-class>
                 org.codehaus.xfire.transport.http.XFireConfigurableServlet
         </servlet-class>
     </servlet>
     
     <servlet-mapping>
         <servlet-name>XFireServlet</servlet-name>
         <url-pattern>/servlet/XFireServlet/*</url-pattern>
     </servlet-mapping>
 
     <servlet-mapping>
         <servlet-name>XFireServlet</servlet-name>
          <url-pattern>/services/*</url-pattern>
     </servlet-mapping>
</web-app>


报如下错误:
exception 

javax.servlet.ServletException: Error initializing XFireServlet.
	org.codehaus.xfire.transport.http.XFireServlet.init(XFireServlet.java:50)
	javax.servlet.GenericServlet.init(GenericServlet.java:211)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
	org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
	org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
	org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
	java.lang.Thread.run(Thread.java:595)


root cause 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.codehaus.xfire.spring.ServiceBean' defined in class path resource [META-INF/xfire/services.xml]: Initialization of bean failed; nested exception is org.codehaus.xfire.annotations.AnnotationException: Class javax.xml.namespace.QName does not have a WebService annotation
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:370)
	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:275)
	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:320)


在xfire的官网上看好象还需要一个.xsd,然后再配到services.xml中,我也试了!错误一样!
希望大家可以帮我一下,看看什么问题,给点意见!最好说的具体点,谢谢!

你可能感兴趣的:(java,apache,tomcat,xml,webservice)