最近蛮多人在问这方面问题的,我把之间的回答再贴一下,楼主可以参考一下:
建议用Axis2来实现WebServices,流程如下(我用的是Axis2项目里的用户手册的例子): 
服务器端: 
1、 public class MyService{ 
    public void ping(OMElement element){ 
        //这里是你在服务器端要实现的功能代码
    } } 2、建立service.xml,放在以上java文件同路径下的META-INF文件夹下 
   <service >   
     <description>   
        This is a sample Web Service with two operations, echo and ping.  
     </description>   
     <parameter name="ServiceClass" locked="false"> userguide.example1.MyService </parameter>   
     <operation name="ping">   
         <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>   
         <actionMapping> urn:ping </actionMapping>   
     </operation>   
   </service>   
3、将上面2个文件打成jar文件,可以考虑用eclipse的导出jar功能来实现,比较方便,在将这个jar文件的后缀名改成aar,比如test.aar,将这个文件放在你那个struts项目的WEB-INF\services下,这样你启动你的项目时候,WebServices的服务器端就可以发布成功了。检查是否发布成功的方法是,用浏览器访问:http://localhost:8080/muProject/services/aaa.wsdl,其中aaa的名字是service.xml中配置的。 现在讲下客户端的编写,举个最简单的例子吧, 
客户端很简单,如下: package userguide.clients;import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;/**
 * Sample for synchronous single channel blocking service invocation.
 * Message Exchage Pattern IN-OUT
 */
public class EchoBlockingClient {
    private static EndpointReference targetEPR = new EndpointReference("http://localhost:8080/axis2/services/MyService");    public static void main(String[] args) {
        try {
            OMElement payload = ClientUtil.getEchoOMElement();
            Options options = new Options();
            options.setTo(targetEPR);
            options.setAction("urn:ping");            //Blocking invocation
            ServiceClient sender = new ServiceClient();
            sender.setOptions(options);
            OMElement result = sender.sendReceive(payload);            System.out.println(result);        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();
        }
    }
}以上就算完成了一个简单的用Axis2来创建WebServices的过程,具体的所用到的项目包,用户手册等资料,在apache的axis项目页上都可以找到 
http://ws.apache.org/axis2/

解决方案 »

  1.   

    谢谢楼上的兄弟,我也用AIXS布置过WEB SERVICE,或者直接将JAVA文件改成为jws文件。我要的WEB SERVICE是不带后缀名的。就像MessageNotification类发布后访问地址为http://localhost:8080/xms/service/MessageNotification ,
    请高手指点,JAVA发布成WEB SERVICE我真的很弱,谢谢。
      

  2.   

    关注:我一直用weblogic做webservecs服务器tomcat没用过 weblogic发布服务很简单
      

  3.   

     最近把webService又弄了一遍,其实发布非常简单的,不管是tomcat还是weblogic,我都弄过,只要把接口写好了,用命令加axis一下了就搞定了。