3 Replies Latest reply on Apr 15, 2009 4:13 PM by renani

    First webservice

      Hi,
      I'm trying to create a webservice. I followed the tutorials at http://www.javabeat.net/articles/40-creating-webservice-using-jboss-and-eclipse-europa-1.html.

      The server would not run the war file created by following these steps. I've debugged all day but could not find the reason for it. What I figured out was that the WSDL file was not created. Strangely, the index.html, a static web page I've created for test would not run either.

      In the book "JBoss in Action", chapter 9 I read that wsprovide is the program used to generate wsdls and it could be used manually. I attempted to do so and I think I figured out where it all fails. The message I got in Dos prompt is:

      Error: Could not generate. (use --show-traces to see full traces)
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
       at java.lang.String.substring(String.java:1768)
       at org.jboss.wsf.common.JavaUtils.getPackageName(JavaUtils.java:533)
       at org.jboss.ws.metadata.wsdl.WSDLUtils.getTypeNamespace(WSDLUtils.java:
      700)
       at org.jboss.ws.metadata.builder.jaxws.JAXWSWebServiceMetaDataBuilder.pr
      ocessWebService(JAXWSWebServiceMetaDataBuilder.java:313)
       at org.jboss.ws.metadata.builder.jaxws.JAXWSWebServiceMetaDataBuilder.bu
      ildWebServiceMetaData(JAXWSWebServiceMetaDataBuilder.java:107)
       at org.jboss.ws.tools.jaxws.impl.JBossWSProviderImpl.provide(JBossWSProv
      iderImpl.java:108)
       at org.jboss.ws.tools.jaxws.impl.JBossWSProviderImpl.provide(JBossWSProv
      iderImpl.java:124)
       at org.jboss.wsf.spi.tools.cmd.WSProvide.generate(WSProvide.java:183)
       at org.jboss.wsf.spi.tools.cmd.WSProvide.main(WSProvide.java:76)


      The java code I'm trying to generate wsdl for is:

      import javax.jws.WebService;
      import javax.jws.WebMethod;
      
      @WebService
      public class Greeting
      {
       @WebMethod
       public String greetClient(String userName)
       {
       return "Greeting " + userName + "! Have a nice day...";
       }
      }
      


      I'm certain that there is an error, not perhaps in the code it self but maybe with my configuration of eclipse (or is it JBoss)?

      Would be grateful for any help!

        • 1. Re: First webservice

          Oh, and I forgot to mention that I could find the error message String out of bounds associated with my project in JBoss logs.

          • 2. Re: First webservice
            peterj

            This is just a guess, but notice this method in the stack trace: org.jboss.wsf.common.JavaUtils.getPackageName. Now look at your web service - it has no package. You should never write packageless classes.

            • 3. Re: First webservice

              Assumed you were right. Created a package, got a new error (classNotFound), deleted the project, created a new project, new webservice in a package and it worked.

              Thanks for the help, PeterJ.