接口如下
package com.wm5920.webservice; public class HelloService { public String sayHello(){ return "hello"; } public String sayHelloToPerson(String name){ if(name==null){ name = "nobody"; } return "hello,"+name; } public void updateData(String data){ System.out.println(data+" 已更新。"); } }
services.xml配置一:
<?xml version="1.0" encoding="UTF-8"?> <service name="HelloService"> <description> Web Service例子 </description> <parameter name="ServiceClass"> com.wm5920.webservice.HelloService </parameter> <messageReceivers> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" /> </messageReceivers> </service>
services.xml配置二:
<service name=" HelloService"> <description> Web Service例子 </description> <parameter name="ServiceClass"> com.wm5920.webservice.HelloService </parameter> <operation name="sayHello"> <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/> </operation> <operation name="sayHelloToPerson"> <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/> </operation> <operation name="updateData"> <messageReceiver class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/> </operation> </service>第二种要多写具体方法,建议用第一种! 原文链接:https://www.f2er.com/xml/296675.html