web.xml 配置以下,services下的所有访问路径 交给AxisServlet 处理。
<servlet> <servlet-name>AxisServlet</servlet-name> <servlet-class> org.apache.axis.transport.http.AxisServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>AxisServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping>
生成的 server-config.wsdd(web-inf目录下) Axis 命令可生成
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper" /> <handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder" /> <service name="CheckServer" provider="java:RPC"> -- 服务名 <parameter name="allowedMethods" value="*"/> -- 可访问所有public方法 <parameter name="className" value="com.heiniao.aaaaa.CheckServer"/> --对应的需要发布的类,只需写正常的类即可。 </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:method" value="org.apache.axis.transport.http.QSMethodHandler" /> </transport> <transport name="local"> <responseFlow> <handler type="LocalResponder" /> </responseFlow> </transport> </deployment>
配置完后,重启项目,可自动发布webservice服务
测试类 -- 本地测试调用webservice 服务,远程调用只需该下地址即可
String xml = "<?xml version="1.0" encoding="UTF-8" ?><reqData> </reqData>"; String targetEendPoint = "http://localhost:8080/heiniao/services/PolicyCheckServer"; //heiniao为项目名 Service service = new Service(); Call call = (Call) service.createCall(); call.setOperationName( new QName(targetEendPoint, "getServerXML" )); //这里指定调用服务的方法 call.setTargetEndpointAddress( new URL(targetEendPoint)); String result = (String) call.invoke( new Object[]{ ""}); //这里为入参,在这传入了String 空值 System.out.println(result); //接收到的服务返回参数, 本服务设置的返回参数为 String
所有的jar包 -- 这里是全部的jar包 -- 根据服务功能有些是不需要的
activation.jar
asm.jar
asm-attrs.jar
axis.jar
axis-ant.jar
commons-discovery-0.2.jar
commons-logging-1.0.4.jar
dom4j-1.6.1.jar
jaxrpc.jar
log4j-1.2.8.jar
mail.jar
saaj.jar
wsdl4j-1.5.1.jar
xerces-2.6.2.jar
xml-apis.jar
XmlSchema-1.0.jar
asm.jar
asm-attrs.jar
axis.jar
axis-ant.jar
commons-discovery-0.2.jar
commons-logging-1.0.4.jar
dom4j-1.6.1.jar
jaxrpc.jar
log4j-1.2.8.jar
mail.jar
saaj.jar
wsdl4j-1.5.1.jar
xerces-2.6.2.jar
xml-apis.jar
XmlSchema-1.0.jar