码迷,mamicode.com
首页 > 编程语言 > 详细

JAVA记录-WebService开发部署

时间:2017-10-19 15:03:24      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:receive   a记录   编译   beans   mod   开发部   contex   一个   oca   

JWS、Axis2、cxf

1.下载axis2.war和axis2.bin.zip

2.将axis2.war包部署到Tomcat下,启动Tomcat测试:http://localhost:8089/axis2

3.新建web project,在src新建一个类编写好代码作为服务端,无需包名,编译生成.class,

拷贝到tomcat\webapps\axis2\WEB-INF\pojo下(需要新建pojo)

4.运行http://localhost:8089/axis2/services/listServices,查看服务名

5.获取服务:http://localhost:8089/axis2/services/DataGetService

6.客户端调用写好类代码,并运行http://localhost:8089/axis2/services/DataGetService?wsdl

###集成到ssmm web项目中去,将axis2-web拷贝到webapp下,将lib、conf、modules、services拷贝到WEB-INF下,

spring-axis2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="applicationContext" class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder" />
<bean id="HelloWorld" class="com.net.xinfang.axis2.server.HelloWorld"></bean>
</beans>

web.xml加入
<servlet>
<servlet-name>AxisServlet</servlet-name>
<servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>

在services下新建hello,在hello新建serviceData.xml和services.xml
serviceData.xml
<?xml version="1.0" encoding="UTF-8"?>
<ServiceData>
</ServiceData>

services.xml
<serviceGroup>
<service name="HelloWorld" >
<description>
Test Service Example
</description>
<parameter name="ServiceObjectSupplier"><!-- 固定的不变 -->
org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
</parameter>
<parameter name="SpringBeanName">HelloWorld</parameter><!-- bean名字 -->
<parameter name="ServiceClass">
com.net.xinfang.service.HelloWorld
</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>
</serviceGroup>

<service name="HelloWorld">
<description>
HelloWorld Service Example
</description>
<parameter name="ServiceClass">
com.cm.service.HelloWorld
</parameter>
<operation name="sayHello">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
</service>

JAVA记录-WebService开发部署

标签:receive   a记录   编译   beans   mod   开发部   contex   一个   oca   

原文地址:http://www.cnblogs.com/xinfang520/p/7692168.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!