11 Replies Latest reply on Nov 18, 2007 8:12 AM by kyriakost

    Necessary artifacts/descriptors for JAX-WS web service

    bernhard_pauler

      I'm somewhat lost. I don't know what artifacts/descriptors are needed for a >JAX-WS< web service...

      I start with a handwritten WSDL file and use the wsconsume tool to generate the annotated Java source code. I know I have to put the classes in the 'classes' directory and the WSDL file in the 'wsdl' directory under WEB-INF. What descriptors need to go into the WAR file for deployment, which can be generated and how do they need to look like?

      I couldn't find any thorough/step-by-step tutorial on this topic (the "JBossWS 2.0.GA - JAX-WS User Guide" is fairly incomplete in my opinion).

      jaxrpc-mapping.xml, jboss-web.xml, web.xml, webservices.xml?

      Any help greatly appreciated,

      Bernhard

        • 1. Re: Necessary artifacts/descriptors for JAX-WS web service

           

          "bernhard_pauler" wrote:
          I'm somewhat lost. I don't know what artifacts/descriptors are needed for a >JAX-WS< web service...

          I start with a handwritten WSDL file and use the wsconsume tool to generate the annotated Java source code. I know I have to put the classes in the 'classes' directory and the WSDL file in the 'wsdl' directory under WEB-INF. What descriptors need to go into the WAR file for deployment, which can be generated and how do they need to look like?

          I couldn't find any thorough/step-by-step tutorial on this topic (the "JBossWS 2.0.GA - JAX-WS User Guide" is fairly incomplete in my opinion).

          See section 2.1 (POJO endpoints) and 2.2 (SLSB endpoints); anyway the full documentation is coming back soon on the wiki (as soon as the its host is fixed or replaced).

          jaxrpc-mapping.xml, jboss-web.xml, web.xml, webservices.xml?

          You only need web.xml if using pojo endpoints, none of them is using ejb3 slsb endpoints.
          Bye
          Alessio Soldano


          • 2. Re: Necessary artifacts/descriptors for JAX-WS web service
            bernhard_pauler

            I'm not really happy with that - but thanks anyway.

            I think I will go back to JAX-RPC...

            Bernhard

            • 3. Re: Necessary artifacts/descriptors for JAX-WS web service

              Hi

              "bernhard_pauler" wrote:
              I'm not really happy with that - but thanks anyway.

              I think I will go back to JAX-RPC...

              honestly, I can't understand why. JAX-WS definitely simplifies development; moreover you don't need a lot of artifacts as jbossws generates what it needs once you deploy your application.
              May be I'm missing something...
              Bye
              Alessio Soldano

              • 4. Re: Necessary artifacts/descriptors for JAX-WS web service

                Dont make a mistake of going back to JAX-RPC :-), embrace the change as it is for good. Documentation will be avialable their in future, have a look in examples bundled jboss-ws src 2.0.1 ga distribution yyou might find one.
                Any way thats my view,, if you still can get joy than post back and some one will be able to help you or use Jboss consulting servives

                • 5. Re: Necessary artifacts/descriptors for JAX-WS web service

                  Yeah, exactly. Btw full documentation is now available at http://jbws.dyndns.org/mediawiki/index.php?title=JBossWS

                  Alessio Soldano

                  • 6. Re: Necessary artifacts/descriptors for JAX-WS web service
                    bernhard_pauler

                    It's too late. ;)

                    I haven't looked into the documentation yet, but the link is finally working.

                    But seriously - web services is the most frustrating topic I have ever worked on. I understand that it's not a trivial topic but why does it have to be so hard?

                    Sorry, this is probably not the right place for my comment. A good documentation would definitely help people. But perhaps it's already there, hidden behind that link ... ;)

                    Thanks,

                    Bernhard

                    • 7. Re: Necessary artifacts/descriptors for JAX-WS web service

                       

                      "vashistvishal" wrote:
                      Dont make a mistake of going back to JAX-RPC :-), embrace the change as it is for good.


                      Yep, exactly.
                      http://jbws.dyndns.org/mediawiki/index.php?title=JAX-WS_vs_JAX-RPC

                      • 8. Re: Necessary artifacts/descriptors for JAX-WS web service
                        kyriakost

                        Hi all,

                        I am coming back to this topic because it seems that I have the same problem and I cannot overpass it.

                        I have successfully deployed a POJO. Very easy.
                        I am now trying to deploy a WebServiceProvider but I am getting :
                        Cannot obtain wsdl location

                        This is my web.xml :


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

                        <servlet-name>Test</servlet-name>
                        <servlet-class>test.ws.Test</servlet-class>

                        <servlet-mapping>
                        <servlet-name>Test</servlet-name>
                        <url-pattern>/Test</url-pattern>
                        </servlet-mapping>
                        </web-app>


                        my jboss-web.xml :

                        <?xml version="1.0" encoding="ISO-8859-1"?>
                        <!DOCTYPE jboss-web
                        PUBLIC "-//JBoss//DTD Web Application 2.3V2//EN"
                        "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">

                        <jboss-web>
                        <context-root>ws</context-root>
                        </jboss-web>


                        and this is the code :
                        package test.ws;
                        
                        
                        import java.io.ByteArrayInputStream;
                        
                        import javassist.tools.rmi.RemoteException;
                        
                        import javax.jws.WebMethod;
                        import javax.jws.WebParam;
                        import javax.jws.WebResult;
                        import javax.jws.WebService;
                        import javax.jws.soap.SOAPBinding;
                        import javax.xml.transform.Source;
                        import javax.xml.transform.Transformer;
                        import javax.xml.transform.TransformerFactory;
                        import javax.xml.transform.dom.DOMResult;
                        import javax.xml.transform.stream.StreamSource;
                        import javax.xml.ws.Provider;
                        import javax.xml.ws.Service;
                        import javax.xml.ws.ServiceMode;
                        import javax.xml.ws.WebServiceProvider;
                        
                        import org.w3c.dom.Node;
                        
                        @WebServiceProvider
                        @ServiceMode(value = Service.Mode.PAYLOAD)
                        public class Test implements Provider<Source>
                        {
                        
                         public Source invoke(Source source) throws RemoteException {
                         try {
                         DOMResult dom = new DOMResult();
                         Transformer trans = TransformerFactory.newInstance().newTransformer();
                         trans.transform(source, dom);
                         Node node = dom.getNode();
                         Node root = node.getFirstChild();
                         Node first = root.getFirstChild();
                         int number1 = Integer.decode(first.getFirstChild().getNodeValue());
                         Node second = first.getNextSibling();
                         int number2 = Integer.decode(second.getFirstChild().getNodeValue());
                        
                         return sendSource(number1, number2);
                        
                         } catch(Exception e) {
                         e.printStackTrace();
                         throw new RemoteException("Error in provider endpoint");
                         }
                         }
                        
                         private Source sendSource(int number1, int number2) {
                         int sum = number1+number2;
                         String body =
                         "<ns:querySubscriberResponse xmlns:ns=\"http://duke.org\"><return>"
                         +sum
                         +"</return></ns:querySubscriberResponse>";
                         Source source = new StreamSource(
                         new ByteArrayInputStream(body.getBytes()));
                         return source;
                         }
                        }
                        


                        I even tried putting a wsdl inside at
                        WEB-INF/wsdl/TestService.wsdl

                        Where should I put the wsdl so that the deployer can find it ?
                        What other artifacts/deployer-descriptors do I need to make it work ?

                        Thank you in advance !

                        • 9. Re: Necessary artifacts/descriptors for JAX-WS web service
                          kyriakost

                          Can anyone help on this ?

                          • 10. Re: Necessary artifacts/descriptors for JAX-WS web service
                            asoldano

                            Try using the wsdlLocation attribute of @WebServiceProvider and eventually take a look at the org.jboss.test.ws.jaxws.samples.provider test cases.

                            • 11. Re: Necessary artifacts/descriptors for JAX-WS web service
                              kyriakost

                              Thank you Alessio,

                              The wsdlLocation was what was missing. The test cases helped a lot.