import javax.jws.WebService; 
import javax.xml.ws.Endpoint; /** 
* Java6开发WebService入门 

* @author leizhimin 2009-11-13 16:10:44 
*/ 
@WebService 
public class Java6WebService { 
        /** 
         * Web服务中的业务方法 
         * 
         * @return 一个字符串 
         */ 
        public String doSomething() { 
                return "Hello Java6 WebService!"; 
        }         public static void main(String[] args) { 
                //发布一个WebService 
                Endpoint.publish("http://localhost:8880/java6ws/lavasoft.Java6WebService", new Java6WebService()); 
        } 
}
我在eclipse运行这个代码,出现下面的错误,请问是什么原因
Exception in thread "main" Server Runtime Error: class: com.ywh.jaxws.DoSomething could not be found
at com.sun.xml.internal.ws.transport.http.server.HttpEndpoint.publish(HttpEndpoint.java:269)
at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:87)
at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:59)
at javax.xml.ws.Endpoint.publish(Endpoint.java:156)
at com.ywh.Java6WebService.main(Java6WebService.java:24)
Caused by: class: com.ywh.jaxws.DoSomething could not be found
at com.sun.xml.internal.ws.modeler.RuntimeModeler.getClass(RuntimeModeler.java:271)
at com.sun.xml.internal.ws.modeler.RuntimeModeler.processDocWrappedMethod(RuntimeModeler.java:562)
at com.sun.xml.internal.ws.modeler.RuntimeModeler.processMethod(RuntimeModeler.java:509)
at com.sun.xml.internal.ws.modeler.RuntimeModeler.processClass(RuntimeModeler.java:355)
at com.sun.xml.internal.ws.modeler.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:251)
at com.sun.xml.internal.ws.server.RuntimeEndpointInfo.createSEIModel(RuntimeEndpointInfo.java:170)
at com.sun.xml.internal.ws.server.RuntimeEndpointInfo.init(RuntimeEndpointInfo.java:317)
at com.sun.xml.internal.ws.transport.http.server.HttpEndpoint.publish(HttpEndpoint.java:298)
at com.sun.xml.internal.ws.transport.http.server.HttpEndpoint.publish(HttpEndpoint.java:263)
... 4 more

解决方案 »

  1.   

    com.ywh.jaxws.DoSomething could not be found缺少这个class,或是路径不正确。
      

  2.   

    成功了
    package com.ywh;
    import javax.jws.WebMethod;
    import javax.jws.WebParam;
    import javax.jws.WebResult;
    import javax.jws.WebService;
    import javax.jws.soap.SOAPBinding;
    import javax.jws.soap.SOAPBinding.ParameterStyle;
    import javax.xml.ws.Endpoint;
    @SOAPBinding(parameterStyle=ParameterStyle.BARE)
    @WebService(serviceName="Java6WebService" ,targetNamespace="http://ywh.com")
    public class Java6WebService { 
     @WebMethod
     @WebResult(name="doSomethingResponse")
     public  String  doSomething(@WebParam(name="input")String input){
      return  "hello:"+input;
     };
     public static  void main(String[] args){
      Endpoint.publish("http://localhost:8887/GeoGlobeServer", new Java6WebService());
     }; }