xFireとSpringの結合例

4482 ワード

XFire 1.2.6
 
公式網上からxfire-distriction-1.2.6.zipをダウンロードして、当地の解凍後にXFireコンパイルのパッケージ化されたファイルxfire-all-1.2.jarをダウンロードします.libディレクトリの下ではXFireに依存する第三者Jarファイルです.開発時に使用できます.また、マニュアルといくつかの例が含まれます.Eclipseにユーザーライブラリを作って、xfire-all-1.2.jarとXFireに依存する第三者Jarファイルを全部含めてください.
 
XFireSpringというTomcatプロジェクトを構築します.中のspringの例を使います.
 
WEB-INFフォルダ下web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- START SNIPPET: xfire -->
	<!--xfire   classpath:org/codehaus/xfire/spring/xfire.xml-->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
        <!--classpath:org/codehaus/xfire/spring/xfire.xml  -->
    </context-param>

    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/log4j.properties</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

	<!--   Spring   XFire     Servlet-->
    <servlet>
        <servlet-name>xfire</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>xfire</servlet-name>
        <url-pattern>/services/*</url-pattern><!--    URI   Web Service   -->
    </servlet-mapping>
<!-- END SNIPPET: xfire -->
</web-app>
 
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>
	<!--   XFire      -->
	<import resource="classpath:org/codehaus/xfire/spring/xfire.xml"/>

    <!-- START SNIPPET: xfire -->
    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="urlMap">
            <map>
                <entry key="/EchoService"><!--     http://127.0.0.1:8080/XFireSpring/services/EchoService?wsdl -->
                    <ref bean="echo"/>
                </entry>
            </map>
        </property>
    </bean>

    <!-- Declare a parent bean with all properties common to both services -->
    <bean id="echo" class="org.codehaus.xfire.spring.remoting.XFireExporter">
    	<!--   xfire.xml       -->
        <property name="serviceFactory">
            <ref bean="xfire.serviceFactory"/>
        </property>
        <!--   xfire.xml  xfire   -->
        <property name="xfire">
            <ref bean="xfire"/>
        </property>
        <property name="serviceBean">
            <ref bean="echoBean"/>
        </property>
        <property name="serviceClass">
            <value>org.codehaus.xfire.spring.example.Echo</value>
        </property>
    </bean>

    <bean id="echoBean" class="org.codehaus.xfire.spring.example.EchoImpl"/>

    <!-- END SNIPPET: xfire -->
</beans>
詳細は添付ファイルを見てください
 
http://127.0.0.1:8080/XFireSpring/services/EchoService?wdl