CXF Study Tour (iii)-Generate Java code from WSDL generation using MAVEN __java

Source: Internet
Author: User

Turn:

http://blog.csdn.net/yuguiyang1990/article/details/9800851

Long time no see CXF, and recently used, here according to daily use, and then finishing.

OK, let's review how to use MAVEN to create a CXF project. 1. According to the previous blog, create a new Web project 2. Modify Pom.xml

[HTML] View Plain copy print? <project xmlns= "http://maven.apache.org/POM/4.0.0"  xmlns:xsi= "http://www.w3.org/2001/ Xmlschema-instance "     xsi:schemalocation=" http://maven.apache.org/POM/4.0.0 http:// Maven.apache.org/maven-v4_0_0.xsd ">     <modelVersion>4.0.0</modelVersion>      <groupId>org.ygy.cxf</groupId>     <artifactId> cxf-date</artifactid>     <packaging>war</packaging>      <version>0.0.1-SNAPSHOT</version>     <name>cxf-date maven  Webapp</name>     <url>http://maven.apache.org</url>          <!--  Property configuration  -->       < properties>           <project.build.sourceEncoding> UTF-8</project.build.sourceEncoding>           < cxf.version>2.7.5</cxf.version>           < spring.version>3.1.1.release</spring.version>       </properties>           <dependencies>            <dependency>                <groupId>junit</groupId>                <artifactId>junit</artifactId>                <version>4.10</version>                <scope>test</scope>            </dependency>                          <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-transports-http</artifactid>                <version>${cxf.version}</version>            </dependency>              < dependency>               <groupid >org.apache.cxf</groupId>                <artifactId>cxf-rt-transports-http-jetty</artifactId>                <version>${cxf.version}</version>            </dependency>               <dependency>                <groupid>org.springframework</groupid>                <artifactId>spring-context</artifactId>                <version>${spring.version}</version>            </dependency>               <dependency>                <groupId>org.springframework</groupId>                <artifactId>spring-web</artifactId>                <version>${ spring.version}</version>           </dependency>       &Nbsp;       <dependency>                <groupId>org.eclipse.jetty</groupId>                <artifactid>jetty-webapp</ artifactid>               <version >8.1.11.v20130520</version>           </ dependency>          </dependencies>          <build>           <finalname >cxf-date</finalName>       </build>   </project>   

<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" > <modelversion >4.0.0</modelVersion> <groupId>org.ygy.cxf</groupId> <artifactid>cxf-date</ artifactid> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name> Cxf-date Maven webapp</name> <url>http://maven.apache.org</url> <!--property configuration--> <properti Es> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <cxf.version>2.7.5 </cxf.version> <spring.version>3.1.1.RELEASE</spring.version> </properties> < dependencies> <dependency> <groupId>junit</groupId> &LT;ARTIFACTID&GT;JUNIT&LT;/ARTIFACTID&G
			T
		<version>4.10</version> <scope>test</scope></dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactid>cxf-rt- frontend-jaxws</artifactid> <version>${cxf.version}</version> </dependency> <dependenc Y> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> & lt;version>${cxf.version}</version> </dependency> <dependency> &LT;GROUPID&GT;ORG.APACHE.CXF </groupId> <artifactId>cxf-rt-transports-http-jetty</artifactId> <version>${cxf.version} </version> </dependency> <dependency> <groupId>org.springframework</groupId> < Artifactid>spring-context</artifactid> <version>${spring.version}</version> </dependency > <dependency> <groupId>org.springframework</groupId> <artifactid>spring-web</artif Actid> <version>${spring.version}</version> </dependency> <dependency> <groupid>org.eclipse.jetty</groupid&gt
			; <artifactId>jetty-webapp</artifactId> <version>8.1.11.v20130520</version> </ dependency> </dependencies> <build> <finalName>cxf-date</finalName> </build> </
 Project>

3. Modify Web.xml

[HTML] View Plain copy print? <?xml version= "1.0"  encoding= "UTF-8?>   <web-app version=" 2.5 " xmlns=" Http://java.sun.com/xml/ns/javaee "            xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"              xsi:schemalocation= "http://java.sun.com/xml/ns/javaee              http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd ">                    <context-param>            <param-name>contextConfigLocation</param-name>            <param-value>classpath:applicationcontext.xml</ param-value>       </context-param>      &NBsp;  <listener>         <listener-class>              org.springframework.web.context.contextloaderlistener         </ listener-class>      </listener>                  <servlet>              <servlet-name>CXFServlet</servlet-name>                 <servlet-class> org.apache.cxf.transport.servlet.cxfservlet</servlet-class>              <load-on-startup>1</load-on-startup>          </servlet>         <servlet-mapping>             <servlet-name> cxfservlet</servlet-name>             < url-pattern>/services/*</url-pattern>         </ servlet-mapping>              </web-app>   

<?xml version= "1.0" encoding= "UTF-8"?> <web-app version= "2.5" xmlns= "Http://java.sun.com/xml/ns/javaee" 
         Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee Http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd "> <context-param> <param-name>contex Tconfiglocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </ context-param> <listener> <listener-class> Org.springframework.web.context.ContextLoader Listener </listener-class> </listener> <servlet> &LT;SERVLET-NAME&GT;CXFSE Rvlet</servlet-name> <servlet-class>org.apache.cxf.transport.servlet.cxfservlet</servlet-clas  
        s> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>cxFservlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping>

 </web-app>

4. Write Service Interface

[Java] View Plain copy print? package org.ygy.cxf.entity;      import java.io.serializable;   Import  java.util.Date;      public class bookentity implements  serializable {       private static final long  serialversionuid = -860948461727285535l;          private  Integer id;       private String name;        private String author;       private Date  publicationdate;//Publication date           public integer getid ()  {            return id;        }          public void setid (integer id)  {  &nbsP         this.id = id;  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.