axis2 结合spring 创建 服务端
首先导入axis2和spring所需的jar包,这里不再多说。
其次创建/WEB-INF/services/module-name/META-INF/services.xml(module-name可任意,目录结构需维持成这样)这样的目录结构。
services.xml内容如下
<serviceGroup> <!-- 服务名称 --> <service name="demoService"> <parameter name="ServiceObjectSupplier">org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier</parameter> <!-- 服务对应的spring bean --> <parameter name="SpringBeanName">demoService</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> <!--multiple action --> <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" /> <!--multiple action --> </service> </serviceGroup>
web.xml修改如下:
<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> <!-- axis2 begin --> <servlet> <servlet-name>AxisServlet</servlet-name> <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>AxisServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping> <!-- axis2 end -->
通过访问WSDL可以从http://server-ip-name:port/application-name/services/services-name?wsdl可以得到生成的wsdl。
相关推荐
yupi0 2020-10-10
spring 2020-08-18
编程点滴 2020-07-29
幸运小侯子 2020-07-05
itjavashuai 2020-07-04
qingjiuquan 2020-06-29
shushan 2020-06-25
小鱿鱼 2020-06-22
咻pur慢 2020-06-18
melonjj 2020-06-17
qingjiuquan 2020-06-13
neweastsun 2020-06-05
小鱿鱼 2020-06-05
mxcsdn 2020-05-31
吾日五省我身 2020-05-27
牧场SZShepherd 2020-05-27
sweetgirl0 2020-05-14