9 Replies Latest reply on Feb 13, 2005 2:41 AM by ranaaich

    Creating Webservice from WSDL

    ranaaich

      Hello All,

      I have read several threads in this forum (JBossWS). Previously I wrote web-service using JBoss.net. However we have decided to rewrite it using JBossWS.

      Previously I was using WSDL2Java tool from Axis - Now as recomended by JBOSSWS I intend to use wscompile to generate the service's RMI interface and a template of the class that implements the interface.

      I am using the following command:

      wscompile -import -keep -d config.xml

      Config.xml points to the WSDL file.
      My intension is to write the Custom Code in the Implementation file after generationg the code.

      My question is - do I need to write jaxrpc-mapping.xml by hand or we can use the wscompile tool for creating jaxrpc-mapping.xml.

      If yes, then which option of wscompile shall I invoke to create jaxrpc-mapping.xml.

      If we have to write by hand how will I input the RequestType and ResponseType mapping in jaxrpc-mapping.xml? I'm not sure If I have to write ws4ee-deployment.xml also.

      Can anyone pleaase throw some light?
      Thanking all in advance.

        • 1. Re: Creating Webservice from WSDL
          andy_wagg

          I used wscompile to create the jaxrpc-mapping.xml using the following option to wscompile,

          -mapping ${src.dir}/WEB-INF/jaxrpc-mapping.xml


          My wsdl was also a .NET document literal and had multiple parameters to the operations, so i also had to use the following wscompile option,

          -f:wsi


          The final problem I had with this was the generated service endpoint interface was correct, but the JBoss geneated wsdd was not, this took my operation with a IN parameter and a return and produced one with just an INOUT parameter.

          To solve this I created a ws4ee-deployment.xml which had to be put in the WEB-INF directory, this just included the operations with the correct return types and parameters etc.

          Hope this helps,

          Andy

          • 2. Re: Creating Webservice from WSDL
            ranaaich

            Hello Andy,
            Thanks for your reply. I got it! Now I can generate mapping file using wscompile. Thanks for your help! But I got stuck again :

            I'm getting error as follows when want to view the service from the browser:

            org.apache.axis.InternalException: java.lang.Exception: The OperationDesc for getQueryService was not synchronized to a method of QueryService.ws.QueryService_PortType.

            Anyway I shall be posting this error in separate thread.

            Thanks for the help.

            • 3. Re: Creating Webservice from WSDL
              andy_wagg

              In your deploy directory for the configuration, you should find the log4j.xml. Find the Axis logger and change it to DEBUG (from INFO). You will then see why it thinks there is a mismatch.

              I had this twice, first as i didn't use wscompile with the -f:wsi switch, so my SEI methods had multiple parameters instead of the one allowed. After fixing that, the JBoss generated wsdd that was deployed didn't match the generated SEI. In my case, the return parameter was treated as an INOUT, it should have been a return parameter and an IN parameter.

              I had to create a ws4ee-deployment.xml in wEB-INF with the correct mappings for the operations. When the wsdd is created by JBoss it merges this file in.

              Andy

              ps. Seems to me with the web services stuff, its just moving from one hurdle to the next.

              • 4. Re: Creating Webservice from WSDL
                ranaaich

                Hello Andy,

                Thanks for your suggestion. I have successfully deployed the webservice by describing the method names and parameters in ws4ee-deployment.xml.

                Now I 'm facing another problem:

                Writing a client that will successfully access the web-service:

                (1) I have to written a stand-alone client using generated stubs from the WSDL file.
                I'm using apache WSDL2Java tool for this. I ve compiled and run the program - only to get the following error:

                11:06:26,564 ERROR [ServerEngine] Server error
                java.lang.IllegalArgumentException: Namespace URI cannot be null
                at org.apache.axis.utils.Mapping.setNamespaceURI(Mapping.java:87)
                at org.apache.axis.utils.Mapping.(Mapping.java:71)
                at org.apache.axis.utils.NSStack.add(NSStack.java:226)
                at org.apache.axis.encoding.DeserializationContextImpl.startPrefixMapping(DeserializationContextImpl.java:991)
                at org.apache.xerces.parsers.AbstractSAXParser.startNamespaceMapping(Unknown Source)
                at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)

                As I continue to browse the JBossWS forum posts I found the mention of the same thing in another post:

                http://www.jboss.org/index.html?module=bb&op=viewtopic&t=58149

                It suggests that developing a client using Axis and with jboss-4.0.1 as server hosting the service - this type error may occur.

                Shall I revert back to Jboss 4.0? What do you suggest?




                • 5. Re: Creating Webservice from WSDL
                  anil.saldhana

                  http://jira.jboss.com/jira/browse/JBWS-64

                  Thomas has added a workaround to this. It will be available in 4.0.1 SP1 to be released sometime soon.

                  • 6. Re: Creating Webservice from WSDL
                    andy_wagg

                    I don't know whether reverting to version 4.0.0 would help. I haven't had that particular problem. I generated a standalone client using wscompile -gen:client -import -f:wsi config.xml.

                    I successfully connect to by webservice and get a response, my problem is that the deserialization doesnt seem to work.


                    arrrggghhhh.

                    Andy

                    • 7. Re: Creating Webservice from WSDL
                      ranaaich

                      I was successfully able to run the Axis-client(It is so easy!) that I have writtten in JBoss 4.0.0(after discarding JBoss 4.0.1). However I would also like to try your approach.

                      So far I have done the following:
                      (1) Created a WSDL by hand. Kept the following following files in WEB-INF directory : webservices.xml, jaxrpc-mapping.xml(generated using wscompile), web.xml and ws4ee-deployment.xml. In WEB-INF/wsdl directory I have kept my wsdl file.
                      (2) executing wscompile with -import -keep (didn't use -gen:server) option and then Customising the implementation file. (Customised code does database query and populates ResponseType Object)
                      (3) Build with ant
                      (4) Deploy the war file in jboss4.0.1
                      (5) Connect to http://myMachineName:8080/wsee and click the view link - YES I can see the My service with WSDL link.

                      Now comes the question of writing the client.

                      From this phase onwards I'm confused.

                      AS this wiki says:
                      http://www.jboss.org/wiki/Wiki.jsp?page=WSClientAppl

                      Do I need to deploy the client in the JBoss server also?

                      Can you bullet out the steps what I need to follow. Which files going to which directory. What shall I do after running wscompile with -gen:client option. Where my own webservice query code will reside? Did you write any DII client? If so - How?

                      Do you again have to do a jndi-lookup for the service endpoint from your testClient? I'm just trying to find other alternatives if I use jboss-4.0.1.

                      Thanks for all the help and advice.

                      • 8. Re: Creating Webservice from WSDL
                        andy_wagg

                        Take a look at the Wikis', Tom has produced a series of step by step examples for both servers and clients.

                        • 9. Re: Creating Webservice from WSDL
                          ranaaich

                          Yeah! I've seen those! I will try to learn the stpes ASAP.
                          Thanks for your help.