8 Replies Latest reply on Jan 18, 2008 2:23 PM by Bruce Snyder

    1.4.0 Generate source artifacts from WSDL

    Mark Rosenthal Newbie

      I'm experimenting with using the Eclipse tooling to build a contract-first web service.

       

      I'm trying to follow the screencast demo as closely as possible given the version differences.  I've also set the WSDL to document-literal.

       

      After designing the WSDL and using the 1.4.0 tooling, I choose Maven2->Update Source Folders.

      The source artifacts are dropped into target/jaxws instead of target/generated-sources, and therefore are not recognized as "source" by the archetype project.

        • 1. Re: 1.4.0 Generate source artifacts from WSDL
          Bruce Snyder Novice

          This can easily be mitigated by adding a resource element to the project's pom.xml file like so:

           

          <build>
            <resources>
          ...
              <resource>
                <directory>target/jaxws</directory>
                  <includes>
                    <include>**/*</include>
                  </includes>
              </resource>
          ...
            </resources>
          </build>
          

           

          This will tell Maven to recognize the target/jaxws directory as a resource when the Eclipse project files are regenerated.

           

          Bruce

          • 2. Re: 1.4.0 Generate source artifacts from WSDL
            Mark Rosenthal Newbie

            Thanks Bruce,

             

            After updating the pom.xml, target/jaxws now recognized as a source foulder.

             

            As I continue to try following along with the screencast, I notice that the Pricing interface has been generated with a return type of BigDecimal instead of PriceResponseType.  As a result, even though a GetPriceResponse.java class has been generated, the generated PricingServiceImpl.java in target/jaxws implements getPrice with a return type of BigDecimal instead of the expected GetPriceResponse.

             

            I double-checked service.wsdl and it shows the getPrice operation with output type of getPriceResponse.  As with the screencast, getPriceResponse is an instance of getPriceResponseType which contains a sequence with a decimal price element and a string source element.

             

            When performing maven2->update source folders I get the following output:

             

            12/31/07 11:46:02 AM MST: Updated model /PricingService/pom.xml : com.mycompany:Pricing:1.0-SNAPSHOT

            12/31/07 12:16:18 PM MST: Reading /PricingService/pom.xml

            12/31/07 12:16:18 PM MST: Setting source compatibility: 1.5

            12/31/07 12:16:18 PM MST: Setting target compatibility: 1.5

            12/31/07 12:16:18 PM MST: Generating sources /PricingService/pom.xml

            12/31/07 12:16:18 PM MST: Scanning for projects...

            12/31/07 12:16:18 PM MST: -


            12/31/07 12:16:18 PM MST: Building An example JSR-181 Service Unit

            12/31/07 12:16:18 PM MST:     task-segment:

            12/31/07 12:16:18 PM MST: -


            12/31/07 12:16:18 PM MST: artifact org.apache.maven.plugins:maven-compiler-plugin: checking for updates from open.iona.m2

            12/31/07 12:16:19 PM MST: artifact org.apache.maven.plugins:maven-compiler-plugin: checking for updates from central

            12/31/07 12:16:20 PM MST: Unable to get resource from repository open.iona.m2 (http://repo.open.iona.com/maven2)

            12/31/07 12:16:20 PM MST: Unable to get resource from repository central (http://repo1.maven.org/maven2)

            12/31/07 12:16:21 PM MST: Unable to get resource from repository open.iona.m2 (http://repo.open.iona.com/maven2)

            12/31/07 12:16:21 PM MST: Unable to get resource from repository central (http://repo1.maven.org/maven2)

            12/31/07 12:16:23 PM MST: xfire:wsgen

            12/31/07 12:16:23 PM MST: Executing XFire WsGen task with url: file:/home/mrosenth/workspace/Pricing/src/main/resources/service.wsdl

            12/31/07 12:16:24 PM MST: ERROR mojo-execute : xfire:wsgen : command execution failed

            12/31/07 12:16:24 PM MST: ERROR project-execute : com.mycompany:Pricing:jbi-service-unit:1.0-SNAPSHOT (  task-segment: ) : command execution failed

            12/31/07 12:16:24 PM MST: xfire:wsgen

            12/31/07 12:16:24 PM MST: Executing XFire WsGen task with url: file:/home/mrosenth/workspace/Pricing/src/main/resources/service.wsdl

            12/31/07 12:16:24 PM MST: ERROR mojo-execute : xfire:wsgen : command execution failed

            12/31/07 12:16:24 PM MST: ERROR project-execute : com.mycompany:Pricing:jbi-service-unit:1.0-SNAPSHOT (  task-segment: ) : command execution failed

            12/31/07 12:16:24 PM MST: artifact org.apache.maven.plugins:maven-resources-plugin: checking for updates from open.iona.m2

            12/31/07 12:16:24 PM MST: artifact org.apache.maven.plugins:maven-resources-plugin: checking for updates from central

            12/31/07 12:16:24 PM MST: xfire:wsgen

            12/31/07 12:16:24 PM MST: Executing XFire WsGen task with url: file:/home/mrosenth/workspace/Pricing/src/main/resources/service.wsdl

            12/31/07 12:16:24 PM MST: ERROR mojo-execute : xfire:wsgen : command execution failed

            12/31/07 12:16:24 PM MST: ERROR project-execute : com.mycompany:Pricing:jbi-service-unit:1.0-SNAPSHOT (  task-segment: ) : command execution failed

            12/31/07 12:16:24 PM MST: xfire:wsgen

            12/31/07 12:16:24 PM MST: Executing XFire WsGen task with url: file:/home/mrosenth/workspace/Pricing/src/main/resources/service.wsdl

            12/31/07 12:16:24 PM MST: ERROR mojo-execute : xfire:wsgen : command execution failed

            12/31/07 12:16:24 PM MST: ERROR project-execute : com.mycompany:Pricing:jbi-service-unit:1.0-SNAPSHOT (  task-segment: ) : command execution failed

            12/31/07 12:16:24 PM MST: BUILD SUCCESSFUL

            12/31/07 12:16:24 PM MST: Error for project: An example JSR-181 Service Unit (during generate-test-resources)

            12/31/07 12:16:24 PM MST: -


            12/31/07 12:16:24 PM MST: command execution failed

             

            Embedded error: java.io.IOException: Could not find resource 'file:/home/mrosenth/workspace/Pricing/src/main/resources/service.wsdl

            12/31/07 12:16:24 PM MST: -


            12/31/07 12:16:24 PM MST: Trace command execution failed

            12/31/07 12:16:24 PM MST: -


            12/31/07 12:16:24 PM MST: ERROR reactor-execute : /home/mrosenth/workspace/PricingService

            12/31/07 12:16:24 PM MST: BUILD ERRORS

            12/31/07 12:16:24 PM MST: -


            12/31/07 12:16:24 PM MST: Total time: 5 seconds

            12/31/07 12:16:24 PM MST: Finished at: Mon Dec 31 12:16:24 MST 2007

            12/31/07 12:16:25 PM MST: Final Memory: 47M/63M

            12/31/07 12:16:25 PM MST: -


            12/31/07 12:16:25 PM MST: Failed to run generate source goals /PricingService/pom.xml Some builds failed

            12/31/07 12:16:25 PM MST: Adding source folder /PricingService/src/main/java

            12/31/07 12:16:25 PM MST: Adding resource folder /PricingService/src/main/resources

            12/31/07 12:16:25 PM MST: Adding resource folder /PricingService/target/generated-sources

            12/31/07 12:16:25 PM MST: Adding resource folder /PricingService/target/jaxws

            12/31/07 12:16:25 PM MST: JRE compliant to 1.5. org.eclipse.jdt.launching.JRE_CONTAINER[CPE_CONTAINER][K_SOURCE][isExported:false]

            12/31/07 12:16:25 PM MST: Updated source folders for project PricingService

             

            Thanks again for your help.

            • 3. Re: 1.4.0 Generate source artifacts from WSDL
              Mark Rosenthal Newbie

              Sorry... I had done a refactor/rename and didn't realize I needed to update pom.xml.

               

              The updated message is as follows:

               

              After updating the pom.xml, target/jaxws now recognized as a source foulder.

               

              As I continue to try following along with the screencast, I notice that the Pricing interface has been generated with a return type of BigDecimal instead of PriceResponseType.  As a result, even though a GetPriceResponse.java class has been generated, the generated PricingServiceImpl.java in target/jaxws implements getPrice with a return type of BigDecimal instead of the expected GetPriceResponse.

               

              I double-checked service.wsdl and it shows the getPrice operation with output type of getPriceResponse.  As with the screencast, getPriceResponse is an instance of getPriceResponseType which contains a sequence with a decimal price element and a string source element.

               

              When performing maven2->update source folders I get the following output:

               

              12/31/07 12:43:40 PM MST: Updated model /PricingService/pom.xml : com.mycompany:PricingService:1.0-SNAPSHOT

              12/31/07 12:43:40 PM MST: Reading /PricingService/pom.xml

              12/31/07 12:43:40 PM MST: Unable to get resource from repository open.iona.m2 (http://repo.open.iona.com/maven2)

              12/31/07 12:43:40 PM MST: Unable to get resource from repository central (http://repo1.maven.org/maven2)

              12/31/07 12:43:41 PM MST: Unable to get resource from repository open.iona.m2 (http://repo.open.iona.com/maven2)

              12/31/07 12:43:41 PM MST: Unable to get resource from repository central (http://repo1.maven.org/maven2)

              12/31/07 12:43:55 PM MST: Reading /PricingService/pom.xml

              12/31/07 12:43:55 PM MST: Setting source compatibility: 1.5

              12/31/07 12:43:55 PM MST: Setting target compatibility: 1.5

              12/31/07 12:43:55 PM MST: Generating sources /PricingService/pom.xml

              12/31/07 12:43:55 PM MST: Scanning for projects...

              12/31/07 12:43:55 PM MST: -


              12/31/07 12:43:55 PM MST: Building An example JSR-181 Service Unit

              12/31/07 12:43:55 PM MST:     task-segment:

              12/31/07 12:43:55 PM MST: -


              12/31/07 12:43:55 PM MST: artifact org.apache.maven.plugins:maven-compiler-plugin: checking for updates from open.iona.m2

              12/31/07 12:43:55 PM MST: artifact org.apache.maven.plugins:maven-compiler-plugin: checking for updates from central

              12/31/07 12:43:56 PM MST: Unable to get resource from repository open.iona.m2 (http://repo.open.iona.com/maven2)

              12/31/07 12:43:56 PM MST: Unable to get resource from repository central (http://repo1.maven.org/maven2)

              12/31/07 12:43:57 PM MST: Unable to get resource from repository open.iona.m2 (http://repo.open.iona.com/maven2)

              12/31/07 12:43:57 PM MST: Unable to get resource from repository central (http://repo1.maven.org/maven2)

              12/31/07 12:43:58 PM MST: xfire:wsgen

              12/31/07 12:43:58 PM MST: Executing XFire WsGen task with url: file:/home/mrosenth/workspace/PricingService/src/main/resources/service.wsdl

              12/31/07 12:43:59 PM MST: Wsdl11Generator - Generating code for WSDL at file:/home/mrosenth/workspace/PricingService/src/main/resources/service.wsdl with a base URI of file:/home/mrosenth/workspace/PricingService/src/main/resources/service.wsdl

              12/31/07 12:44:00 PM MST: AbstractServiceGenerator - Creating class com.testuri.Pricing

              12/31/07 12:44:00 PM MST: AbstractServiceGenerator - Creating class com.testuri.PricingServiceImpl

              12/31/07 12:44:00 PM MST: ServiceStubGenerator - Found a pre-existing server stub. It will not be overwritten.

              12/31/07 12:44:00 PM MST: xfire:wsgen

              12/31/07 12:44:00 PM MST: Executing XFire WsGen task with url: file:/home/mrosenth/workspace/PricingService/src/main/resources/service.wsdl

              12/31/07 12:44:00 PM MST: Wsdl11Generator - Generating code for WSDL at file:/home/mrosenth/workspace/PricingService/src/main/resources/service.wsdl with a base URI of file:/home/mrosenth/workspace/PricingService/src/main/resources/service.wsdl

              12/31/07 12:44:00 PM MST: AbstractServiceGenerator - Creating class com.testuri.Pricing

              12/31/07 12:44:00 PM MST: AbstractServiceGenerator - Creating class com.testuri.PricingServiceImpl

              12/31/07 12:44:00 PM MST: ServiceStubGenerator - Found a pre-existing server stub. It will not be overwritten.

              12/31/07 12:44:00 PM MST: artifact org.apache.maven.plugins:maven-resources-plugin: checking for updates from open.iona.m2

              12/31/07 12:44:00 PM MST: artifact org.apache.maven.plugins:maven-resources-plugin: checking for updates from central

              12/31/07 12:44:01 PM MST: xfire:wsgen

              12/31/07 12:44:01 PM MST: Executing XFire WsGen task with url: file:/home/mrosenth/workspace/PricingService/src/main/resources/service.wsdl

              12/31/07 12:44:01 PM MST: Wsdl11Generator - Generating code for WSDL at file:/home/mrosenth/workspace/PricingService/src/main/resources/service.wsdl with a base URI of file:/home/mrosenth/workspace/PricingService/src/main/resources/service.wsdl

              12/31/07 12:44:01 PM MST: AbstractServiceGenerator - Creating class com.testuri.Pricing

              12/31/07 12:44:01 PM MST: AbstractServiceGenerator - Creating class com.testuri.PricingServiceImpl

              12/31/07 12:44:01 PM MST: ServiceStubGenerator - Found a pre-existing server stub. It will not be overwritten.

              12/31/07 12:44:01 PM MST: resources:resources

              12/31/07 12:44:01 PM MST: Using default encoding to copy filtered resources.

              12/31/07 12:44:01 PM MST: compiler:compile

              12/31/07 12:44:01 PM MST: Compiling 6 source files to /home/mrosenth/workspace/PricingService/target/classes

              12/31/07 12:44:10 PM MST: jbi:generate-jbi-service-unit-descriptor

              12/31/07 12:44:10 PM MST: Generating jbi.xml

              12/31/07 12:44:10 PM MST: Created Service Unit Analyzer org.apache.servicemix.jsr181.packaging.Jsr181ServiceUnitAnalyzer@10dcddb

              12/31/07 12:44:10 PM MST: Failed to generate jbi.xml: org.apache.servicemix.maven.plugin.jbi.JbiPluginException: Unable to generate service unit descriptor! Unable to generate service unit descriptor!

              12/31/07 12:44:10 PM MST: xfire:wsgen

              12/31/07 12:44:10 PM MST: Executing XFire WsGen task with url: file:/home/mrosenth/workspace/PricingService/src/main/resources/service.wsdl

              12/31/07 12:44:10 PM MST: Wsdl11Generator - Generating code for WSDL at file:/home/mrosenth/workspace/PricingService/src/main/resources/service.wsdl with a base URI of file:/home/mrosenth/workspace/PricingService/src/main/resources/service.wsdl

              12/31/07 12:44:10 PM MST: AbstractServiceGenerator - Creating class com.testuri.Pricing

              12/31/07 12:44:10 PM MST: AbstractServiceGenerator - Creating class com.testuri.PricingServiceImpl

              12/31/07 12:44:10 PM MST: ServiceStubGenerator - Found a pre-existing server stub. It will not be overwritten.

              12/31/07 12:44:10 PM MST: resources:resources

              12/31/07 12:44:10 PM MST: Using default encoding to copy filtered resources.

              12/31/07 12:44:10 PM MST: compiler:compile

              12/31/07 12:44:10 PM MST: Compiling 6 source files to /home/mrosenth/workspace/PricingService/target/classes

              12/31/07 12:44:12 PM MST: jbi:generate-jbi-service-unit-descriptor

              12/31/07 12:44:12 PM MST: Generating jbi.xml

              12/31/07 12:44:12 PM MST: Created Service Unit Analyzer org.apache.servicemix.jsr181.packaging.Jsr181ServiceUnitAnalyzer@14290e2

              12/31/07 12:44:12 PM MST: Failed to generate jbi.xml: org.apache.servicemix.maven.plugin.jbi.JbiPluginException: Unable to generate service unit descriptor! Unable to generate service unit descriptor!

              12/31/07 12:44:12 PM MST: BUILD SUCCESSFUL

              12/31/07 12:44:12 PM MST: -


              12/31/07 12:44:12 PM MST: BUILD SUCCESSFUL

              12/31/07 12:44:12 PM MST: -


              12/31/07 12:44:12 PM MST: Total time: 17 seconds

              12/31/07 12:44:12 PM MST: Finished at: Mon Dec 31 12:44:12 MST 2007

              12/31/07 12:44:13 PM MST: Final Memory: 51M/63M

              12/31/07 12:44:13 PM MST: -


              12/31/07 12:44:13 PM MST: Adding source folder /PricingService/src/main/java

              12/31/07 12:44:13 PM MST: Adding resource folder /PricingService/src/main/resources

              12/31/07 12:44:13 PM MST: Adding resource folder /PricingService/target/generated-sources

              12/31/07 12:44:13 PM MST: Adding resource folder /PricingService/target/jaxws

              12/31/07 12:44:13 PM MST: JRE compliant to 1.5. org.eclipse.jdt.launching.JRE_CONTAINER[CPE_CONTAINER][K_SOURCE][isExported:false]

              12/31/07 12:44:13 PM MST: Updated source folders for project PricingService

               

              Here is the generated PricingServiceImpl.java:

               

               

              package com.testuri;

               

              import java.math.BigDecimal;

              import javax.jws.WebMethod;

              import javax.jws.WebParam;

              import javax.jws.WebResult;

              import javax.jws.WebService;

              import javax.jws.soap.SOAPBinding;

              import javax.xml.datatype.XMLGregorianCalendar;

              import javax.xml.ws.Holder;

              import javax.xml.ws.RequestWrapper;

              import javax.xml.ws.ResponseWrapper;

               

              @WebService(name = "Pricing", targetNamespace = "http://testuri.com")

              @SOAPBinding(use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)

              public interface Pricing {

               

               

                  @WebMethod(operationName = "getPrice", action = "http://testuri.com/getPrice")

                  @RequestWrapper(targetNamespace = "http://testuri.com", localName = "getPrice", className = "com.testuri.GetPrice")

                  @ResponseWrapper(targetNamespace = "http://testuri.com", localName = "getPriceResponse", className = "com.testuri.GetPriceResponse")

                  @WebResult(name = "price", targetNamespace = "")

                  public BigDecimal getPrice(

                      @WebParam(name = "ticker", targetNamespace = "")

                      String ticker,

                      @WebParam(name = "date", targetNamespace = "")

                      XMLGregorianCalendar date,

                      @WebParam(name = "source", targetNamespace = "", mode = WebParam.Mode.OUT)

                      Holder source);

               

              }

               

               

              Thanks again for your help.

              • 4. Re: 1.4.0 Generate source artifacts from WSDL
                Mark Rosenthal Newbie

                Bruce,

                 

                Any thoughts about generated output message type?

                 

                Thanks,

                -Mark

                • 5. Re: 1.4.0 Generate source artifacts from WSDL
                  Mark Rosenthal Newbie

                  On closer inspection of the Eclipse console log, I see the following:

                   

                  1/7/08 3:05:43 PM MST: xfire:wsgen

                  1/7/08 3:05:43 PM MST: Executing XFire WsGen task with url: file:/home/mrosenth/workspace/PricingService/src/main/resources/service.wsdl

                   

                  I'll try invoking wsgen outside of the tooling to see if I get the same results.

                   

                  Does anyone know why xfire is the default instead of cxf?

                  • 6. Re: 1.4.0 Generate source artifacts from WSDL
                    Bruce Snyder Novice

                    My apologies for the late reply. I haven't had the time to run through the whole pricing service example to take a deeper look yet.

                     

                    I recommend using the servicemix-cxf-bc and servicemix-cxf-se instead of servicemix-jsr181. Apache CXF was certified via its use in the Geronimo JavaEE 5 certification and is more robust than the JSR181 SE.

                     

                    Bruce

                    • 7. Re: 1.4.0 Generate source artifacts from WSDL
                      Bruce Snyder Novice

                       

                      Does anyone know why xfire is the default instead of cxf?

                       

                       

                      There is no default, so I'm not sure to what you are referring. As I stated above, however, I recommend using the CXF JBI BC/SE combinartion instead of the JSR181 SE.

                       

                      Bruce

                      • 8. Re: 1.4.0 Generate source artifacts from WSDL
                        Irene Levina Newbie

                        jaxws is default location for the generated code with "wsdl2java" mojo, so even user can manually fixed it in pom as you suggested.

                        I think that archetype pom prototype that used for project layout creation should be changed to reflect this.