12 Replies Latest reply on Nov 9, 2008 2:50 AM by javaee5

    Not getting instance of Service object from a WSDL file.

    ajayks

      I exposed a stateless EJB3.0 as a web service as per JAX-WS specification.
      I deployed the web service on JBOSS 4.2.2 Application server which created the corresponding WSDL file successfully .I can see the produced WSDL file for the deployed Web service.
      I tried to consume the deployed web service from a java client using following steps :-

      String url="http://dlhlx09.dlh.st.com:20120/mywebservice/Greeting?wsdl";
      URL wsdlLocation=new URL(url);
      QName serviceName = new QName("http://ccc/", "GreetingService");
      Service service = Service.create(wsdlLocation, serviceName);

      But I am getting the static create method of Service class returning null instance of Service object.
      I do not understand why the create method returning null instance of Service object.
      Should I need to install some patch JAX-WS implementation of JBOSS?
      Can any one help me out waht is the problem why I am getting null value for instance of Service object.
      best regards,
      Ajay Kumar,
      ST Microelectronics Ltd.
      Noida,India.

        • 1. Re: Not getting instance of Service object from a WSDL file.
          peterj

          It is easier if you use wsconsume to generate the client stubs. Then your client code would be something like:

          GreetingService svc = new GreetingService();
          Greeting g = svc.getGreetingPort();

          I was going to dig through the source code generated by wsconsume to correct your code, but you can do that just as easily so I will leave it as an exercise for you.

          • 2. Re: Not getting instance of Service object from a WSDL file.
            ajayks

            Thanks a lot peter for the reply.
            I created the client stub for the my deployed web service and
            I called the webservice with the help following code :-

            GreetingService greetingSrv = new GreetingService();
            Greeting greeting =greetingSrv.getGreetingPort();

            But I am getting following run time exeception :-
            Unable to load Provider: Failed to load javax.xml.ws.spi.Provider: com.sun.xml.ws.spi.ProviderImpl

            Could please help me to know how can I load provider as specified in the above exeception.I have included all the jars in the client application and there is no compilation error.

            best regards,
            Ajay Kumar,
            ST Microelectronics Ltd,
            Noida,India.

            • 3. Re: Not getting instance of Service object from a WSDL file.
              peterj

              Are you using wsrunclient to run your client? I have found that the wsrunclient script does not include all of the JARs needed to run a web services client. Here is how I set the classpath (this is for JBoss AS 5.0.0.CR2, the actual list might be different for 4.2.2):

              ## Initialize the environment:
              CLASSPATH=myclient.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/jbossall-client.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/jbossws-native-jaxws.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/jbossws-native-core.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/jbossws-native-jaxws-ext.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/jbossws-spi.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/jbossws-common.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/wsdl4j.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/jboss-xml-binding.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/jbossws-native-jaxrpc.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/activation.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/jbossws-native-saaj.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/mail.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/policy.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/jaxb-api.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/javassist.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/jaxb-impl.jar
              CLASSPATH=$CLASSPATH:$JBOSS_HOME/client/stax-api.jar
              
              ## Invoke the application, letting the user know what is being run:
              APP="$JBOSS_HOME/bin/wsrunclient.sh -classpath $CLASSPATH my.package.name.Client $*"
              echo $APP
              $APP



              • 4. Re: Not getting instance of Service object from a WSDL file.
                ajayks

                Thanks a lot peter for the reply. I am new in JbossWS and I am evaluating it for the use in our organization.
                1.I did not call the web service using wsrunclient.I called it from simple
                java program.
                I found some of the the jars specified by you like jbossws-native-jaxws.jar is not available in my $JBOSS_HOME/client directory. I using JBOSS-4.2.2 application server. Should I need to install jobss JAX-WS patch for the JBOSS- 4.2.2 application server in order to run the web service.If yes, which version of jobss JAX-WS I need to install.

                2.Normally a web service would be called from any environment and
                platform.I want to call it by using WSDL generated.Why I am getting null Service object when I tried to call the web service from its WSDL file using
                below code ? --
                String url="http://dlhlx09.dlh.st.com:20120/mywebservice/Greeting?wsdl";
                URL wsdlLocation=new URL(url);
                QName serviceName = new QName("http://ccc/", "GreetingService");
                Service service = Service.create(wsdlLocation, serviceName);

                Is it only issue of JAX-WS patch which need to be installed.?
                best regards,
                Ajay kumar,
                ST Microleectronics Ltd.,
                Noida,India.

                • 5. Re: Not getting instance of Service object from a WSDL file.
                  peterj

                  1) As I indicated, the list of JARs I gave is for 5.0 CR2. I provided the list mainly to say that you will probably need to add a lot of JARs and your list will most likely be different from mine. What I did was used wsrunclient and when it gave a ClassNotFoundEsxception, I found the JAR containing that class, added it to my classpath, and then ran it again. I did this about a dozen times to find all of the required JARs. You can do the same. You do not need to install anything different, the JBossWS provided with 4.2.x will work just fine. (Actually, what I cannot figure out is why wsrunclient does not already include all of the necessary JAR files - that was what the whole point of that script was.)

                  2) Most likely you are using the wrong names or making the wrong calls. Use wsconsume to generate the stubs and examine the source for the stubs. That should tell you what names you should be using or calls you should be making.

                  • 6. Re: Not getting instance of Service object from a WSDL file.
                    ajayks

                    Thanks Peter for the taking time to reply.
                    1.What is strange in my JBOSS 4.2..2 installation is that I have not finding following jars in my $JBOSS_HOME/client/ path :-
                    jbossws-native-jaxws.jar
                    jbossws-native-core.jar
                    client/jbossws-native-jaxws-ext.jar
                    client/jbossws-native-jaxrpc.jar
                    jbossws-native-saaj.jar

                    In fact these jars are not available in any path of my JBOSS installation.
                    Is the normal JBOSS 4.2.2 installation does not include all these jars .
                    do I need to insatll JBOSS JAX-WS integartion layer in order to make
                    JBOSS JAXWS compliant.
                    2.I made the client stub with wsconsume and I checked the all the names used in the both stub and "stepts to call to make web service using WSDL location".
                    The all the names used both in the stub and in the "stepts to call to make web service using WSDL location" are same.
                    In Fact, I am not able to call deployed web service either with stub created by wsconsume or by using WSDL location primitive.
                    Could please let me know what could be the reason of my problem and what is its soution.
                    with best rehards,
                    Ajay Kumar,
                    ST Microelectronics Ltd.,
                    Noida, India.


                    • 7. Re: Not getting instance of Service object from a WSDL file.
                      ropalka

                       

                      "ajayks" wrote:
                      Thanks Peter for the taking time to reply.
                      1.What is strange in my JBOSS 4.2..2 installation is that I have not finding following jars in my $JBOSS_HOME/client/ path :-
                      jbossws-native-jaxws.jar
                      jbossws-native-core.jar
                      client/jbossws-native-jaxws-ext.jar
                      client/jbossws-native-jaxrpc.jar
                      jbossws-native-saaj.jar

                      These jars were introduced since JBossWS 3.0.1 release.

                      • 8. Re: Not getting instance of Service object from a WSDL file.
                        peterj

                        Go back an read my previous reply, under item #1. You have to do your own searching for the correct set of JAR files. You will probably need to add about 12 JAR files to the classpath. If it were just one or two, I could tell you each time you get a CNFE which JAR you need to add, but doing this form a dozen JARs is too much work. One obvious shortcut is to include every JAR in the jboss_home/client directory in your client's classpath. (Though I vaguely recall that one or two if them are not there but in the server/xxx/lib directory. Anyway, if after adding all of the jboss_home/client jar files you still get a CNFE, post it and I will tell you which JAR it is in.)

                        • 9. Re: Not getting instance of Service object from a WSDL file.
                          ajayks

                          Dear Peter,
                          I have included all the jars from $JBOSS_HOME/client/lib directory in the classpath of client program of web service since begining and it is still not working.
                          Do I need to provide integration layer of web service to the srever in order to run the web service on jboss 4.2.2 server.

                          with best regards,
                          Ajay

                          • 10. Re: Not getting instance of Service object from a WSDL file.
                            peterj

                            I hope this was a typo: $JBOSS_HOME/client/lib, and that you really meant $JBOSS_HOME/client.

                            As I mentioned before

                            PeterJ wrote:
                            (Though I vaguely recall that one or two of [the necessary JAR files] are not there but in the server/xxx/lib directory. Anyway, if after adding all of the jboss_home/client jar files you still get a CNFE, post [the CNFE stack trace] and I will tell you which JAR [the missing class] is in.)


                            • 11. Re: Not getting instance of Service object from a WSDL file.
                              peterj

                              I decided to deploy my simple hello EJB-based web service on 4.2.2. I used the wsrunclient to run my client and the only JAR files I had to add to the classpath were:

                              1 - the JAR file containing my client code and the subs generated by wsconsume
                              2 - jboss_home/client/jbossall-client.jar

                              Then the client ran without errors.

                              (Perhaps my recollection regarding using JAR files from server/xxx/lib is somewhat mistaken. After all, I did that well over a year ago.)

                              • 12. Re: Not getting instance of Service object from a WSDL file.
                                javaee5

                                Hi,

                                How Can I create Object from WSDL in JBoss-4.2.2.GA?

                                Regards,
                                Hatami.