webservice--知识点

webservice

<!-- begin XFire 配置 -->
    <servlet>
        <servlet-name>xfire</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/classes/conf/xfire/xfire-servlet.xml</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>xfire</servlet-name>
        <url-pattern>*.ws</url-pattern>
    </servlet-mapping>
    <!-- end XFire 配置 -->

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans><!-- 引入XFire预配置信息 -->
    <import resource="classpath:org/codehaus/xfire/spring/xfire.xml" />
    <bean id="baseWebService"
        class="org.codehaus.xfire.spring.remoting.XFireExporter"
        lazy-init="false" abstract="true">
        <!-- 引用xfire.xml中定义的工厂 -->
        <property name="serviceFactory"   ref="xfire.serviceFactory" />
        <!-- 引用xfire.xml中的xfire实例 -->
        <property name="xfire" ref="xfire" />
    </bean>
    <!-- 定义访问发送数据的服务 -->
    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="urlMap">
            <map>
           
               
                <entry key="/jptMobileAttachment.ws">
                    <ref bean="JptMobileAttachmentService" />
                </entry>
              
            </map>
        </property>
    </bean>
   
    <bean id="JptMobileAttachmentService" parent="baseWebService">
        <!-- 业务服务bean -->
        <property name="serviceBean" ref="jptMobileAttachmentWSService" />
        <!-- 业务服务bean的窄接口类 -->
        <property name="serviceClass" value="com.attachment.webservice.IAttachmentWebService" />
    </bean>

</beans>

客户端调用

Service ser = new ObjectServiceFactory().create(IJsoMobileEmailWSService.class);
                XFireProxyFactory xFactory = new XFireProxyFactory(XFireFactory.newInstance().getXFire());
                // ms与服务器端交互复杂对象类型
                IJsoMobileEmailWSService ms = (IJsoMobileEmailWSService) xFactory.create(ser, url);
                String message = ms.sendEmailAndFTPfile(obj.toString());

整合spring

org.codehaus.xfire.spring.XFireSpringServlet

https://www.cnblogs.com/zhangrumingbj/p/3884753.html

原文地址:https://www.cnblogs.com/jentary/p/11459803.html