1 2 3 Previous Next 38 Replies Latest reply on Jul 1, 2008 10:14 AM by Borislav Gizdov

    Jbossws Tutorial.

    Zeeshan Javeed Newbie

      I have search a lot to find a starting tutorial for JBossws without EJB and wiht server 4.0.5.
      Can any body help me how to create a very simple Web Service. Which files need to be created, directory structure, where to deploy and how to test it.

      It would be very helpful.

      Regards,
      Zeeshan

        • 1. Re: Jbossws Tutorial.
          Alessio Soldano Master

          Did you take a look at the documentation? In particular, speaking of POJO endpoint, check this:
          http://jbws.dyndns.org/mediawiki/index.php?title=JAX-WS_User_Guide#Plain_old_Java_Object_.28POJO.29

          • 2. Re: Jbossws Tutorial.
            Giuseppe Moscardelli Newbie

            Hi I have read that guide but I haven't understood much.
            First I had to write the class that implements the service but then I don't know what I have to do.
            In that page there's this file xml:

             <web-app ...>
             <servlet>
             <servlet-name>TestService</servlet-name>
             <servlet-class>org.jboss.test.ws.jaxws.samples.jsr181pojo.JSEBean01</servlet-class>
             </servlet>
             <servlet-mapping>
             <servlet-name>TestService</servlet-name>
             <url-pattern>/*</url-pattern>
             </servlet-mapping>
             </web-app>
            

            Must I write this file or this file is generated by jbossws automatically when I deploy a web service? or are there some tools to write it?

            The xml that I copied above is the web.xml required?
            After that I have created my implementation of service ed the xml file, If I understand I must create a jar file and rename it as war, isn't it?

            The last my doubt is about how can I deploy the war?
            In wich directory must I put the war file?

            Thanks to all, bye bye.

            • 3. Re: Jbossws Tutorial.
              Johannes Testori Newbie

              you can do the following: create a zip-file with the follwoing structure (folders are between < and >)
              |
              +-- <META-INF>
              +-- <WEB-INF>
              +-- web.xml
              +--
              +-- put your class-files here (including packages)

              rename the zip-file to a war-file and copy it to <JBOSS_HOME>/server/default/deploy (if you are using the default-server-config)

              • 4. Re: Jbossws Tutorial.
                Johannes Testori Newbie

                hm, something happened with the zip-file-structure:

                 |
                 +-- <META-INF>
                 +-- <WEB-INF>
                 +-- web.xml
                 +-- <classes>
                 +-- put your class-files here (including packages)
                


                • 5. Re: Jbossws Tutorial.
                  Zeeshan Javeed Newbie

                  Hi,
                  Thanks for your response.
                  Again my question is still there. How to start from a scratch?
                  Can you please eloborate how to make a simple HelloWorld Service. Which in ping send message, 'Hello World'
                  My question goes, how to creat this class, how to use tools to create WSDL file.
                  Its clear once u have you .war file how to deploy that. Please give a complete example of HelloWorld from scratch which explains how to use jbossws.
                  Thanks in advance.
                  Regards,
                  Zeeshan

                  • 6. Re: Jbossws Tutorial.
                    Giuseppe Moscardelli Newbie

                    Mmm, I must create a zip file with the class file that describes the web service like this:

                     @WebService
                     @SOAPBinding(style = SOAPBinding.Style.RPC)
                     public class Test
                     {
                     @WebMethod
                     public String echo(String input)
                     {
                     return input;
                     }
                     }
                    


                    In the test.war, I insert test.class and the web.xml.
                    But my problems is the web.xml file, how can I create this?
                    Is it generated automatically by something? And how?
                    Thanks, bye bye.

                    • 7. Re: Jbossws Tutorial.
                      Johannes Testori Newbie

                      copy the web.xml and change the servlet-class to your webservice's class and the servlet-name (twice) to whatever you like to
                      i don't know if it can be created automatically, i always do it manually

                      • 8. Re: Jbossws Tutorial.
                        Zeeshan Javeed Newbie

                        Hi,
                        Can you please do a favour and paste here the compelte files.
                        Test.java (with all imports as I am getting compiling error)
                        web.xml (refering to this Test.java).

                        Please , kick us to start...

                        Regards,
                        Zeeshan.

                        • 9. Re: Jbossws Tutorial.
                          Johannes Testori Newbie

                          java-source (you need jboss-jaxws.jar to compile it)

                          package ws.test; /* you can use any package */
                          
                          import javax.jws.WebMethod;
                          import javax.jws.WebService;
                          import javax.jws.soap.SOAPBinding;
                          
                          @WebService
                          @SOAPBinding(style = SOAPBinding.Style.RPC)
                          public class Test {
                          
                           @WebMethod
                           public String echo(String param) {
                           return param;
                           }
                          
                          }
                          


                          web.xml
                          <?xml version="1.0" encoding="UTF-8"?>
                          
                          <web-app version="2.5"
                           xmlns="http://java.sun.com/xml/ns/javaee"
                           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
                          
                           <servlet>
                           <servlet-name>Test</servlet-name>
                           <servlet-class>ws.test.Test</servlet-class>
                           </servlet>
                          
                           <servlet-mapping>
                           <servlet-name>Test</servlet-name>
                           <url-pattern>/*</url-pattern>
                           </servlet-mapping>
                          
                          </web-app>
                          


                          • 10. Re: Jbossws Tutorial.
                            Zeeshan Javeed Newbie

                            Hi,
                            Thanks for such a great help.
                            Now files are compiled and deployed sucsessfully but I am not able to see any published service on JBOSSWS page. for example
                            http://localhost/jbossws/ is the url where i can see that jbossws is running and up. how I see my my published service??

                            Regards,
                            Zeeshan

                            • 11. Re: Jbossws Tutorial.
                              Johannes Testori Newbie

                              per default the url is http://localhost:8080/jbossws/

                              after deploying the war-file you should see something like this in the log-file (<JBOSS_HOME>/server/default/log/server.log) and/or on the console:

                              8:58,078 INFO [org.jboss.ws.core.server.ServiceEndpointManager] WebService started: http://127.0.0.1:8080/test
                              


                              then you can see the wsdl of your webservice at http://127.0.0.1:8080/test?WSDL



                              • 12. Re: Jbossws Tutorial.
                                Zeeshan Javeed Newbie

                                Hi,
                                NOw let me repeat what I have done

                                Test.Java
                                __

                                import javax.jws.WebMethod;
                                import javax.jws.WebService;
                                import javax.jws.soap.SOAPBinding;

                                @WebService
                                @SOAPBinding(style = SOAPBinding.Style.RPC)
                                public class Test {

                                @WebMethod
                                public String echo(String param) {
                                return param;
                                }

                                }

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

                                <web-app version="2.5"
                                xmlns="http://java.sun.com/xml/ns/javaee"
                                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">


                                <servlet-name>FirstTest</servlet-name>
                                <servlet-class>Test</servlet-class>


                                <servlet-mapping>
                                <servlet-name>FirstTest</servlet-name>
                                <url-pattern>/*</url-pattern>
                                </servlet-mapping>

                                </web-app>

                                __

                                and when I make a war file of this and put in deploy directory of Jboos, I got on console ..

                                14:54:01,371 INFO [TomcatDeployer] deploy, ctxPath=/FirstTest, warUrl=.../tmp/deploy/tmp64909FirstTest-exp.war/

                                Now When I try to go to this url.
                                http://localhost/FirstTest?wsdl
                                it simply comes up with 'Directory Listing For'

                                I think I am still missing something. Are not we suppose to make WSDL file first using some tool. If yes, can you please explain that as well?

                                Regards.

                                • 13. Re: Jbossws Tutorial.
                                  Johannes Testori Newbie

                                  wsdl-file will be created automatically
                                  are there no more log-entries for your deployment?
                                  maybe the structure of your war-file is not correct. could you unzip it and paste a recursive directory-listing here?

                                  • 14. Re: Jbossws Tutorial.
                                    Giuseppe Moscardelli Newbie

                                    Thank you! I deployed my web service. I have generated the web service wsdl, does it means that the web service work correctly?

                                    Another question, I must write a web service that read/write an xml file, what is the current path of the war package?

                                    Thanks again!
                                    Bye Bye.

                                    1 2 3 Previous Next