欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

CXF调用webservice报错

程序员文章站 2022-06-11 08:22:58
...
    public static void main(String[] args) {
        JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance();
        Client client = null;
        client = clientFactory.createClient("http://localhost:8080/bnc?wsdl");
        try {
            Object[] result = client.invoke("sayHi", "wlh");
            System.out.println(result[0]);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


2013-7-30 21:28:11 org.apache.cxf.common.jaxb.JAXBUtils logGeneratedClassNames
信息: Created classes: org.crazyit.cxfapp.service.ObjectFactory, org.crazyit.cxfapp.service.SayHi, org.crazyit.cxfapp.service.SayHiResponse, org.crazyit.cxfapp.service.SayHiToUser, org.crazyit.cxfapp.service.SayHiToUserResponse, org.crazyit.cxfapp.service.User
Exception in thread "main" java.lang.NullPointerException
    at org.apache.cxf.common.util.Compiler.useJava6Compiler(Compiler.java:190)
    at org.apache.cxf.common.util.Compiler.compileFiles(Compiler.java:144)
    at org.apache.cxf.common.util.Compiler.compileFiles(Compiler.java:139)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.compileJavaSrc(DynamicClientFactory.java:610)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:369)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:240)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:233)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:188)
    at org.crazyit.cxfapp.bnc.MyClient.main(MyClient.java:16)



报这个错的原因是因为:1.你环境变量设置有错(网上有人说吧jre改成jdk的jre,主要原因是因为你环境变量设置有错。)
相关标签: CXF webservice