使用Jetty服务器和Axis2框架技术发布Webservice接口

1.所需要的工具

1.1 Ant工具 ,axis2-bin文件,axis2-war文件

这些工具和jar都可以从网上下载

2.下面我在eclipse中编写一个测试类,就是这么简单。

public class Add {
public int add(int a,int b){
return a+b;
}
}

3.我们把axis2-war这个文件 解压之后,把axis2文件放入到jetty容器中的webapps目录下,D:\jetty-6.1.9\webapps

4.ant执行命令

D:\caseone\test>ant generate.wsdl

D:\caseone\test>ant generate.service

执行成功之后 生成build文件

4.

.

5.把Add文件复制到


6.service.xml文件

<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->


<service name="Add" scope="application" targetNamespace="http://add/">
<description>
Add
</description>
<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>
<schema schemaNamespace="http://Add/xsd"/>
<parameter name="ServiceClass">Add</parameter>
</service>

7.bulid.xml文件

<project name="quickstart" basedir="." default="generate.service">
<property environment="env"/>
<property name="AXIS2_HOME" value="../.."/>
<property name="build.dir" value="build"/>
<path id="axis2.classpath">
<fileset dir="${AXIS2_HOME}/lib">
<include name="*.jar"/>
</fileset>
</path>

<target name="compile.service">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.dir}/classes"/>

<!--First let's compile the classes-->
<javac debug="on"
fork="true"
destdir="${build.dir}/classes"
srcdir="${basedir}/src"
classpathref="axis2.classpath">
</javac>
</target>

<target name="generate.wsdl" depends="compile.service">
<taskdef name="java2wsdl"
classname="org.apache.ws.java2wsdl.Java2WSDLTask"
classpathref="axis2.classpath"/>
<java2wsdl className="Add"
outputLocation="${build.dir}"
targetNamespace="http://add/"
schemaTargetNamespace="http://add/xsd">
<classpath>
<pathelement path="${axis2.classpath}"/>
<pathelement location="${build.dir}/classes"/>
</classpath>
</java2wsdl>
</target>

<target name="generate.service" depends="compile.service">
<!--aar them up -->
<copy toDir="${build.dir}/classes" failοnerrοr="false">
<fileset dir="${basedir}/resources">
<include name="**/*.xml"/>
</fileset>
</copy>
<jar destfile="${build.dir}/add.aar">
<fileset excludes="**/Test.class" dir="${build.dir}/classes"/>
</jar>
</target>


<target name="clean">
<delete dir="${build.dir}"/>
</target>
</project>

8.最后启动jetty


9.以上文字演示视频

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值