XFire的简单配置

        有段时间业务需要webservice,所以弄了下XFire,发现这个工具真的很傻瓜,接下来我就把如何配置详细的说一下。
        首先要引入相关的jar包,jar包我就不再这里列表了,童鞋们自己去下吧,呵呵,我用的版本是1.2.6,所以我只能保证在1.2.6下运行是正常的。
        其次,请打开你的web.xml在里面添加一个servlet并将xfile的配置说明加入进去
    <context-param>
        
<param-name>contextConfigLocation</param-name>
        
<param-value>classpath*:config/spring/*.xml
                     classpath:org/codehaus/xfire/spring/xfire.xml
        
</param-value>
    
</context-param>

        
1    <servlet>
2        <servlet-name>xfire</servlet-name>
3        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
4    </servlet>
5
6    <servlet-mapping>
7        <servlet-name>xfire</servlet-name>
8        <url-pattern>/ws/*</url-pattern>
9    </servlet-mapping>
        请在WEB-INF下添加一个xfire-servlet.xml文件,具体内容如下
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>

    
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        
<property name="urlMap">
            
<map>
                
<entry key="/netsuiteservice">
                    
<ref bean="netSuiteServiceCXF"/>
                
</entry>
            
</map>
        
</property>
    
</bean>
    
    
<bean id="netSuiteServiceCXF" class="org.codehaus.xfire.spring.remoting.XFireExporter">
        
<property name="serviceFactory">
            
<ref bean="xfire.serviceFactory"/>
        
</property>
        
<property name="xfire">
            
<ref bean="xfire"/>
        
</property>
        
<property name="serviceBean">
            
<ref bean="netSuiteService"/>
        
</property>
        
<property name="serviceClass">
            
<value>com.akazam.ws.INetSuiteService</value>
        
</property>
    
</bean>

</beans>
        大家看看就明白了,这里就是定义service的地方,你要发布的service的配置说明
       
 1<?xml version="1.0" encoding="UTF-8"?>
 2<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3    xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core"
 4    xsi:schemaLocation="http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
 5    default-lazy-init="true">
 6
 7    <description>Apache CXF的Web Service配置</description>
 8    <!-- WebService的实现Bean定义 -->
 9     <bean id="netSuiteService" class="com.akazam.ws.impl.NetSuiteServiceImpl"/>
10</beans>

接下来你只需要实现相关的接口就可以了


posted on 2011-04-06 11:13 Cloud kensin 阅读(404) 评论(0)  编辑  收藏 所属分类: 其他


只有注册用户登录后才能发表评论。


网站导航:
 
<2011年4月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

导航

统计

常用链接

留言簿(4)

随笔分类

相册

相册

搜索

最新评论