日期:2014-05-20  浏览次数:20712 次

webService新手问题、
最近项目需要使用WebSerivce、以前没接触过、刚才网上down了点资料跟着写个服务端的简单demo、发布报错了、何解?
Java code
@WebService
public interface IHelloService {
    Customer selectMaxAgeStudent(Customer c1, Customer c2);

    Customer selectMaxLongNameStudent(Customer c1, Customer c2);
}

Java code
public class HelloServiceImpl implements IHelloService {

    @Override
    public Customer selectMaxAgeStudent(Customer c1, Customer c2) {
        if (c1.getBirthday().getTime() > c2.getBirthday().getTime()) {
            return c1;
        } else {
            return c2;
        }
    }

    @Override
    public Customer selectMaxLongNameStudent(Customer c1, Customer c2) {
        if (c1.getName().length() > c2.getName().length()) {
            return c1;
        } else {
            return c2;
        }
    }

}


Java code
@XmlRootElement(name = "customer")
public class Customer {
    private long id;
    private String name;
    private Date birthday;
。。。。。。get set。。。


Java code
public class SoapServer {
    public static void main(String[] args) {
        Endpoint.publish("http://127.0.0.1:8080/helloService",
                new HelloServiceImpl());
    }

Java code

Exception in thread "main" java.lang.NullPointerException
    at com.sun.xml.internal.ws.server.EndpointFactory.getWsdlLocation(EndpointFactory.java:385)
    at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.getPrimaryWsdl(EndpointImpl.java:265)
    at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.createEndpoint(EndpointImpl.java:208)
    at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:138)
    at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:92)
    at javax.xml.ws.Endpoint.publish(Endpoint.java:170)
    at com.gsoft.server.util.SoapServer.main(SoapServer.java:26)




------解决方案--------------------
啊哦、我也去学下webservice去
------解决方案--------------------
LZ你是AXIS2还是XFIRE啊
------解决方案--------------------
看不懂哦,为什么不用Eclipse去生成呢?只用导入一些Axis的jar包就Ok了。
------解决方案--------------------
在jdk1.6之前要发布Webservcie需要继承axis、XFire、CXF等框架。而jdk1.6自己实现了JAX-WS规范,可以用最简单的方式发布Webservice,楼主可以用"jdk1.6 Webservice"的关键字去Google一下,会后很多例子,希望能帮助你。