11 Replies Latest reply on Feb 1, 2005 4:01 PM by Ayodeji Falokun

    Problem with EJB Web service Client

    Gayathiri R Newbie

      We actually agree, but our definitions are different.

      You will note in my example (it is pseudo code) the interceptors are external
      to the bean (target).

      What I want to get across is that the container (advisor) is also a bean
      and should be constructed through dependency injection so it can take advantage
      of microcontainer dependency processing.

        • 1. Re: Problem with EJB Web service Client
          Thomas Diesler Master

          The JAXRPC DII client API does not have any knowledge about the WS4EE deployment artifacts like jaxrpc-mapping.xml.

          In other words, the XML <-> Java mapping is undefined.

          You can:

          a) look up a preconfigured Service from JNDI
          http://www.jboss.org/wiki/Wiki.jsp?page=WSClientAppl

          b) use a propriatary API call when creating the Service

           /**
           * Create a <code>Service</code> instance.
           * <p/>
           * Note, this method is not in the {@link ServiceFactory} interface, it provides the service
           * with additional ws4ee wsdl/java mapping information
           *
           * @param wsdlLocation URL for the WSDL document location
           * @param mappingLocation An optional URL for the jaxrpc-mapping.xml location
           * @param serviceName QName for the service.
           * @param portName An optional port name
           * @return Service.
           * @throws ServiceException If any error in creation of the
           * specified service
           */
           public Service createService(URL wsdlLocation, URL mappingLocation, URL ws4eeMetaData, QName serviceName, String portName) throws ServiceException
          


          • 2. Re: Problem with EJB Web service Client
            Gayathiri R Newbie

            Hi,
            As u told i changed my client code like this

            URL wsdl =new URL("http://192.10.10.58:8080/JoinBean/services/JoinServiceEJB?wsdl");
            
             File file=new File("jaxrpc-mapping.xml");
             URL mappinglocation =file.toURL();
            
             file=new File("ws4ee-deployment.xml");
             URL ws4eeMetaData =file.toURL();
            
             QName qname = new QName("http://join.synxis.org","JoinEndpointService");
             String portName="JoinEndpoint";
            
             Service service=new ServiceFactoryImpl().createService(wsdl,mappinglocation,ws4eeMetaData,qname,portName);



            i m getting this error when i execute this
            Exception in thread "main" java.lang.IllegalAccessError: tried to access field org.apache.axis.client.Service.engine from class org.jboss.webservice.client.ServiceImpl
             at org.jboss.webservice.client.ServiceImpl.getAxisClient(ServiceImpl.java:255)
             at org.apache.axis.client.Service.<init>(Service.java:146)
             at org.jboss.webservice.client.ServiceImpl.<init>(ServiceImpl.java:99)
             at org.jboss.webservice.client.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:147)
             at org.synxis.join.JoinClient1.main(JoinClient1.java:86)
            



            pls advice me if i m wrong.
            pls reply me

            rgds
            Gayathiri

            • 3. Re: Problem with EJB Web service Client
              Gayathiri R Newbie

              Hi

              I tried giving like this....

              org.jboss.webservice.client.ServiceFactoryImpl factory=(org.jboss.webservice.client.ServiceFactoryImpl)ServiceFactory.newInstance();
               Service service=factory.createService(wsdl,mappinglocation,ws4eeMetaData,qname,portName);




              but i m getting
              java.lang.ClassCastException



              can u pls tell wat is the problem....

              rgds
              gayathiri

              • 4. Re: Problem with EJB Web service Client
                Gerhard Otte Newbie

                I'm using this method to access a webservice from an EJB with metadata and portname set to null and it works. Here is the snippet:

                ServiceFactoryImpl factory = new ServiceFactoryImpl();
                 Service svc = factory.createService(
                 new URL("http://localhost:8080/LvsWs/Item?wsdl"),
                 new URL("http://localhost/resources/LVSItemJSE-jaxrpc-mapping.xml"),
                 null,
                 new QName("http://lvsws.emediapark.de", "LVSItemJSE"),
                 null);
                 itemService = (LVSItemServicesEndpoint)svc.getPort(LVSItemServicesEndpoint.class);
                

                Hope this helps,
                Gerhard

                • 5. Re: Problem with EJB Web service Client
                  Gayathiri R Newbie

                  Hi,

                  i m bugged up of this error....I hv given this code in client file

                  ServiceFactoryImpl factory = new ServiceFactoryImpl();
                  javax.xml.rpc.Service service = factory.createService(wsdl,mappinglocation,null,qname,null);


                  but still the same error....i m using jboss-4.0.0. I tried with jboss-4.0.0 also
                  no use...pls help me out
                  Exception in thread "main" java.lang.IllegalAccessError: tried to access field org.apache.axis.client.Service.engine from class org.jboss.webservice.client.ServiceImpl
                   at org.jboss.webservice.client.ServiceImpl.getAxisClient(ServiceImpl.java:306)
                   at org.apache.axis.client.Service.<init>(Service.java:146)
                   at org.jboss.webservice.client.ServiceImpl.<init>(ServiceImpl.java:106)
                   at org.jboss.webservice.client.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:147)
                   at org.synxis.join.JoinClient1.main(JoinClient1.java:251)



                  rgds
                  gayathiri

                  • 6. Re: Problem with EJB Web service Client
                    Gerhard Otte Newbie

                    I'm using this access method from an EJB in other words a J2EE client; is your application a standard java app ? Perhaps different classloaders give a IllegalAccessException. But I'm just guessing.

                    Gerhard

                    • 7. Re: Problem with EJB Web service Client
                      Thomas Diesler Master

                      More likely your client sees some other axis jar than the one we provide (axis-ws4ee.jar)

                      • 8. Re: Problem with EJB Web service Client
                        Gayathiri R Newbie

                        Hi,
                        i m using jboss-4.0.1RC2.i have given axis-ws4ee.jar in my classpath.
                        but still i m getting this exception

                        2005-01-10 13:37:46,033 WARN org.jboss.xml.binding.Unmarshaller[main] - SAX feature not recognized: http://apache.org/xml/features/validation/schema
                        2005-01-10 13:37:46,035 WARN org.jboss.xml.binding.Unmarshaller[main] - SAX feature not recognized: http://apache.org/xml/features/validation/schema-full-checking
                        2005-01-10 13:37:46,035 WARN org.jboss.xml.binding.Unmarshaller[main] - SAX feature not recognized: http://apache.org/xml/features/validation/dynamic
                        2005-01-10 13:37:53,016 ERROR org.jboss.webservice.client.ServiceFactoryImpl[main] - Element type "java-wsdl-mapping" is not declared. @ *unknown*[8,-1]
                        org.xml.sax.SAXException: Element type "java-wsdl-mapping" is not declared. @ *unknown*[8,-1]
                         at org.jboss.xml.binding.Unmarshaller$MetaDataErrorHandler.error(Unmarshaller.java:170)
                         at org.apache.crimson.parser.Parser2.error(Parser2.java:3322)
                         at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1469)
                         at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:634)
                         at org.apache.crimson.parser.Parser2.parse(Parser2.java:333)
                         at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
                         at org.jboss.xml.binding.Unmarshaller.unmarshal(Unmarshaller.java:153)
                         at org.jboss.xml.binding.Unmarshaller.unmarshal(Unmarshaller.java:140)
                         at org.jboss.webservice.metadata.jaxrpcmapping.JavaWsdlMappingFactory.parse(JavaWsdlMappingFactory.java:63)
                         at org.jboss.webservice.client.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:158)
                         at org.synxis.join.JoinClient1.main(JoinClient1.java:245)
                        Exception in thread "main" javax.xml.rpc.ServiceException: org.xml.sax.SAXException: Element type "java-wsdl-mapping" is not declared. @ *unknown*[8,-1]
                         at org.jboss.webservice.client.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:167)
                         at org.synxis.join.JoinClient1.main(JoinClient1.java:245)
                        Caused by: org.xml.sax.SAXException: Element type "java-wsdl-mapping" is not declared. @ *unknown*[8,-1]
                         at org.jboss.xml.binding.Unmarshaller$MetaDataErrorHandler.error(Unmarshaller.java:170)
                         at org.apache.crimson.parser.Parser2.error(Parser2.java:3322)
                         at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1469)
                         at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:634)
                         at org.apache.crimson.parser.Parser2.parse(Parser2.java:333)
                         at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
                         at org.jboss.xml.binding.Unmarshaller.unmarshal(Unmarshaller.java:153)
                         at org.jboss.xml.binding.Unmarshaller.unmarshal(Unmarshaller.java:140)
                         at org.jboss.webservice.metadata.jaxrpcmapping.JavaWsdlMappingFactory.parse(JavaWsdlMappingFactory.java:63)
                         at org.jboss.webservice.client.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:158)
                         ... 1 more


                        the client code is this


                        URL wsdl =new URL("http://192.10.10.58:8080/JoinBean/?wsdl");
                         URL mappinglocation =new URL("http://192.10.10.72/resources/jaxrpc-mapping.xml");
                         QName qname = new QName("http://join.synxis.org","JoinEndpointService");
                         String portName="JoinEndpoint";
                         org.jboss.webservice.client.ServiceFactoryImpl factory= (org.jboss.webservice.client.ServiceFactoryImpl)ServiceFactoryImpl.newInstance();
                         Service service=factory.createService(wsdl,mappinglocation,null,qname,portName);
                        



                        rgds
                        gayathiri

                        • 9. Re: Problem with EJB Web service Client
                          Thomas Diesler Master

                          Your client code uses the crimson parser that is the JDK default and cannot handle xml schema.

                          Use Xerces instead like this

                           <sysproperty key="java.endorsed.dirs" value="${jboss.home}/lib/endorsed"/>
                          




                          • 10. Re: Problem with EJB Web service Client
                            Gayathiri R Newbie

                            Hi,

                            Thanks a lot.....it worked

                            rgds
                            gayathiri

                            • 11. Re: Problem with EJB Web service Client
                              Ayodeji Falokun Newbie

                              I'm having similar issues. Where do I make changes in my code.

                              ----------------------------------
                              My classpath is as follows: C:\Java\JBoss-4.0.1\server\default\deploy\jboss-ws4ee.sar\axis-ws4ee.jar;C:\Java\JBoss-4.0.1\server\default\deploy\jboss-ws4ee.sar\commons-discovery.jar;C:\Java\JBoss-4.0.1\server\default\deploy\jboss-ws4ee.sar\commons-logging.jar;C:\Java\JBoss-4.0.1\server\default\deploy\jboss-ws4ee.sar\jboss-ws4ee.jar;C:\Java\JBoss-4.0.1\server\default\deploy\jboss-ws4ee.sar\wsdl4j.jar;C:\Java\JBoss-4.0.1\client\jboss-jaxrpc.jar;C:\MyTutorials\j2ee14jboss\examples\bank\src;C:\Java\JarFiles\jax-qname.jar

                              -----------------------------------
                              My client code is as follows (from the JBoss tutorial):

                              package com.jboss.ebank;

                              import javax.xml.rpc.Call;
                              import javax.xml.rpc.Service;
                              import javax.xml.rpc.JAXRPCException;
                              import javax.xml.rpc.ServiceFactory;
                              import javax.xml.rpc.ParameterMode;

                              import javax.xml.namespace.QName;
                              import java.util.ArrayList;

                              import java.net.URL;

                              public class WSClient {
                              public static void main(String[] args)
                              throws Exception
                              {
                              URL url =
                              new URL("http://localhost:8080/ws4ee/services/TellerService?wsdl");

                              QName qname = new QName("http://ebank.jboss.com",
                              "TellerService");

                              ServiceFactory factory = ServiceFactory.newInstance();
                              Service service = factory.createService(url, qname);

                              TellerEndpoint endpoint = (TellerEndpoint)
                              service.getPort(TellerEndpoint.class);

                              String customer = "200";
                              String[] ids = endpoint.getAccountsOfCustomer(customer);

                              System.out.println("Customer: " + customer);
                              for (int i=0; i<ids.length; i++) {
                              System.out.println("account[" + ids + "] " +
                              endpoint.getAccountBalance(ids
                              ));
                              }
                              }

                              }