1 2 Previous Next 15 Replies Latest reply on Aug 24, 2006 4:51 PM by Burr Sutter

    JSR181 Annotated Web Services Intro

    Burr Sutter Master

      Hello,
      I'm trying to find the fastest and easiest way to deploy a JSR181-based Web Service on JBossWS 1.0GA and JBoss AppServer 4.0.4GA (built from source). My goal with this posting is to find out if others are interested in this Getting Started, HelloWorld approach.
      Here is my process to make Hello World work:
      1) Create a directory called MyWS.war in the default\deploy directory
      2) Create the following directory structure under MyWS.war:
      -- WEB-INF\classes\org\jboss\samples
      3) Create the annotated Web Service called HelloWorldWS.java

      package org.jboss.samples;
      
      import javax.jws.WebMethod;
      import javax.jws.WebService;
      import javax.jws.soap.SOAPBinding;
      import javax.jws.soap.SOAPBinding.Use;
      
      
      @WebService(name = "HelloWorld", targetNamespace="http://com.burrsutter.jbossws/helloworld")
      @SOAPBinding(style = SOAPBinding.Style.RPC)
      public class HelloWorldWS
      {
       @WebMethod
       public String sayHello(String toWhom)
       {
       System.out.println("I'm Hit! " + toWhom);
       return "Aloha " + toWhom + " on " + new java.util.Date();
       }
      }
      
      


      4) Use the Java 5 compiler to compile HelloWorldWS.java to HelloWorldWS.class. Here is my classpath to pull off this trick, you'll wish to modify for your JBOSS_HOME:
      set JBOSS_HOME=C:\JBoss\wsdemo4\jboss-4.0.x\build\output\jboss-4.0.4.GA-ejb3
      set CLASSPATH=%CLASSPATH%;%JBOSS_HOME%\server\default\deploy\jbossws.sar\jbossws.jar
      


      5) Create a web.xml file in the WEB-INF folder with the following content:
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation=
      "http://java.sun.com/xml/ns/j2ee
      http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
       <servlet>
       <servlet-name>HelloWorldService</servlet-name>
       <servlet-class>org.jboss.samples.HelloWorldWS</servlet-class>
       </servlet>
       <servlet-mapping>
       <servlet-name>HelloWorldService</servlet-name>
       <url-pattern>/HelloWorldService</url-pattern>
       </servlet-mapping>
      </web-app>
      


      6) In your browser hit: http://localhost:8080/jbossws and click on View the list of deployed Web Services

      7) Click on http://yourhost:8080/MyWS/HelloWorldService?wsdl to view the WSDL.

      DONE! This should be a wiki posting and I'll happily add it once there is some validation by the folks here.

      I always try to use VB.NET as a consumer to prove the interop so I downloaded Visual Basic 2005 Express Edition and it hit the web service.
      Here is the VB.NET code in case you are interested:
      Make sure to add the Web Reference and point it to the url for the WSDL. Plus I added a TextBox and CommandButton to the WinForm.
      This code is in the Button1_Click event delegate
       Dim proxy As New JBossHelloWorld.HelloWorldWSService
       Dim result As String
       result = proxy.sayHello(TextBox1.Text)
       MsgBox(result)
      


      I'm working on an Excel consumer example as well but that is giving me troubles at this moment.

      Burr
      burr.sutter@jboss.com


        • 1. Re: JSR181 Annotated Web Services Intro
          Thomas Diesler Master

          Yes this is the way to go. You can also look at the JSR181 samples that come with jbossws-samples-1.0.0.GA

          Every chapter in the user guide should be backed up with code in the samples

          http://labs.jboss.com/portal/jbossws/user-guide/en/html/endpoints.html#jsr181-endpoints

          • 2. Re: JSR181 Annotated Web Services Intro
            Burr Sutter Master

            Thank you Thomas!

            I'd curious to see if other users of JBossWS find this posting to be useful.

            Now, there is at least one "gotcha" with the Hello World process as described in this thread. The web.xml file is re-written with the one I listed renamed as web.xml.org. This causes a problem if you change and recompile the HelloWorldWS.java file. If this was a servlet I would simply touch the web.xml to have app server hot redeploy it. The trick is to delete the funny looking web.xml file and rename "web.xml.org" to "web.xml" then hot deployment kicks in and all is good. If you simply "touch" the funny web.xml (generated by JBossWS I suspect) you will get a stack trace displayed to the server console, the web service will no longer be available at http://localhost:8080/jbossws View and you'll have to restart the app server to clear things up.

            • 4. Re: JSR181 Annotated Web Services Intro
              Burr Sutter Master

              I'll try my process (steps for building hello world) out again on the 4.0.4.GA to see if its simply a problem with my hand-built App Server with the JBossWS addition. For now there is a fairly simple workaround to my problem.

              Thanks,
              Burr
              burr.sutter@jboss.com

              • 5. Re: JSR181 Annotated Web Services Intro
                Dan Smith Newbie

                I've been trying to do exactly this but have had no luck. So now I've copied your example exactly and tried these steps. I always get the following error with mine and your example:

                08:29:15,625 ERROR [MainDeployer] Could not create deployment: file:/C:/jboss-4.
                0.4.CR2/server/default/deploy/HelloWorldWs.war
                java.lang.ArrayIndexOutOfBoundsException: 0
                 at org.jboss.ws.metadata.AnnotationsMetaDataBuilder.getWebParamAnnotatio
                n(AnnotationsMetaDataBuilder.java:310)
                 at org.jboss.ws.metadata.AnnotationsMetaDataBuilder.processWebMethod(Ann
                otationsMetaDataBuilder.java:388)
                 at org.jboss.ws.metadata.AnnotationsMetaDataBuilder.setupEndpointFromAnn
                otations(AnnotationsMetaDataBuilder.java:153)
                 at org.jboss.ws.metadata.AnnotationsMetaDataBuilderJSE.buildMetaData(Ann
                otationsMetaDataBuilderJSE.java:82)
                 at org.jboss.ws.server.WebServiceDeployerJSE.createWebServicesMetaData(W
                ebServiceDeployerJSE.java:194)
                 at org.jboss.ws.server.WebServiceDeployer.create(WebServiceDeployer.java
                :103)
                 at org.jboss.ws.server.WebServiceDeployerJSE.create(WebServiceDeployerJS
                E.java:65)
                 at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.
                create(SubDeployerInterceptorSupport.java:180)
                 at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterce
                ptor.java:91)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
                java:260)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:190)
                 at $Proxy30.create(Unknown Source)
                 at org.jboss.deployment.MainDeployer.create(MainDeployer.java:953)
                 at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:807)
                 at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
                 at sun.reflect.GeneratedMethodAccessor50.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
                sorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
                er.java:155)
                 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                 at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
                or.java:133)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                 at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
                BeanOperationInterceptor.java:142)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
                java:260)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:190)
                 at $Proxy8.deploy(Unknown Source)
                 at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymen
                tScanner.java:334)
                 at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentS
                canner.java:522)
                 at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
                doScan(AbstractDeploymentScanner.java:207)
                 at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
                loop(AbstractDeploymentScanner.java:218)
                 at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.
                run(AbstractDeploymentScanner.java:197)
                


                The only difference I see is I am using the CR2 and you are building from source. Is this currently working in CR2, or am I missing something?

                Thanks,

                • 7. Re: JSR181 Annotated Web Services Intro
                  Bret Patterson Newbie

                  This was very helpful and helped me alot. However I noticed one thing:
                  if I leave out the web.xml portion my web service shows up in the listing but when I click on the link to see the wsdl it gives http 404
                  If I include the web.xml changes you showed it gives me 2 listing for
                  the same webservice but clicking on the webservice?wsdl it gives me the wsdl and each link works.

                  Wondering what I'm doing wrong.

                  • 8. Re: JSR181 Annotated Web Services Intro
                    Bret Patterson Newbie

                     

                    "bpatters" wrote:
                    This was very helpful and helped me alot. However I noticed one thing:
                    if I leave out the web.xml portion my web service shows up in the listing but when I click on the link to see the wsdl it gives http 404
                    If I include the web.xml changes you showed it gives me 2 listing for
                    the same webservice but clicking on the webservice?wsdl it gives me the wsdl and each link works.

                    Wondering what I'm doing wrong.

                    nm it's finding the web services in my ejb.jar and war file since it's both a webservice and a ejb session bean.

                    • 9. Re: JSR181 Annotated Web Services Intro
                      Christian Betz Newbie

                      Hi!

                      I used your example (and some others, too), and each produces the same result (in 4.0.4.GA):

                      13:13:39,953 ERROR [MainDeployer] Could not create deployment: file:/D:/Programme/jboss-4.0.4.GA/server/default/deploy/S
                      erviceAccounting.war
                      java.lang.ArrayIndexOutOfBoundsException: 0
                      at org.jboss.ws.metadata.AnnotationsMetaDataBuilder.getWebParamAnnotation(AnnotationsMetaDataBuilder.java:322)
                      at org.jboss.ws.metadata.AnnotationsMetaDataBuilder.processWebMethod(AnnotationsMetaDataBuilder.java:400)
                      at org.jboss.ws.metadata.AnnotationsMetaDataBuilder.setupEndpointFromAnnotations(AnnotationsMetaDataBuilder.java:154)


                      below you will find a snippet from the startup logs.


                      Any help on this is very much appreciated.

                      Bye

                      Chris





                      from JBoss startup:
                      ===============================================================================
                      .
                      JBoss Bootstrap Environment
                      .
                      JBOSS_HOME: D:\Programme\jboss-4.0.4.GA\bin\\..
                      .
                      JAVA: C:\Programme\Java\jdk1.5.0_06\bin\java
                      .
                      JAVA_OPTS: -Dprogram.name=run.bat -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcIn
                      terval=3600000
                      .
                      CLASSPATH: C:\Programme\Java\jdk1.5.0_06\lib\tools.jar;D:\Programme\jboss-4.0.4.GA\bin\\run.jar
                      .
                      ===============================================================================
                      .
                      13:12:57,562 INFO [Server] Starting JBoss (MX MicroKernel)...
                      13:12:57,562 INFO [Server] Release ID: JBoss [Zion] 4.0.4.GA (build: CVSTag=JBoss_4_0_4_GA date=200605151000)

                      • 10. Re: JSR181 Annotated Web Services Intro
                        Thomas Diesler Master

                        Does this still show with jbossws-1.0.1.GA ?

                        • 11. Re: JSR181 Annotated Web Services Intro
                          Christian Betz Newbie

                          Hi!

                          No, thanks - in 1.0.1.GA the bug is eliminated.

                          Bye

                          Chris

                          • 12. Re: JSR181 Annotated Web Services Intro
                            M H Newbie

                            Hi,
                            I'm getting this error also. I'm running 4.0.4.GA, upgraged to JBossWS 1.0.2.GA and got the same error (different line #), so I switched to 1.0.1.GA and the error still shows up.

                            I looked at my web.xml and didn't notice anything 'funny' in it. I'd deployed this same service un-annotated and it worked fine.

                            Can someone point this newbie in the right direction? Thanks.

                            19:25:49,445 ERROR [MainDeployer] Could not create deployment: file:/C:/workspace/jboss-4.0.4.GA/server/default/deploy/J
                            SEServicesAnn.war
                            java.lang.ArrayIndexOutOfBoundsException: 0
                             at org.jboss.ws.deployment.JSR181MetaDataBuilder.getWebParamAnnotation(JSR181MetaDataBuilder.java:377)
                             at org.jboss.ws.deployment.JSR181MetaDataBuilder.processWebMethod(JSR181MetaDataBuilder.java:461)
                             at org.jboss.ws.deployment.JSR181MetaDataBuilder.setupEndpointFromAnnotations(JSR181MetaDataBuilder.java:173)
                             at org.jboss.ws.deployment.JSR181MetaDataBuilderJSE.buildMetaData(JSR181MetaDataBuilderJSE.java:72)
                             at org.jboss.ws.deployment.ServiceEndpointDeployer.create(ServiceEndpointDeployer.java:92)
                             at org.jboss.ws.integration.jboss.DeployerInterceptor.create(DeployerInterceptor.java:80)


                            • 13. Re: JSR181 Annotated Web Services Intro
                              M H Newbie

                              nm...need to use 1.5 version.

                              • 14. Re: JSR181 Annotated Web Services Intro
                                TOM zhang Newbie

                                Hi, I got the same error with jboss_portal-2.4.0. Anyone can help us? thanks in advance.

                                loy/jmx-console.war/
                                15:51:07,648 ERROR [MainDeployer] Could not create deployment: file:/C:/jboss-po
                                rtal-2.4.0/server/default/deploy/webservices.war/
                                java.lang.ArrayIndexOutOfBoundsException: 0
                                at org.jboss.ws.metadata.AnnotationsMetaDataBuilder.getWebParamAnnotatio
                                n(AnnotationsMetaDataBuilder.java:322)
                                at org.jboss.ws.metadata.AnnotationsMetaDataBuilder.processWebMethod(Ann
                                otationsMetaDataBuilder.java:400)
                                at org.jboss.ws.metadata.AnnotationsMetaDataBuilder.setupEndpointFromAnn
                                otations(AnnotationsMetaDataBuilder.java:154)
                                at org.jboss.ws.metadata.AnnotationsMetaDataBuilderJSE.buildMetaData(Ann
                                otationsMetaDataBuilderJSE.java:82)
                                at org.jboss.ws.server.WebServiceDeployerJSE.createWebServicesMetaData(W
                                ebServiceDeployerJSE.java:196)
                                at org.jboss.ws.server.WebServiceDeployer.create(WebServiceDeployer.java
                                :103)
                                at org.jboss.ws.server.WebServiceDeployerJSE.create(WebServiceDeployerJS
                                E.java:66)
                                at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.
                                create(SubDeployerInterceptorSupport.java:180)
                                at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterce
                                ptor.java:91)
                                at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
                                java:264)
                                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                                at $Proxy93.create(Unknown Source)
                                at org.jboss.deployment.MainDeployer.create(MainDeployer.java:953)
                                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:807)
                                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
                                at sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
                                sorImpl.java:25)
                                at java.lang.reflect.Method.invoke(Method.java:585)
                                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
                                er.java:155)
                                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                                at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractIntercept
                                or.java:133)
                                at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                                at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelM
                                BeanOperationInterceptor.java:142)
                                at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)

                                1 2 Previous Next