JAVA记录-WebService开发部署

Posted 信方互联网硬汉

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JAVA记录-WebService开发部署相关的知识,希望对你有一定的参考价值。

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开发部署的主要内容,如果未能解决你的问题,请参考以下文章

系统开发系列 之WebService(spring框架+maven+CXF框架)部署问题及解决方案

如何用IDEA一步一步开发WebService客户端程序

Web Service

java语言 编写接口开发需要用到WebService么?

visio studio2010 在win10下 开发webservice接口以及部署调用

WindowsAzure上把WebApp和WebService同时部署在一个WebRole中