Axis1.4之定制发布服务
将axis1.4_home\webapps目录下的axis文件夹拷贝到tomcat_home\webapps目录下。然后在tomcat_home\webapps\axis\WEB-INF\lib下添加activation-1.1.1.jar和mail-1.4.jar。接着我们写一个带包结构的Java类HelloWSDD.java:
package com.grubby.webservice; public class HelloWSDD
{
public String getName(String name){
return "your name:"+name;
} public int getAge(int age){
return age+10;
}
}
编译并将编译后带包结构的class文件拷贝到tomcat_home\webapps\axis\WEB-INF\classes目录下。
然后在tomcat_home\webapps\axis\WEB-INF目录下写一个deploy.wsdd文件,代码如下:
<deployment name="test" xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <service name="HelloWSDD" provider="java:RPC">
<parameter name="className" value="com.grubby.webservice.HelloWSDD" />
<parameter name="allowedMethods" value="*" />
</service> </deployment>
接着启动tomcat,然后:

这样就在deploy.wsdd的同级目录下生成了一个叫server-config.wsdd的文件:
<?xml version="1.0" encoding="UTF-8"?> <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<globalConfiguration>
<parameter name="sendMultiRefs" value="true"/>
<parameter name="disablePrettyXML" value="true"/>
<parameter name="adminPassword" value="admin"/>
<parameter name="attachments.Directory" value="D:\apache-tomcat-6.0.44\webapps\axis\WEB-INF\attachments"/>
<parameter name="dotNetSoapEncFix" value="true"/>
<parameter name="enableNamespacePrefixOptimization" value="false"/>
<parameter name="sendXMLDeclaration" value="true"/>
<parameter name="sendXsiTypes" value="true"/>
<parameter name="attachments.implementation" value="org.apache.axis.attachments.AttachmentsImpl"/>
<requestFlow>
<handler type="java:org.apache.axis.handlers.JWSHandler">
<parameter name="scope" value="session"/>
</handler>
<handler type="java:org.apache.axis.handlers.JWSHandler">
<parameter name="scope" value="request"/>
<parameter name="extension" value=".jwr"/>
</handler>
</requestFlow>
</globalConfiguration>
<handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/>
<handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder"/>
<handler name="Authenticate" type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>
<service name="HelloWSDD" provider="java:RPC">
<parameter name="allowedMethods" value="*"/>
<parameter name="className" value="com.grubby.webservice.HelloWSDD"/>
</service>
<service name="AdminService" provider="java:MSG">
<parameter name="allowedMethods" value="AdminService"/>
<parameter name="enableRemoteAdmin" value="false"/>
<parameter name="className" value="org.apache.axis.utils.Admin"/>
<namespace>http://xml.apache.org/axis/wsdd/</namespace>
</service>
<service name="Version" provider="java:RPC">
<parameter name="allowedMethods" value="getVersion"/>
<parameter name="className" value="org.apache.axis.Version"/>
</service>
<transport name="http">
<requestFlow>
<handler type="URLMapper"/>
<handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
</requestFlow>
<parameter name="qs:list" value="org.apache.axis.transport.http.QSListHandler"/>
<parameter name="qs:wsdl" value="org.apache.axis.transport.http.QSWSDLHandler"/>
<parameter name="qs.list" value="org.apache.axis.transport.http.QSListHandler"/>
<parameter name="qs.method" value="org.apache.axis.transport.http.QSMethodHandler"/>
<parameter name="qs:method" value="org.apache.axis.transport.http.QSMethodHandler"/>
<parameter name="qs.wsdl" value="org.apache.axis.transport.http.QSWSDLHandler"/>
</transport>
<transport name="local">
<responseFlow>
<handler type="LocalResponder"/>
</responseFlow>
</transport>
</deployment>
我们在浏览器输入http://localhost:8080/axis/,回车得到页面,点击List链接得到:

