Problems with web services generated code.

Hi All,

In IntelliJ 10.0.3

I use the menu option "new web service" and this generates a class file and adds to sun-jaxws.xml - this is fine - it's working.

Now if I try to write a Java client for this web service I get IllegalArgumentException TestWebService is not an interface

Here's my client code:

public class WebServiceTest {

    public static void main(String[] args) throws Exception {

        URL url = new URL("http://localhost/services/TestWebService?wsdl");

        //1st argument service URI, refer to wsdl document above
        //2nd argument is service name, refer to wsdl document above
        QName qname = new QName("http://ws.mydomain.com/", "TestWebServiceService");


        Service service = Service.create(url, qname);

        TestWebService test = service.getPort(TestWebService.class); // fails here


        System.out.println(test.sayHelloWorldFrom("TESTING...."));

    }

}

How should I implement this? Should I have an interface and a class?  Is there a good example? Best practice?

2 comments
Comment actions Permalink

Anyone? I get an NPE trying to run a just-created example. IntelliJ IDEA 10.5.2, java version "1.6.0_29", Mac OS X 10.7.2 Steps:

o create new project
o create project from scratch
o Java Module
o create source dir
o check: WebServices (checks Web Application for me)
o Finish

[it downloads 18 files then opens the project]

o run HelloWorld -> gives me no output (though it showed a prompt to http://localhost:9000/HelloWorld the first time I ran it)
o browse http://localhost:9000/HelloWorld

-> java.lang.NullPointerException [see full output below, and generated command line]

Any ideas? Having it fail out of the box is a big dissapointment!

Thanks -- matt


java.lang.NullPointerException
    at com.sun.xml.ws.encoding.SOAPBindingCodec.compareStrings(SOAPBindingCodec.java:341)
    at com.sun.xml.ws.encoding.SOAPBindingCodec.isMultipartRelated(SOAPBindingCodec.java:323)
    at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:251)
    at com.sun.xml.ws.transport.http.HttpAdapter.decodePacket(HttpAdapter.java:206)
    at com.sun.xml.ws.transport.http.HttpAdapter.access$500(HttpAdapter.java:74)
    at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:362)
    at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:175)
    at com.sun.xml.ws.transport.http.server.WSHttpHandler.handleExchange(WSHttpHandler.java:96)
    at com.sun.xml.ws.transport.http.server.WSHttpHandler.handle(WSHttpHandler.java:77)
    at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:65)
    at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:65)
    at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:68)
    at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:555)
    at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:65)
    at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:527)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -Didea.launcher.port=7534 -Didea.launcher.bin.path=/Applications/IntelliJ IDEA 10.app/bin -Dfile.encoding=UTF-8 -classpath /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/deploy.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/dt.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/javaws.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/jce.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/jconsole.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/management-agent.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/plugin.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/sa-jdi.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/alt-rt.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/alt-string.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/charsets.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/classes.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/jsse.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/../Classes/ui.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/apple_provider.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/dnsns.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/localedata.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunjce_provider.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunpkcs11.jar:/Users/cornell/IdeaProjects/untitled/out/production/untitled:/Users/cornell/IdeaProjects/untitled/lib/activation.jar:/Users/cornell/IdeaProjects/untitled/lib/FastInfoset.jar:/Users/cornell/IdeaProjects/untitled/lib/http.jar:/Users/cornell/IdeaProjects/untitled/lib/jaxb-api.jar:/Users/cornell/IdeaProjects/untitled/lib/jaxb-impl.jar:/Users/cornell/IdeaProjects/untitled/lib/jaxb-xjc.jar:/Users/cornell/IdeaProjects/untitled/lib/jaxws-api.jar:/Users/cornell/IdeaProjects/untitled/lib/jaxws-rt.jar:/Users/cornell/IdeaProjects/untitled/lib/jaxws-tools.jar:/Users/cornell/IdeaProjects/untitled/lib/jsr173_api.jar:/Users/cornell/IdeaProjects/untitled/lib/jsr181-api.jar:/Users/cornell/IdeaProjects/untitled/lib/jsr250-api.jar:/Users/cornell/IdeaProjects/untitled/lib/resolver.jar:/Users/cornell/IdeaProjects/untitled/lib/saaj-api.jar:/Users/cornell/IdeaProjects/untitled/lib/saaj-impl.jar:/Users/cornell/IdeaProjects/untitled/lib/sjsxp.jar:/Users/cornell/IdeaProjects/untitled/lib/stax-ex.jar:/Users/cornell/IdeaProjects/untitled/lib/streambuffer.jar:/Applications/IntelliJ IDEA 10.app/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain example.HelloWorld
0
Comment actions Permalink

Meta note: Why does it say this at the top:

This Question is                             Possibly Answered


1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)


I don't see any answers at all, other than my just-posted one!
0

Please sign in to leave a comment.