今天按照网上搜的教程做axis2与spring整合,遇到如下问题:
开始时services.xml配置如下:
<service name="LessonAction">
<!-- <parameter name="ServiceClass">test.service.ServiceOne</parameter> -->
<parameter name="SpringBeanName">serviceOne</parameter>
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</messageReceivers>
</service>
启动访问wsdl文档,生成的文档<wsdl:types>是空的,就是没有operation,时下面这样
<?xml version="1.0" encoding="UTF-8"?>
-<wsdl:definitions targetNamespace="http://ws.apache.org/axis2" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ws.apache.org/axis2">
<wsdl:documentation>LessonAction</wsdl:documentation>
<wsdl:types/>
<wsdl:portType name="LessonActionPortType"/>
-<wsdl:binding name="LessonActionSoap11Binding" type="tns:LessonActionPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
</wsdl:binding>
-<wsdl:binding name="LessonActionSoap12Binding" type="tns:LessonActionPortType">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
</wsdl:binding>
-<wsdl:binding name="LessonActionHttpBinding" type="tns:LessonActionPortType">
<http:binding verb="POST"/>
</wsdl:binding>
-<wsdl:service name="LessonAction">
-<wsdl:port name="LessonActionHttpSoap11Endpoint" binding="tns:LessonActionSoap11Binding">
<soap:address location="http://localhost:8080/ImageTransport/services/LessonAction.LessonActionHttpSoap11Endpoint/"/>
</wsdl:port>
-<wsdl:port name="LessonActionHttpSoap12Endpoint" binding="tns:LessonActionSoap12Binding">
<soap12:address location="http://localhost:8080/ImageTransport/services/LessonAction.LessonActionHttpSoap12Endpoint/"/>
</wsdl:port>
-<wsdl:port name="LessonActionHttpEndpoint" binding="tns:LessonActionHttpBinding">
<http:address location="http://localhost:8080/ImageTransport/services/LessonAction.LessonActionHttpEndpoint/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
后来在bean配置里加上<bean id="applicationContext" class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder"/>
services.xml加上
<parameter name="ServiceObjectSupplier" locked="false">
org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
</parameter>
注意这里老的版本是org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier,否则会报Spring context file cannot be located for AxisServlet的错误。
问题解决!!!,在此记录下
网上查到它的功能是通过ServiceObjectSupplier参数指定SpringServletContextObjectSupplier类来获得Spring的ApplicationContext对象