5 Replies Latest reply on Sep 6, 2011 7:53 AM by pi4630

    Web service client in EJB 3.x - best practice

    pi4630

      Hi,

       

      up to now I've been using Axis 1.4 to generate classes from the WSDL file with eclipse, not using EJBs at all.

       

      I'm about to write a little proof of concept with EJBs 3.1 and would like to know about which is the best practice in generating a web service client using using EJB 3.1 together with JBoss AS 6.

      I was told I shouldn't really use Axis 1.4 since that could give me problems. My idea is to use Apache CXF runtime, because I read that this is part of JBoss 6 specification.

      Is it necessary to download the runtime and point eclipse to it or can I point and use a library file provided with my JBoss 6 installation (I usually define a user library in eclipse called JBoss, which contains all lib files).

       

      Thank you in advance.

       

      ~pasquale

        • 1. Re: Web service client in EJB 3.x - best practice
          pi4630

          After several unsuccessful attempts to get the webservice client stub and proxies done with wsconsume for this apparently particular WSDL (it points to a xsd of another namespace and wsconsume would throw a java.net.Connection error when trying to access that definition), I was able to generate the client classes using Axis 1.4 and using them by copying the necessary Axis jars into %JBOSS%/server/default/lib directory.

          • 2. Re: Web service client in EJB 3.x - best practice
            mmusaji

            From you original post, what you described should work. Could you upload the WSDL you tried to generate the client stubs from and I'll try and have a look if I get a chance. Also, how was this WSDL generated?

            • 3. Re: Web service client in EJB 3.x - best practice
              pi4630
              • 4. Re: Web service client in EJB 3.x - best practice
                mmusaji

                So I tried using wsconsume.sh directly from a JBoss + CXF and got the following stack

                 

                org.apache.cxf.tools.common.ToolException: Thrown by JAXB : Two declarations cause a collision in the ObjectFactory class.

                    at org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBBindErrorListener.error(JAXBBindErrorListener.java:41)

                    at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.error(SchemaCompilerImpl.java:286)

                    at com.sun.tools.xjc.util.ErrorReceiverFilter.error(ErrorReceiverFilter.java:77)

                    at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:82)

                    at com.sun.tools.xjc.generator.bean.ObjectFactoryGeneratorImpl.populate(ObjectFactoryGeneratorImpl.java:187)

                    at com.sun.tools.xjc.generator.bean.PublicObjectFactoryGenerator.populate(PublicObjectFactoryGenerator.java:55)

                    at com.sun.tools.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.java:242)

                    at com.sun.tools.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.java:175)

                    at com.sun.tools.xjc.model.Model.generateCode(Model.java:286)

                    at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:252)

                    at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:85)

                    at org.apache.cxf.tools.wsdlto.databinding.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:374)

                    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.generateTypes(WSDLToJavaContainer.java:576)

                    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:228)

                    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:128)

                    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:271)

                    at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)

                    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)

                    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)

                    at org.jboss.wsf.stack.cxf.tools.CXFConsumerImpl.consume(CXFConsumerImpl.java:224)

                    at org.jboss.wsf.spi.tools.cmd.WSConsume.importServices(WSConsume.java:230)

                    at org.jboss.wsf.spi.tools.cmd.WSConsume.main(WSConsume.java:81)

                Caused by: com.sun.istack.SAXParseException2: Two declarations cause a collision in the ObjectFactory clas

                 

                It looks like the WSDL has two declarations either within a schema import or the WSDL itself that clash. Axis may ignore this which is why it's not exactly the best because this can lead to issues later when developing client side code. You can try and use databinding to rename any clashes but you need to know what they are first.

                1 of 1 people found this helpful
                • 5. Re: Web service client in EJB 3.x - best practice
                  pi4630

                  Yes, I imagined... but the guys behind that WSDL wouldn't care.

                  I'll make my tests with the Axis 1.4 generated client and stubs, if that works, I'll let it be.

                   

                  Thanks for caring!

                   

                  ~pasquale