4 Replies Latest reply on Feb 27, 2004 12:49 PM by Charles Arcudi

    Custom class with Jboss.net

    Charles Arcudi Newbie

      Used the informative site http://www.nsdev.org/jboss/stories/jboss-net.html to build and deploy EJB-based web services on my jboss server. However, when I try to incorporate his process for working with Java Objects as return types or parameters, all bets are off.

      I have been able to generate methods that return Strings and Arrays of Map objects and run test clients against those web services successfully (though there is a fairly elaborate set of gotchas to getting this to work), but I cannot get jboss.net to recognize a custom object (the User object from the example).

      I realize it is a question of scoping, but even for testing purposes, I have not been able to place the class in any of the usual places (jboss-net.sar/jboss-net.war/WEB-INF, server/lib, even JBOSS_DIST/lib) to force jboss-net to recognize it. Frankly, I would prefer to scope it as finitely as possible.

      Any suggestions?

        • 1. Re: Custom class with Jboss.net
          Dr. Christoph Georg Jung Newbie

          The usual place for application objects is ... tara ... the application package, in your case the the ejb-jar.

          To deal with these classes, JBoss.net/Axis however needs mapping information in the form of a serializer/deserializer pair (e.g. a Bean(De)Serializer that canonically maps bean properties to xml elements). This can be specified in the webservice deployment descriptor (in your wsr) as follows:



          Note that as of JBoss3.2, these descriptors can be easily generated using our jboss.net xdoclet module and tag annotations in your custom objects:

          /**
          * A serializable data object for testing data passed to an EJB through
          * the web service interface.
          * @author jung
          * @version $Revision: 1.1.2.1 $
          * @jboss-net:xml-schema urn="hello:HelloData"
          */

          public class HelloData
          implements java.io.Serializable
          {
          private String name;

          public String getName()
          {
          return name;
          }

          public void setName(String name)
          {
          this.name = name;
          }
          }

          Hope that helps,
          CGJ

          • 2. Re: Custom class with Jboss.net
            Charles Arcudi Newbie

            Thank you for your reply, Dr. Jung.

            However, I wanted to let you know that I followed Neal Sanche's example to the letter, including the xml-schema tag you mention in your reply. The generated web-services.xml file appears below.

            As you can see, the cert:User class has been identified by the xdoclet plugin and included in the file. I can confirm that the User class is included in the ejb.jar file as well.

            Our application deployments do have a special application-scoped class loader, but even when I disable that loader, the classDefNotFound errors persist.

            web-services.xml file:

             <?xml version="1.0" encoding="UTF-8" ?>
            - <!--
             -->
            - <!-- This JBoss.Net Web Service Descriptor has been generated by XDoclet
             -->
            - <!-- and is brought to you by F. M. Brier, C. G. Jung and J. Essington
             -->
            - <!--
             -->
            - <deployment name="cert" xmlns="http://xml.apache.org/axis/wsdd/" targetNamespace="http://cvs.east.frontiercorp.com/cert" xmlns:cert="http://cvs.east.frontiercorp.com/cert" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
            - <!--
             The following are declarations of service endpoints targetted to
             session beans
            
             -->
            - <service name="ListProvider" provider="Handler">
             <parameter name="handlerClass" value="org.jboss.net.axis.server.EJBProvider" />
             <parameter name="beanJndiName" value="cap/cert/ejb/ListProviderLocalEjb" />
             <parameter name="allowedMethods" value="getList getListValue" />
            - <requestFlow name="ListProviderRequest">
            - <handler type="java:org.jboss.net.axis.server.JBossAuthenticationHandler">
             <parameter name="securityDomain" value="java:/jaas/cap_hybrid" />
             <parameter name="validateUnauthenticatedCalls" value="false" />
             </handler>
            - <handler type="java:org.jboss.net.axis.server.JBossAuthorizationHandler">
             <parameter name="securityDomain" value="java:/jaas/cap_hybrid" />
             <parameter name="allowedRoles" value="Cert_Admin, Cert_User, Cert_ReadOnly" />
             </handler>
            - <!-- this is a temporary solution to allow immediate (de-)serialization of entity beans in the web service layer
             -->
             <handler type="java:org.jboss.net.axis.server.TransactionRequestHandler" />
             </requestFlow>
            - <responseFlow name="ListProviderResponse">
            - <!-- this is a temporary solution to allow immediate (de-)serialization of entity beans in the web service layer
             -->
             <handler type="java:org.jboss.net.axis.server.SerialisationResponseHandler" />
             <handler type="java:org.jboss.net.axis.server.TransactionResponseHandler" />
             </responseFlow>
             </service>
            - <service name="WebServiceTest" provider="Handler">
             <parameter name="handlerClass" value="org.jboss.net.axis.server.EJBProvider" />
             <parameter name="beanJndiName" value="cap/cert/ejb/WebServiceTestEjbLocal" />
             <parameter name="allowedMethods" value="getName" />
            - <operation name="getName" returnQName="Greeting">
             <parameter name="Name" />
             </operation>
            - <requestFlow name="WebServiceTestRequest">
            - <handler type="java:org.jboss.net.axis.server.JBossAuthenticationHandler">
             <parameter name="securityDomain" value="java:/jaas/cap_hybrid" />
             <parameter name="validateUnauthenticatedCalls" value="false" />
             </handler>
            - <handler type="java:org.jboss.net.axis.server.JBossAuthorizationHandler">
             <parameter name="securityDomain" value="java:/jaas/cap_hybrid" />
             <parameter name="allowedRoles" value="Cert_Admin, Cert_User, Cert_ReadOnly" />
             </handler>
            - <!-- this is a temporary solution to allow immediate (de-)serialization of entity beans in the web service layer
             -->
             <handler type="java:org.jboss.net.axis.server.TransactionRequestHandler" />
             </requestFlow>
            - <responseFlow name="WebServiceTestResponse">
            - <!-- this is a temporary solution to allow immediate (de-)serialization of entity beans in the web service layer
             -->
             <handler type="java:org.jboss.net.axis.server.SerialisationResponseHandler" />
             <handler type="java:org.jboss.net.axis.server.TransactionResponseHandler" />
             </responseFlow>
             </service>
            - <service name="ComplexWebServiceTest" provider="Handler">
             <parameter name="handlerClass" value="org.jboss.net.axis.server.EJBProvider" />
             <parameter name="beanJndiName" value="cap/cert/ejb/ComplexWebServiceTestEjbLocal" />
             <parameter name="allowedMethods" value="getName getMap getUser" />
            - <operation name="getName" returnQName="Greeting">
             <parameter name="Name" />
             </operation>
            - <operation name="getMap" returnQName="MapGreeting">
             <parameter name="someData" />
             </operation>
            - <operation name="getUser" returnQName="UserGreeting">
             <parameter name="name" />
             </operation>
            - <requestFlow name="ComplexWebServiceTestRequest">
            - <handler type="java:org.jboss.net.axis.server.JBossAuthenticationHandler">
             <parameter name="securityDomain" value="java:/jaas/cap_hybrid" />
             <parameter name="validateUnauthenticatedCalls" value="false" />
             </handler>
            - <handler type="java:org.jboss.net.axis.server.JBossAuthorizationHandler">
             <parameter name="securityDomain" value="java:/jaas/cap_hybrid" />
             <parameter name="allowedRoles" value="Cert_Admin, Cert_User, Cert_ReadOnly" />
             </handler>
            - <!-- this is a temporary solution to allow immediate (de-)serialization of entity beans in the web service layer
             -->
             <handler type="java:org.jboss.net.axis.server.TransactionRequestHandler" />
             </requestFlow>
            - <responseFlow name="ComplexWebServiceTestResponse">
            - <!-- this is a temporary solution to allow immediate (de-)serialization of entity beans in the web service layer
             -->
             <handler type="java:org.jboss.net.axis.server.SerialisationResponseHandler" />
             <handler type="java:org.jboss.net.axis.server.TransactionResponseHandler" />
             </responseFlow>
             </service>
            - <!--
             The following are typemappings for entity beans for implementing
             the implicit web-service value-object pattern
            
             -->
            - <!-- The following are typemappings for bean-type value-objects
             -->
             <typeMapping qname="cert:User" type="java:com.frontiercorp.bss.cap.cert.webservice.User" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
            - <!-- There follow merged custom web service descriptions
             -->
             </deployment>


            • 3. Re: Custom class with Jboss.net
              Dr. Christoph Georg Jung Newbie

              which version of jboss are you using?

              (NoClassDefs in contrast to ClassNotFounds are a hint that not the
              target class itself could not be found, but a linked class from there).

              How do you deploy the whole stuff ear(ejb-jar,wsr)?

              Could you maybe send me a small deployment unit such that I could verify it?

              CGJ

              • 4. Re: Custom class with Jboss.net
                Charles Arcudi Newbie

                Dr. Jung. Thank you again for your reply.

                There were two issues I was tripping over. The first (see the odd posting starting with "Eye of Newt" in this forum), had to do with a class collision between the commons-logging.jar file I was loading in my WAR and the commons-loading.jar already in the jboss-net sub-directory. That was easy to solve (once I figured out what was going on).

                This other one had an equally simple solution, though the results are slightly imperfect. If I include a copy of the custom class (actually the full jar from the project) in the wsr file, the class deploys without issue.

                -- Actually, something you said in your last post made me want to try it without the jar. That seems to work now as well --

                The only issue remaining may not have a resolution. The class gets recognized during the WSDL generation as cert:User, but SoapEnvelopes returned from calls to the service list the class as ns1:User, and java sees the class as org.apache.crimson.tree.ElementNode2, which that's probably a default. The upshot is that Java Clients have to treat the object as a Node rather than as an Object. Since our consumer is a .NET client, that may not be an issue.

                If you have any thoughts on this, please let me know:

                (FYI: Jboss 3.2.2. Please let me know if you would still like to see a sample deployment unit.)

                SOAP:

                <?xml version="1.0" encoding="UTF-8" ?>
                
                - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                
                - <soapenv:Body>
                
                - <getUserResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
                
                 <UserGreeting href="#id0" />
                
                 </getUserResponse>
                
                - <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns1:User" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://cvs.east.frontiercorp.com/cert">
                
                 <name xsi:type="xsd:string">My Name</name>
                
                 </multiRef>
                
                 </soapenv:Body>
                
                 </soapenv:Envelope>
                



                WSDL:
                <?xml version="1.0" encoding="UTF-8" ?>
                
                - <wsdl:definitions targetNamespace="http://localhost:8080/jboss-net/services/ComplexWebServiceTest" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://localhost:8080/jboss-net/services/ComplexWebServiceTest" xmlns:intf="http://localhost:8080/jboss-net/services/ComplexWebServiceTest" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://cvs.east.frontiercorp.com/cert" xmlns:tns2="http://net.jboss.org/jmx" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                
                - <wsdl:types>
                
                - <schema targetNamespace="http://cvs.east.frontiercorp.com/cert" xmlns="http://www.w3.org/2001/XMLSchema">
                
                 <import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
                
                - <complexType name="User">
                
                - <sequence>
                
                 <element name="name" nillable="true" type="xsd:string" />
                
                 </sequence>
                
                 </complexType>
                
                 </schema>
                
                - <schema targetNamespace="http://net.jboss.org/jmx" xmlns="http://www.w3.org/2001/XMLSchema">
                
                 <import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
                
                - <simpleType name="ObjectNameType">
                
                - <simpleContent>
                
                 <extension base="xsd:string" />
                
                 </simpleContent>
                
                 </simpleType>
                
                 </schema>
                
                - <schema targetNamespace="http://xml.apache.org/xml-soap" xmlns="http://www.w3.org/2001/XMLSchema">
                
                 <import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
                
                - <complexType name="mapItem">
                
                - <sequence>
                
                 <element name="key" nillable="true" type="xsd:string" />
                
                 <element name="value" nillable="true" type="xsd:string" />
                
                 </sequence>
                
                 </complexType>
                
                - <complexType name="Map">
                
                - <sequence>
                
                 <element maxOccurs="unbounded" minOccurs="0" name="item" type="apachesoap:mapItem" />
                
                 </sequence>
                
                 </complexType>
                
                 </schema>
                
                - <schema targetNamespace="http://localhost:8080/jboss-net/services/ComplexWebServiceTest" xmlns="http://www.w3.org/2001/XMLSchema">
                
                 <import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
                
                - <complexType name="ArrayOf_apachesoap_Map">
                
                - <complexContent>
                
                - <restriction base="soapenc:Array">
                
                 <attribute ref="soapenc:arrayType" wsdl:arrayType="apachesoap:Map[]" />
                
                 </restriction>
                
                 </complexContent>
                
                 </complexType>
                
                 </schema>
                
                 </wsdl:types>
                
                - <wsdl:message name="getNameResponse">
                
                 <wsdl:part name="Greeting" type="xsd:string" />
                
                 </wsdl:message>
                
                - <wsdl:message name="getMapResponse">
                
                 <wsdl:part name="MapGreeting" type="impl:ArrayOf_apachesoap_Map" />
                
                 </wsdl:message>
                
                - <wsdl:message name="getUserRequest">
                
                 <wsdl:part name="name" type="xsd:string" />
                
                 </wsdl:message>
                
                - <wsdl:message name="getMapRequest">
                
                 <wsdl:part name="someData" type="xsd:string" />
                
                 </wsdl:message>
                
                - <wsdl:message name="getNameRequest">
                
                 <wsdl:part name="Name" type="xsd:string" />
                
                 </wsdl:message>
                
                - <wsdl:message name="getUserResponse">
                
                 <wsdl:part name="UserGreeting" type="tns1:User" />
                
                 </wsdl:message>
                
                - <wsdl:portType name="ComplexWebServiceTestEjbLocal">
                
                - <wsdl:operation name="getName" parameterOrder="Name">
                
                 <wsdl:input message="impl:getNameRequest" name="getNameRequest" />
                
                 <wsdl:output message="impl:getNameResponse" name="getNameResponse" />
                
                 </wsdl:operation>
                
                - <wsdl:operation name="getMap" parameterOrder="someData">
                
                 <wsdl:input message="impl:getMapRequest" name="getMapRequest" />
                
                 <wsdl:output message="impl:getMapResponse" name="getMapResponse" />
                
                 </wsdl:operation>
                
                - <wsdl:operation name="getUser" parameterOrder="name">
                
                 <wsdl:input message="impl:getUserRequest" name="getUserRequest" />
                
                 <wsdl:output message="impl:getUserResponse" name="getUserResponse" />
                
                 </wsdl:operation>
                
                 </wsdl:portType>
                
                - <wsdl:binding name="ComplexWebServiceTestSoapBinding" type="impl:ComplexWebServiceTestEjbLocal">
                
                 <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
                
                - <wsdl:operation name="getName">
                
                 <wsdlsoap:operation soapAction="ComplexWebServiceTest" />
                
                - <wsdl:input name="getNameRequest">
                
                 <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/jboss-net/services/ComplexWebServiceTest" use="encoded" />
                
                 </wsdl:input>
                
                - <wsdl:output name="getNameResponse">
                
                 <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/jboss-net/services/ComplexWebServiceTest" use="encoded" />
                
                 </wsdl:output>
                
                 </wsdl:operation>
                
                - <wsdl:operation name="getMap">
                
                 <wsdlsoap:operation soapAction="ComplexWebServiceTest" />
                
                - <wsdl:input name="getMapRequest">
                
                 <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/jboss-net/services/ComplexWebServiceTest" use="encoded" />
                
                 </wsdl:input>
                
                - <wsdl:output name="getMapResponse">
                
                 <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/jboss-net/services/ComplexWebServiceTest" use="encoded" />
                
                 </wsdl:output>
                
                 </wsdl:operation>
                
                - <wsdl:operation name="getUser">
                
                 <wsdlsoap:operation soapAction="ComplexWebServiceTest" />
                
                - <wsdl:input name="getUserRequest">
                
                 <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/jboss-net/services/ComplexWebServiceTest" use="encoded" />
                
                 </wsdl:input>
                
                - <wsdl:output name="getUserResponse">
                
                 <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/jboss-net/services/ComplexWebServiceTest" use="encoded" />
                
                 </wsdl:output>
                
                 </wsdl:operation>
                
                 </wsdl:binding>
                
                - <wsdl:service name="ComplexWebServiceTestEjbLocalService">
                
                - <wsdl:port binding="impl:ComplexWebServiceTestSoapBinding" name="ComplexWebServiceTest">
                
                 <wsdlsoap:address location="http://localhost:8080/jboss-net/services/ComplexWebServiceTest" />
                
                 </wsdl:port>
                
                 </wsdl:service>
                
                 </wsdl:definitions>