3

i can't find any where how to create web service from server skeletons ( java pojo's )from wsdl using JAXWS. The only tutorials I see are using automated wizard in NetBeans and and axis2 in eclipse. Can someone please give me hints on how to generate server side classes from given wsdl?

Thanks

UPADATE:
I just need to do :
wsimport.bat -Xendorsed SOAP.WSDL
and it creates the artifacts. But now how do I implement it in the server ?

user63898
  • 29,839
  • 85
  • 272
  • 514

3 Answers3

7

In addition to client side classes, wsimport also generates a SEI (Service Endpoint Interface). All you need to do is creating an implementation for that.

Then it should be ready for deployment in your application server.

Answer extended:

If you are using Metro, this is a tutorial on how to map your SEI and SIB (Service Implementation Bean) to the config files and get it ready for deployment.

  • im using Tomcat server . how different it is ? – user63898 Oct 05 '11 at 20:09
  • 1
    it should be exactly the same as the tutorial above. Nevertheless, this is an example of how to do it in Tomcat: http://puretech.paawak.com/2010/03/09/running-jax-ws-with-tomcat/. Also bear in mind the potential class loading issues due to jaxb version mismatching:http://weblogs.java.net/blog/ramapulavarthi/archive/2009/04/tip_for_using_j.html – Gonzalo Garcia Lasurtegui Oct 05 '11 at 20:20
  • The Metro tutorial link is broken. Does anyone know of an alternate? – sdoca Mar 23 '12 at 17:12
1

As pointed out by kevin, this can be done with cxf. They also maintain a maven plugin.

Here's an example on how to generate a server side implementation skeleton:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>2.7.7</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>src/main/gen</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>src/main/webapp/WEB-INF/wsdl/yourWsdl.wsdl
                        </wsdl>
                        <wsdlLocation>classpath:wsdl/yourWsdl.wsdl</wsdlLocation>
                        <!--  Generate WS impl Skeleton -->
                        <extraargs>
                            <extraarg>-impl</extraarg>
                        </extraargs>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>

The -impl option will create a skeleton impl class that provides a basic implementation for your @WebService interface on the server side (provider). Note that this also create a Service class (consumer/client side).

Community
  • 1
  • 1
schnatterer
  • 7,525
  • 7
  • 61
  • 80
1

You can do this using wsdl2j during build phases using maven or ant. Also quite good is the cxf codegen plugin for maven.

kevin
  • 11
  • 1