点击HelloWSDD的wsdl链接:
<wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://localhost:8080/axis/services/HelloWSDD" xmlns:intf="http://localhost:8080/axis/services/HelloWSDD" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://localhost:8080/axis/services/HelloWSDD">
<!--
WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)
-->
<wsdl:message name="getNameRequest">
<wsdl:part name="in0" type="soapenc:string"/>
</wsdl:message>
<wsdl:message name="getNameResponse">
<wsdl:part name="getNameReturn" type="soapenc:string"/>
</wsdl:message>
<wsdl:message name="getAgeRequest">
<wsdl:part name="in0" type="xsd:int"/>
</wsdl:message>
<wsdl:message name="getAgeResponse">
<wsdl:part name="getAgeReturn" type="xsd:int"/>
</wsdl:message>
<wsdl:portType name="HelloWSDD">
<wsdl:operation name="getName" parameterOrder="in0">
<wsdl:input message="impl:getNameRequest" name="getNameRequest"/>
<wsdl:output message="impl:getNameResponse" name="getNameResponse"/>
</wsdl:operation>
<wsdl:operation name="getAge" parameterOrder="in0">
<wsdl:input message="impl:getAgeRequest" name="getAgeRequest"/>
<wsdl:output message="impl:getAgeResponse" name="getAgeResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloWSDDSoapBinding" type="impl:HelloWSDD">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getName">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getNameRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://webservice.grubby.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="getNameResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/axis/services/HelloWSDD" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getAge">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getAgeRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://webservice.grubby.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="getAgeResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/axis/services/HelloWSDD" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloWSDDService">
<wsdl:port binding="impl:HelloWSDDSoapBinding" name="HelloWSDD">
<wsdlsoap:address location="http://localhost:8080/axis/services/HelloWSDD"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
此时浏览器地址栏变为:http://localhost:8080/axis/services/HelloWSDD?wsdl。
这就完成了发布。下面我们进行测试:
我们新建一个Java工程,加入axis1.4开发包下的jar到工程的类路径。然后写一个测试类Client.java:
package com.grubby.webservice.client; import java.rmi.RemoteException; import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException; import org.apache.axis.client.Call;
import org.apache.axis.client.Service; public class Client { public static void main(String[] args) throws ServiceException, RemoteException { String url = "http://localhost:8080/axis/services/HelloWSDD";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(url);
call.setOperationName(new QName(url,"getName"));
String result = (String) call.invoke(new Object[]{"Tom"});
System.out.println(result); }
}
运行后控制台输出:your name:Tom
Axis1.4之定制发布服务的更多相关文章
- Axis1.4之即时发布服务
下载axis1.4开发包,解压开发包,将webapps目录下的axis文件夹拷贝到tomcat的webapps目录下.启动tomcat,在浏览器输入http://localhost:8080/axis ...
- Webservice学习之——即时发布与定制发布
一.工具 myEclipse tomcat 6.0 以上版本 axis-bin-1_4.zip 二.即时发布 1.解压 axis-bin-1_4.zip 2.axis-bin-1_4.zip\axi ...
- ServiceStack.Redis订阅发布服务的调用(Z)
1.Redis订阅发布介绍Redis订阅发布是一种消息通信模式:发布者(publisher)发送消息,订阅者(Subscriber)接受消息.类似于设计模式中的观察者模式.发布者和订阅者之间使用频 ...
- ArcGIS Server开发教程系列(2)配置ARCMAP和ARCCatalog发布服务
1. Arc catalog的配置 打开catalog,如图新增刚刚创建的server 1. Use GIS services: 用户身份连接 使用此种连接,可以浏览.使用站点内发布的所有 ...
- ServiceStack.Redis订阅发布服务的调用
1.Redis订阅发布介绍 Redis订阅发布是一种消息通信模式:发布者(publisher)发送消息,订阅者(Subscriber)接受消息.类似于设计模式中的观察者模式. 发布者和订阅者之间使用频 ...
- ArcGIS发布服务时缓存切片设置
[文件]>[共享]>[服务]>[覆盖原有服务]或[创建新服务] 设置好相关参数后,会弹出"服务编辑框": 进入"缓存" 1."绘制此 ...
- 使用expect脚本语言写一键发布服务(代码发布、所有服务重启)
互联网服务有很多台服务,但是在上线的时候需要将这些服务版本都更新与个个都重启,下面的脚本语言,就是一键发布服务~ 1.在/home/weihu/deploy/ 目录下建下publish .publis ...
- PHPRPC jsp发布服务
PHPRPC是面向服务的高性能远程过程调用协议.PHPRPC for java 是此协议的一种实现,详细请到官方看PHPRPC的介绍 ,以其它rpc协议的性能对比请:Java.PHPRPC.Hessi ...
- 除非 Windows Activation Service (WAS)和万维网发布服务(W3SVC)均处于运行状态,否则无法启动网站。目前,这两项服务均处于停止状态。
win7 IIS 所有网站都停止了,启动提示: 除非 Windows Activation Service (WAS)和万维网发布服务(W3SVC)均处于运行状态,否则无法启动网站.目前,这两项服务均 ...
随机推荐
- eclipse web and java ee development
1.打开Eclipse ->help ->install new software 2.Work with:http://download.eclipse.org/releases/gan ...
- python 常见错误和异常 函数 正则表达式及多线程编程
生成随机密码#!/usr/bin/env python import stringfrom random import choice def gen_pass(num=9): all_chs = st ...
- linux iptables扩展,脚本防火墙
netfileter:防火墙内核态ip tables:防火墙用户态(管理防火墙规则) iptables的表和链表包括不同的链,链包括大量的规则4个表: raw,mangle,nat,filter5种链 ...
- Ubuntu的shell之bash和dash
Ubuntu的 shell 默认安装的是 dash,而不是 bash. 运行以下命令查看 sh 的详细信息,确认 shell 对应的程序是哪个: $ls -al /bin/sh dash 比 bash ...
- 错误代码: 1111 Invalid use of group function
1.错误描述 1 queries executed, 0 success, 1 errors, 0 warnings 查询:update t_user_info t inner join t_pro_ ...
- freemarker中的left_pad和right_pad
freemarker中的left_pad和right_pad 1.简易说明 (1)left_pad 距左边 (2)right_pad 距右边 (3)当仅仅只有一个参数时,插入的是空白:当有两个参数时, ...
- Java中的List转换成JSON报错(三)
1.错误描述 Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ezmorph/Morpher a ...
- Java语法 示例
第二章: int:整型 double:双精度浮点型 char:字符型 String:字符串型语法:数据类型 变量名: 如:String name: 变量名=值: 如:name="张三&quo ...
- sql中的IFNULL函数的应用
select r.status=1 and IFNULL(r.channel_code,'') != 'crm' 这种查询方式的意思就是说如果r.channel_code为空则设置为空字符串,自然而然 ...
- 让安卓app支持swf的一个播放器,和自己编写的音乐管理程序
jcenter方式导入 在需要用到这个库的module中的build.gradle中的dependencies中加入 dependencies { compile 'com.yhd.hdswfplay ...