最近开始学习了下在Myeclipse开发工具下基于WebSerivce的开发,下面将相关相关关键信息予以记录

  1. Myeclipse的安装,本文以Myeclipse2014-blue为开发环境,相关配置执行完善
  2. http://archive.apache.org/dist/ws/axis2/tools/下载Axis2包,下载 axis2-eclipse-codegen-wizard.zip,下载axis2-eclipse-service-archiver-wizard.zip
  3. http://axis.apache.org/axis2/java/core/download.html下载(axis2-1.7.0-bin.zip,axis2-1.7.0-war.zip,axis2-eclipse-codegen-plugin-1.7.0.zip,axis2-eclipse-service-plugin-1.7.0.zip)
  4. 下载说明:从步骤1下载出来的Axis2_Codegen_Wizard_1.3.0文件夹,Axis2_Service_Archiver_1.3.0文件夹拷贝到myeclipse安装目录之dropins文件下,重启myeclipse下载到的axis2-1.7.0-war.zip,拷贝文件之tomact/webapps目录下面,重命名axis2.war,刷新文件夹,tomact为解压该部署包,此时可以通过tomact服务访问axis2站,看到相关页面表示成功
  5. 在步骤4中,注意文件夹axis2\WEB-INF,下面有3个文件夹,conf,modules,services,lib文件夹,稍后我们会用到
  6. 下面借助于axis2来开发webservice
  7. 打开myeclipse新建web project项目,将步骤5中conf,modules,services,lib文件夹的拷贝之WebRoot/WEB-INF/下面,并在WEB-INF下面新建Web.xml文件,倘若web.xml存在则打开,添加以下代码配置axis2
  8. axis2配置代码如下:
        <!-- 加载Axis2 -->
    <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>

      

  9. 在WEB-INF/services/下新建Axis2Service/META-INF/目录,新建文件services.xml,添加如下webservice服务配置代码
        <!-- HelloWorld表示您的WebService服务名 -->
    <service name="HelloWorld" >
    <!-- HelloWorld表示您的WebService服务描述 -->
    <description>
    HelloWorld Service Example
    </description>
    <!-- 这个必须是这个服务的类路径 -->
    <parameter name="ServiceClass">
    cn.homily.action.HelloWorld
    </parameter>
    <!-- 这个是这个服务的方法名 -->
    <operation name="getHello">
    <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
    </operation>
    <operation name="getWorld">
    <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
    </operation>
    <operation name="getHelloWorld">
    <!-- 这里要注意,当没有返回值时才用
    org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver,
    没有参数还是用RPCMessageReceiver-->
    <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
    </operation>
    </service>

      

  10. 在src包下面添加子包cn.homily.action,添加HelloWorld.java文件,其代码如下:
    package cn.homily.action;
    //服务名
    public class HelloWorld
    {
      //服务方法
    public String getHello(String name)
    {
    return "Hello, " + name + ".";
    }
    //服务方法
    public String getWorld(String name)
    {
    return "World," + name + ".";
    }
    //服务方法
    public String getHelloWorld()
    {
    return "Hello,World";
    }
    }

      经过以上步骤,我们的WebService基本代码已经全了,现在看看实际效果。

  11. 现在打包我们的Web-Project,部署我们的Web-Project至tomact,现在我们运行,在浏览器输入如下地址http://zgc-20150226yxm:8080/sayHello2Axis/services/HelloWorld?wsdl。如果在浏览器里面看到了以下代码,说明我们的Web-Service服务Demo开发完成。正确的页面效果如下:
    This XML file does not appear to have any style information associated with it. The document tree is shown below.
    <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://action.homily.cn" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" targetNamespace="http://action.homily.cn">
    <wsdl:documentation>HelloWorld</wsdl:documentation>
    <wsdl:types>...</wsdl:types>
    <wsdl:message name="getHelloRequest">
    <wsdl:part name="parameters" element="ns:getHello"/>
    </wsdl:message>
    <wsdl:message name="getHelloResponse">
    <wsdl:part name="parameters" element="ns:getHelloResponse"/>
    </wsdl:message>
    <wsdl:message name="getHelloWorldRequest">
    <wsdl:part name="parameters" element="ns:getHelloWorld"/>
    </wsdl:message>
    <wsdl:message name="getHelloWorldResponse">
    <wsdl:part name="parameters" element="ns:getHelloWorldResponse"/>
    </wsdl:message>
    <wsdl:message name="getWorldRequest">
    <wsdl:part name="parameters" element="ns:getWorld"/>
    </wsdl:message>
    <wsdl:message name="getWorldResponse">
    <wsdl:part name="parameters" element="ns:getWorldResponse"/>
    </wsdl:message>
    <wsdl:portType name="HelloWorldPortType">
    <wsdl:operation name="getHello">
    <wsdl:input message="ns:getHelloRequest" wsaw:Action="urn:getHello"/>
    <wsdl:output message="ns:getHelloResponse" wsaw:Action="urn:getHelloResponse"/>
    </wsdl:operation>
    <wsdl:operation name="getHelloWorld">
    <wsdl:input message="ns:getHelloWorldRequest" wsaw:Action="urn:getHelloWorld"/>
    <wsdl:output message="ns:getHelloWorldResponse" wsaw:Action="urn:getHelloWorldResponse"/>
    </wsdl:operation>
    <wsdl:operation name="getWorld">
    <wsdl:input message="ns:getWorldRequest" wsaw:Action="urn:getWorld"/>
    <wsdl:output message="ns:getWorldResponse" wsaw:Action="urn:getWorldResponse"/>
    </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="HelloWorldSoap11Binding" type="ns:HelloWorldPortType">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <wsdl:operation name="getHello">
    <soap:operation soapAction="urn:getHello" style="document"/>
    <wsdl:input>
    <soap:body use="literal"/>
    </wsdl:input>
    <wsdl:output>
    <soap:body use="literal"/>
    </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getHelloWorld">
    <soap:operation soapAction="urn:getHelloWorld" style="document"/>
    <wsdl:input>
    <soap:body use="literal"/>
    </wsdl:input>
    <wsdl:output>
    <soap:body use="literal"/>
    </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getWorld">
    <soap:operation soapAction="urn:getWorld" style="document"/>
    <wsdl:input>
    <soap:body use="literal"/>
    </wsdl:input>
    <wsdl:output>
    <soap:body use="literal"/>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="HelloWorldSoap12Binding" type="ns:HelloWorldPortType">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <wsdl:operation name="getHello">
    <soap12:operation soapAction="urn:getHello" style="document"/>
    <wsdl:input>
    <soap12:body use="literal"/>
    </wsdl:input>
    <wsdl:output>
    <soap12:body use="literal"/>
    </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getHelloWorld">
    <soap12:operation soapAction="urn:getHelloWorld" style="document"/>
    <wsdl:input>
    <soap12:body use="literal"/>
    </wsdl:input>
    <wsdl:output>
    <soap12:body use="literal"/>
    </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getWorld">
    <soap12:operation soapAction="urn:getWorld" style="document"/>
    <wsdl:input>
    <soap12:body use="literal"/>
    </wsdl:input>
    <wsdl:output>
    <soap12:body use="literal"/>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="HelloWorldHttpBinding" type="ns:HelloWorldPortType">
    <http:binding verb="POST"/>
    <wsdl:operation name="getHello">
    <http:operation location="getHello"/>
    <wsdl:input>
    <mime:content type="application/xml" part="parameters"/>
    </wsdl:input>
    <wsdl:output>
    <mime:content type="application/xml" part="parameters"/>
    </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getHelloWorld">
    <http:operation location="getHelloWorld"/>
    <wsdl:input>
    <mime:content type="application/xml" part="parameters"/>
    </wsdl:input>
    <wsdl:output>
    <mime:content type="application/xml" part="parameters"/>
    </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getWorld">
    <http:operation location="getWorld"/>
    <wsdl:input>
    <mime:content type="application/xml" part="parameters"/>
    </wsdl:input>
    <wsdl:output>
    <mime:content type="application/xml" part="parameters"/>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="HelloWorld">
    <wsdl:port name="HelloWorldHttpSoap11Endpoint" binding="ns:HelloWorldSoap11Binding">
    <soap:address location="http://zgc-20150226yxm:8080/sayHello2Axis/services/HelloWorld.HelloWorldHttpSoap11Endpoint/"/>
    </wsdl:port>
    <wsdl:port name="HelloWorldHttpSoap12Endpoint" binding="ns:HelloWorldSoap12Binding">
    <soap12:address location="http://zgc-20150226yxm:8080/sayHello2Axis/services/HelloWorld.HelloWorldHttpSoap12Endpoint/"/>
    </wsdl:port>
    <wsdl:port name="HelloWorldHttpEndpoint" binding="ns:HelloWorldHttpBinding">
    <http:address location="http://zgc-20150226yxm:8080/sayHello2Axis/services/HelloWorld.HelloWorldHttpEndpoint/"/>
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>

      

