5 Replies Latest reply on May 11, 2006 4:03 AM by Hark Jan

    EJB3 webservice tutorial

    Anders Thörnström Newbie

      Hi
      i have run the EJB3 webservice tutorial and it works fine. but i need to consume the webserivece from an bean. As I understand this should be done with @webserviceref which is not implemented yet so i tried to use the tutorial client code

      URL url = new URL("http://localhost:8080/tutorial/CalculatorBean?wsdl");
       QName qname = new QName("http://bean.webservice.tutorial.jboss.org/jaws",
       "CalculatorService");
      
       ServiceFactory factory = ServiceFactory.newInstance();
       Service service = factory.createService(url, qname);
      
       Calculator calculator = (Calculator) service.getPort(Calculator.class);
      
       System.out.println("1 + 1 = " + calculator.add(1, 1));
       System.out.println("1 - 1 = " + calculator.subtract(1, 1));


      this however resulted in a Nullpointer @ JSR109ClientMetaDataBuilder.java:72

      My question is: is this a correct way to do this ?
      I thought that the problem was that the correct jars was not included but i have tried to add from the jboss/client but i continue to get this error...

      Thanks
      /Anders


        • 1. Re: EJB3 webservice tutorial
          Anders Thörnström Newbie

          i answer my own post as usual =)
          i solved this by adding the service-ref to a application client and lookup the webservices throw that..

          /Anders

          • 2. Re: EJB3 webservice tutorial
            Thomas Diesler Master

            I'd like to see the stacktrace that relates to the NPE

            • 3. Re: EJB3 webservice tutorial
              Ramzi Maalej Newbie

              Hi, can you tell from where you get the needed library for this tutorial, because it deson't work for me.
              I get this error when compling the sources code.
              compile:
              [javac] Compiling 3 source files to C:\Documents and Settings\Ramzi\Bureau\w
              ebservice\build\classes
              [javac] C:\Documents and Settings\Ramzi\Bureau\webservice\src\org\jboss\tuto
              rial\webservice\bean\Calculator.java:31: incompatible types
              [javac] found : javax.jws.WebService
              [javac] required: java.lang.annotation.Annotation
              [javac] @WebService
              [javac] ^
              [javac] C:\Documents and Settings\Ramzi\Bureau\webservice\src\org\jboss\tuto
              rial\webservice\bean\Calculator.java:32: incompatible types
              [javac] found : javax.jws.soap.SOAPBinding
              [javac] required: java.lang.annotation.Annotation
              [javac] @SOAPBinding(style=Style.RPC)
              [javac] ^
              [javac] C:\Documents and Settings\Ramzi\Bureau\webservice\src\org\jboss\tuto
              rial\webservice\bean\Calculator.java:32: duplicate annotation
              [javac] @SOAPBinding(style=Style.RPC)
              [javac] ^
              [javac] C:\Documents and Settings\Ramzi\Bureau\webservice\src\org\jboss\tuto
              rial\webservice\bean\Calculator.java:35: incompatible types
              [javac] found : javax.jws.WebMethod
              [javac] required: java.lang.annotation.Annotation
              [javac] @WebMethod
              [javac] ^
              [javac] C:\Documents and Settings\Ramzi\Bureau\webservice\src\org\jboss\tuto
              rial\webservice\bean\Calculator.java:38: incompatible types
              [javac] found : javax.jws.WebMethod
              [javac] required: java.lang.annotation.Annotation
              [javac] @WebMethod
              [javac] ^
              [javac] C:\Documents and Settings\Ramzi\Bureau\webservice\src\org\jboss\tuto
              rial\webservice\bean\CalculatorBean.java:30: incompatible types
              [javac] found : javax.jws.WebService
              [javac] required: java.lang.annotation.Annotation
              [javac] @WebService(endpointInterface="org.jboss.tutorial.webservice.bean.Ca
              lculator")
              [javac] ^
              [javac] C:\Documents and Settings\Ramzi\Bureau\webservice\src\org\jboss\tuto
              rial\webservice\client\Client.java:43: warning: [deprecation] org.jboss.tutorial
              .webservice.bean.Calculator in org.jboss.tutorial.webservice.bean has been depre
              cated
              [javac] Calculator calculator = (Calculator) service.getPort(Calculato
              r.class);
              [javac] ^
              [javac] C:\Documents and Settings\Ramzi\Bureau\webservice\src\org\jboss\tuto
              rial\webservice\client\Client.java:43: warning: [deprecation] org.jboss.tutorial
              .webservice.bean.Calculator in org.jboss.tutorial.webservice.bean has been depre
              cated
              [javac] Calculator calculator = (Calculator) service.getPort(Calculato
              r.class);
              [javac] ^
              [javac] C:\Documents and Settings\Ramzi\Bureau\webservice\src\org\jboss\tuto
              rial\webservice\client\Client.java:43: warning: [deprecation] org.jboss.tutorial
              .webservice.bean.Calculator in org.jboss.tutorial.webservice.bean has been depre
              cated
              [javac] Calculator calculator = (Calculator) service.getPort(Calculato
              r.class);
              [javac] ^
              [javac] C:\Documents and Settings\Ramzi\Bureau\webservice\src\org\jboss\tuto
              rial\webservice\client\Client.java:45: warning: [deprecation] add(int,int) in or
              g.jboss.tutorial.webservice.bean.Calculator has been deprecated
              [javac] System.out.println("1 + 1 = " + calculator.add(1, 1));
              [javac] ^
              [javac] C:\Documents and Settings\Ramzi\Bureau\webservice\src\org\jboss\tuto
              rial\webservice\client\Client.java:46: warning: [deprecation] subtract(int,int)
              in org.jboss.tutorial.webservice.bean.Calculator has been deprecated
              [javac] System.out.println("1 - 1 = " + calculator.subtract(1, 1));
              [javac] ^
              [javac] 6 errors
              [javac] 5 warnings

              BUILD FAILED
              file:C:/Documents%20and%20Settings/Ramzi/Bureau/webservice/build.xml:52: Compile
              failed; see the compiler error output for details.

              thanks

              • 4. Re: EJB3 webservice tutorial
                Thomas Diesler Master

                Ramcis, please do not hijack threads with unrelated stuff

                • 5. Re: EJB3 webservice tutorial
                  Hark Jan Newbie

                   

                  "Dust_Puppy" wrote:
                  i answer my own post as usual =)
                  i solved this by adding the service-ref to a application client and lookup the webservices throw that..

                  /Anders



                  Can tell me more details?
                  Please