2 Replies Latest reply on Aug 19, 2003 9:28 AM by reeves

    export stateless session bean as webservice

    reeves Newbie

      Hi all !

      I want to export my session bean as webservice,
      the problem is that I use complex bean as return value.
      I was able to generate web-service.xml using xdoclet tag
      but I've got "no deserialiser found" when calling my webservice.

      Thanks in advance for any help !


      here my web-service.xml :

      <?xml version="1.0" encoding="UTF-8"?>

      <deployment
      xmlns="http://xml.apache.org/axis/wsdd/"
      targetNamespace="http://net.jboss.org/hello"
      xmlns:hello="http://net.jboss.org/hello"
      xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
      <!-- this is an extension to the Axis deployment descriptor which allows to
      specify the naming environment for the deployed ws logic -->



















      and UserInfo.java
      public class UserInfo implements java.io.Serializable
      {
      private boolean authentified;
      private java.lang.String[] userPlugins;

      public UserInfo() {
      }

      public boolean isAuthentified() {
      return authentified;
      }

      public void setAuthentified(boolean authentified) {
      this.authentified = authentified;
      }

      public java.lang.String[] getUserPlugins() {
      return userPlugins;
      }

      public void setUserPlugins(java.lang.String[] userPlugins) {
      this.userPlugins = userPlugins;
      }

      }



        • 1. Re: export stateless session bean as webservice
          Jon Barnett Master

          UserInfo may be too complex for the standard deserializer to handle. It doesn't look like a standard Bean in that there are not the standard setters and getters. Also, you have a complex get and set element with a String[]. Check the Axis site and the associated WIKI for more information on custom serializers and deserializers. There are also more in-depth discussions in the Axis mailing lists.

          That is all I can suggest at this stage.

          • 2. Reply myself to my question and YES it's POSSIBLE
            reeves Newbie

            In your Ant file :

            Add : <fileset dir="${java.dir}" includes="**/webservice/*.java" /> to your ejbdoclet task
            werservice is the directory which contains all your webservice bean

            Add this subtask to ejbdoclet task
            <jbossnet prefix="yourPrefix"
            destdir="${build.dir}/META-INF/" />

            you should have something like :














            next write your session bean and your UserInfo bean
            in a directory name "webservice"
            ---------------------------------------------------------

            package com.xxx.domain.test;


            import javax.ejb.CreateException;
            import javax.ejb.DuplicateKeyException;
            import javax.ejb.EJBException;
            import javax.ejb.FinderException;
            import javax.ejb.SessionBean;

            import javax.naming.InitialContext;
            import javax.naming.NamingException;


            /**
            *
            * @ejb.bean
            * name="ManageUser"
            * type="Stateless"
            * view-type="both"
            *
            * @ejb.transaction
            * type="Required"
            *
            * @jboss-net.web-service urn="HelloWorldService"
            *
            */

            public abstract class ManageUserEJB
            implements SessionBean
            {

            /**
            * @ejb.interface-method view-type="local"
            * @jboss-net.web-method
            * @jboss-net.wsdd-operation returnQName="ResponseString"
            * @return the string "Hello " + name + "!"
            */
            public String hello(String name)
            {
            return "Hello " + name;
            }

            /**
            * @ejb.interface-method view-type="local"
            * @jboss-net.web-method
            * @jboss-net.wsdd-operation returnQName="ResponseUserInfo"
            */
            public UserInfo login(String name,String password)
            {
            UserInfo u = new UserInfo();

            if ( name.equals("user1") &&
            password.equals("password1"))
            {
            u.setAuthentified(true);
            String[] tabPlugin = {"plugin1","plugin2","plugin3"};
            u.setUserPlugins(tabPlugin);
            System.out.println("Valid [" + u.isAuthentified() + "]");

            }
            else
            {
            u.setAuthentified(false);
            String[] tabPlugin = new String[0];
            u.setUserPlugins(tabPlugin);
            System.out.println("Valid [" + u.isAuthentified() + "]");

            }

            return u;

            }

            //==========================================
            // EJB callbacks
            //==========================================

            /**
            * @ejb.create-method
            */
            public void ejbCreate( )
            throws CreateException {}

            public void ejbPostCreate( )
            throws CreateException {}
            }

            ---------------------------------------------------------
            package com.xxx.webservice;

            /**
            *
            * @jboss-net:xml-schema urn="yourPrefix:UserInfo"
            */
            public class UserInfo implements java.io.Serializable
            {
            private boolean authentified;
            private String[] userPlugins;

            public UserInfo() {
            }

            public boolean isAuthentified() {
            return authentified;
            }

            public void setAuthentified(boolean authentified) {
            this.authentified = authentified;
            }

            public String[] getUserPlugins() {
            return userPlugins;
            }

            public void setUserPlugins(String[] userPlugins) {
            this.userPlugins = userPlugins;
            }

            }

            And that's all ! web-service.xml contains all you want !
            Going to write a real tutorial that explain all this process
            and post it here.

            Just one more thinks, notice that you have to use
            String[] instead of java.lang.String[] don't know why .... :-(