CXF publishes webservice

 cxf publishing service

first step

Introduce the corresponding jar package in pom.xml

 

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-frontend-jaxws</artifactId>
    <version>2.3.2</version>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http</artifactId>
    <version>2.3.2</version>
</dependency>

 second step

 

   Implementation steps

1. Interface

@WebService
public interface xfiretestCXF {
 public String testmethod(String str);  
}

 

2. Implementation class

@WebService(endpointInterface="cn.ths.emi.webservice.xfire.xfiretestCXF",serviceName="testCXF")
public class xfiretestCXFimpl implements xfiretestCXF{
 
 @Override
 public String testmethod(String str)
 {
  return "abc"+str;
 }
 
}

 

third step

  Modify the spring configuration file

 

(1) Add in the file header of applicationContext.xml

      xmlns:jaxws="http://cxf.apache.org/jaxws"  

      http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd

(2) Specify the bean to be published as a webservice in applicationContext.xml

<!-- webservice start-->

    <import resource="classpath:META-INF/cxf/cxf.xml" />

     <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />

    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

 

    <jaxws:endpoint id="helloService" implementor="com.ths.projects.ths.server.HelloWorldServerImp" address="/helloService" />

<!-- webservice end-->

 the fourth step

 

  Add the following servlet to web.xml to view the deployed webservice

<!-- CXF配置方式 -->
 <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>/webservice/*</url-pattern>
   </servlet-mapping>

the fifth step

Repackage release deployment, start

 

Step 6

Check if the webservice is published successfully

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326443530&siteId=291194637