同时在一个WebService服务中发布多个普通Java类

package service;
public class MyService{
    
public String getGreeting(String name){
        
return "您好 " + name;
    }
    
public void update(String data){
        System.out.println(
"<" + data + ">已经更新");
    }
}

package service;
public class MyServiceOther{
    
public String getName(){ 
        
return "shihuan";
    }
}
services.xml文件中可以使用如下的配置代码来配置MyServiceMyServiceOther类:

<serviceGroup>
    <service name="myService">
       
<description>
            Web Service例子
       
</description>
       
<parameter name="ServiceClass">
            service.MyService  
       
</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>
    <service name="myServiceOther">
       
<description>
            Web Service例子
      
</description>
       
<parameter name="ServiceClass">
            service.MyServiceOther  
       
</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>
</serviceGroup>

 

【注】:myServicemyServiceOther就是http://IP:PORT/ProjectName/services/ServiceName?wsdl中?wsdl前

        面的那个ServiceName

        本例的访问路径应该是:

        http://IP:PORT/ProjectName/services/myService?wsdl

       

        http://IP:PORT/ProjectName/services/myServiceOther?wsdl

posted on 2012-06-13 21:56  h2内存数据库  阅读(505)  评论(0编辑  收藏  举报

导航