Axis 2でSpringのアセンブリJavaBeanをWebServiceにリリース
3151 ワード
サービスの実装クラス
コンパイルしたclassをwebappsaxis 2WEB-INFclassesディレクトリに入れ、classが多い場合はjarパッケージとしてWEB-INFlibの下に置くこともできます
springBeanのアプリケーションContextファイルの作成
axis 2のwebでxmlにcontextloadlistenerを追加してspringプロファイルをloadする
サービスを作成します.xmlはMETA-INFファイルに入れてarrパッケージにします.ここではclassファイルを入力する必要はありません.services.xmlプロファイルでOK
ここでは主に2つのparameterが必要です.1つはServiceObjectSupplierです.私たちはorgを使っています.apache.axis2.extensions.spring.receivers.Spring ServiceletContextObjectSupplierこのsupplierはspringを取得するためのアプリケーションContext.
もう一つのparameterはSpringBeanNameは私たちのサービスの実装クラスspringContextのBean idです.
最後にspring関連jarパッケージをaxis 2/web-inf/libのディレクトリの下に置くことを忘れないでください.
このようなspring beanベースのサービスがリリースされます.
public class SpringBeanTest {
public String getWeatherReport(String city) {
return city + " weather is very hot currently";
}
}
コンパイルしたclassを
springBeanのアプリケーションContextファイルの作成
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="springService" class="com.bank.webservice.SpringBeanTest">
</bean>
</beans>
axis 2のwebでxmlにcontextloadlistenerを追加してspringプロファイルをloadする
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
サービスを作成します.xmlはMETA-INFファイルに入れてarrパッケージにします.ここではclassファイルを入力する必要はありません.services.xmlプロファイルでOK
<service name="springService">
<description>
Spring aware
</description>
<parameter name="ServiceObjectSupplier">
org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
</parameter>
<parameter name="SpringBeanName">
springService
</parameter>
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</messageReceivers>
</service>
ここでは主に2つのparameterが必要です.1つはServiceObjectSupplierです.私たちはorgを使っています.apache.axis2.extensions.spring.receivers.Spring ServiceletContextObjectSupplierこのsupplierはspringを取得するためのアプリケーションContext.
もう一つのparameterはSpringBeanNameは私たちのサービスの実装クラスspringContextのBean idです.
最後にspring関連jarパッケージをaxis 2/web-inf/libのディレクトリの下に置くことを忘れないでください.
このようなspring beanベースのサービスがリリースされます.