基于Myeclipse+Axis2的WebService开发实录的更多相关文章

  1. 使用Myeclipse进行简单webservice开发的示例

    (转) http://blog.csdn.net/changhenshui1990/article/details/70142371 前言:朋友们开始以下教程前,请先看第五大点的注意事项,以避免不必要 ...

  2. 搭建基于MyEclipse的Hadoop开发环境

    不多说,直接上干货! 前面我们已经搭建了一个伪分布模式的Hadoop运行环境.请移步, hadoop-2.2.0.tar.gz的伪分布集群环境搭建(单节点) 我们绝大多数都习惯在Eclipse或MyE ...

  3. Myeclipse+Axis2+Tomcat开发webService

    1.  下载文件: 需要在axis2官网下载两种类型的axis2文件,bin版和war版(下载地址:http://axis.apache.org/axis2/java/core/download.cg ...

  4. WebService学习总结(四)--基于CXF的服务端开发

    本节将实践目前最流行的第二种web service 发布和调试框架  CXF Apache CXF 是一个开放源代码框架,提供了用于方便地构建和开发 Web 服务的可靠基础架构.它允许创建高性能和可扩 ...

  5. 基于JAX-WS的webService开发实例

    最近因为工作原因接触到webService,所以记录下开发中碰到的问题,方便自己以后复习,顺便发扬一下开源精神.刚刚接触webServie如果有什么错误欢迎大家指正. 本地环境:myEclipse10 ...

  6. 基于Axis1.4的webservice接口开发(代码开发)

    基于Axis1.4的webservice接口开发(代码开发) 一.开发环境: 我的开发环境是MyEclipse 2015+Apache-Tomcat-8.0.21. 二.代码开发: 1.新建一个Web ...

  7. 使用axis2进行WebService的开发

    使用axis2进行WebService的开发 Apache Axis2 是 Apache Axis SOAP 项目的后继项目.此项目是 Web 服务核心引擎的重要改进,目标是成为 Web 服务和面向服 ...

  8. 基于Axis1.4的webservice接口开发(接口调用)

    基于Axis1.4的webservice接口开发(接口调用) 一.webservice接口代码参考上一篇博客: http://www.cnblogs.com/zhukunqiang/p/7125668 ...

  9. 基于Axis1.4的webservice接口开发(环境搭建)

    基于Axis1.4的webservice接口开发(环境搭建) 一.环境搭建: 1.搜索关键字“Axis1.4”下载Axis1.4相关的jar包. 下载地址:http://download.csdn.n ...

随机推荐

  1. react特性-声明式编程

    网络上有很多关于声明式编程和命令式编程的对比和说明,但是大多都是大同小异,总的来说就是一句话"告诉电脑我要做什么,但是让电脑自己决定怎么做." 1.命令式编程. 这种编程模式比较常 ...

  2. linu下nginx的安装

    这里用到的环境是nginx-1.8.0,linux用的是CentOS-7-x86_64-DVD-1804.iso版本 1   什么是nginx Nginx ("engine x") ...

  3. 使用final关键字修饰一个引用类型变量时,是引用不能变,还是引用的对象不能变?

    使用final关键字修饰一个引用类型变量时,是指引用变量不能变,引用变量所指向的对象中的内容还是可以改变的. 测试代码如下: package reviewTest; /** * @ClassName: ...

  4. RabbitMQ在Ubuntu上的环境搭建

    1.修改/etc/apt/sources.list文件 A:命令:vi /etc/apt/sources.list B:在最后一行加上:deb http://www.rabbitmq.com/debi ...

  5. gitlab的添加密钥

    1.在本地电脑下载git的客户端并且安装 2.鼠标右键左面选中Git Bash Here 3.操作如下图生成密钥 4.将密钥复制过来添加到gitLab中 5.Eclipse配置密钥 6.在git创建的 ...

  6. XOR Queries

    XOR Queries 时间限制: 1000ms   内存限制: 256M 描述 给出一个长度为n的数组C,回答m个形式为(L,R,A,B)的询问,含义为存在多少个不同的数组下标k∈[L,R]满足C[ ...

  7. 洛谷 P1972 BZOJ 1878 [SDOI2009]HH的项链

    题目描述 HH 有一串由各种漂亮的贝壳组成的项链.HH 相信不同的贝壳会带来好运,所以每次散步完后,他都会随意取出一段贝壳,思考它们所表达的含义.HH 不断地收集新的贝壳,因此,他的项链变得越来越长. ...

  8. sgu 176 有源汇有上下界的最小流模板题

    /*参考博文:http://hi.baidu.com/dragon_eric123/item/82e259200ece744046996282 有上下界的有源最小流 */ #include<st ...

  9. 如何将变量id添加到jquery的选择器中

    今天在做广州仲裁委员会的系统时这样的一个需求,需要在页面一加载的时候查询各个项目的案件数,这里有很多个项目,一开始我是这样写的: 代码如下: $.get(assignedCaseUrl,functio ...

  10. Cash Machine POJ 1276 多重背包

    Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 35387   Accepted: 12816 Description A B ...