EugeneP
EugeneP

Reputation: 12003

Tutorial how to create a CXF web service from existing Java code and embed it in Tomcat

Do you know a tutorial how to create a CXF soap web service from existing Java code and embed it in Tomcat, and also generate a wsdl file so that any .NET system would be able to generate client code easily?

I miss that WSDL creation point in, for example this http://www.ibm.com/developerworks/library/ws-pojo-springcxf/ tutorial. No wsdl file is generated. But still it should be present in my case to provide system interoperability.

Upvotes: 0

Views: 8004

Answers (2)

Nava
Nava

Reputation: 11

To create wsdl file for the existing Java SOAP Service, you can use maven plugin. It will generated wsdl files on {project_home}/target/generated/wsdl/MyService.wsdl

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-java2ws-plugin</artifactId>
    <version>${cxf.version}</version>
    <dependencies>
        <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-simple</artifactId>
        <version>${cxf.version}</version>
        </dependency>
    </dependencies>

    <executions>
        <execution>
            <id>process-classes</id>
        <phase>process-classes</phase>
        <configuration>
            <className>com.foo.MyService</className>
            <genWsdl>true</genWsdl>
            <verbose>true</verbose>
            <frontend>jaxws</frontend>
            <databinding>jaxb</databinding>
        </configuration>
        <goals>
            <goal>java2ws</goal>
        </goals>
        </execution>
    </executions>
</plugin>

Upvotes: 1

zaletniy
zaletniy

Reputation: 549

Do you know a tutorial how to create a CXF soap web service from existing Java code and embed it in Tomcat,

Embedding to Tomcat (to avoid using spring, opening own port): Servlet Transport

also generate a wsdl file

You java code 2 wsdl also maven plugin exists. But you can get the wsdl from working service by http://host:port/servicename?wsdl url and provide it ;)

Upvotes: 1

Related Questions