6 Replies Latest reply on Aug 28, 2003 7:45 AM by cazacov

    How to expose stateless session bean as webservice ?

    cazacov

      I have stateless session bean runing on JBoss 3.2.1 (tomcat bundle). How can I expose it as webservice ?

      I have read article "JBoss-Net Hello World Example" but failed to compile the example. In build.bat there is a line "set CATALINA_HOME=%JBOSS_DIST%\catalina", but I do not have "catalina" directory in my JBoss distribution.

      Is there step-by-step description how to expose EJB beans as webservices ?

        • 1. Re: How to expose stateless session bean as webservice ?
          cazacov

          I modified build.bat and now can compile and run HelloWorld example.

          But problem remains, I have already jar file with session beans and want to automatically generate webservice wrapper to access EJBs from my C++ application. How can I do it ?

          • 2. Re: How to expose stateless session bean as webservice ?
            samart

            the web-service.xml below should help you. the "GLxx" stuff are my own classes/interfaces.

            basically, create a filename.wsr and include that as a module in your ear file. all i have in the wsr is a meta-inf with this web-service.xml file. the interfaces that are mentioned in th web-service.xml are from my ejb's in the .jar that's also in the ear.

            have fun.
            -trevor


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

            <deployment name="PRS" targetNamespace="http://www.gs.com/PRS" xmlns="http://xml.apache.org/axis/wsdd/" 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
            -->

















            • 3. Re: How to expose stateless session bean as webservice ?
              cazacov

              Thanks, Samart, now it runs !!!

              If my method returns primitive type, it works OK. But if I try to return user-defined class, like

              public class TestTransferObject implements java.io.Serializable {

              public int intfield;
              public String strfield;

              public TestTransferObject() {
              intfield = 5;
              strfield = "some text";
              }
              }

              then server throws an exception:
              java.io.IOException: No serializer found for class de.slsag.test.TestTransferObject in registry org.apache.axis.encoding.TypeMappingImpl@a96606

              How can I return composite objects ?

              PS: I use XMLSPY to send SOAP requests to server.

              • 4. Re: How to expose stateless session bean as webservice ?
                cazacov

                Problem solved :-)

                I had to add:
                <beanMapping qname="myNS:TestTransferObject" xmlns:myNS="urn:TestTransferObject" languageSpecificType="java:de.slsag.test.TestTransferObject"/>

                to my web-service.xml file

                • 5. Re: How to expose stateless session bean as webservice ?
                  psien

                  I tried doing this for a stateless session ejb but I get the following error:-

                  org.apache.axis.ConfigurationException: Could not find home in JNDI
                  [java] AxisFault
                  [java] faultCode: {http://xml.apache.org/axis/}Server.generalException
                  [java] faultString: Could not find home in JNDI
                  [java] faultActor: null
                  [java] faultDetail:

                  [java] Could not find home in JNDI
                  [java] javax.naming.NameNotFoundException: TLWebService not bound
                  [java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
                  [java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
                  [java] at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
                  ...

                  here's the application.xml
                  <?xml version="1.0" encoding="UTF-8"?>

                  <display-name>TLWebService</display-name>


                  <web-uri>tlwebservice.war</web-uri>
                  <context-root>TLWebService</context-root>
                  TLWebService.wsr



                  TLWebServiceEJB.jar


                  TLWebService.wsr



                  here's the web-service.xml
                  <?xml version="1.0" encoding="UTF-8"?>

                  <deployment
                  targetNamespace="http://net.jboss.org/TLWebService"
                  xmlns="http://xml.apache.org/axis/wsdd/"
                  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 -->

















                  The session ejb descriptors are standard ejb-jar.xml:-
                  <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>


                  <!-- Generated XML! -->

                  <ejb-jar>
                  <enterprise-beans>

                  <ejb-name>TLWebServiceEJB</ejb-name>
                  com.tlc.webservices.TLWebServiceHome
                  com.tlc.webservices.TLWebService
                  <ejb-class>com.tlc.webservices.TLWebServiceEJB</ejb-class>
                  <session-type>Stateless</session-type>
                  <transaction-type>Container</transaction-type>

                  </enterprise-beans>

                  <assembly-descriptor>
                  <container-transaction>

                  <ejb-name>TLWebServiceEJB</ejb-name>
                  <method-name>*</method-name>

                  <trans-attribute>NotSupported</trans-attribute>
                  </container-transaction>
                  </assembly-descriptor>
                  </ejb-jar>

                  jboss.xml:-
                  <?xml version="1.0"?>

                  <enterprise-beans>

                  <ejb-name>TLWebServiceEJB</ejb-name>
                  <jndi-name>TLWebService</jndi-name>

                  </enterprise-beans>

                  • 6. Re: How to expose stateless session bean as webservice ?
                    cazacov

                    Hi, psien

                    I see some differences in our xml files. Here the are:

                    application.xml


                    TLWebService.wsr



                    web-service.xml
                    <parameter name="homeInterfaceName" value="TLWebServiceLocalHome"/>

                    My bean has same EJB and JNDI names

                    jboss.xml

                    <ejb-name>TLWebService</ejb-name>
                    <jndi-name>TLWebService</jndi-name>


                    I had a vacation at last three weeks, hope you already solved this problem. If not, do not hesitate to contact me by e-mail