Web Service a server to communicate with the client bridge, through the Web service can handle the large amount of data, the Java backend server needs to operate the business needs.
With the CXF (WEB Service Framework) publishing interface, CXF can be well integrated with spring
1, download the CXF version of the relevant jar package, Spring's package is included in it.
2, the core configuration of CXF in Web. xml:
<servlet>
<servlet-name>CXFService</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CXFService</servlet-name>
<url-pattern>/webservices/*</url-pattern>
</servlet-mapping>
3. Configuration of the CFX service in the spring configuration file
<!--Web Service configuration--
<jaxws:endpoint id= "wms" address="/AA">
<jaxws:implementor>
<!--implementation of the Web service Interface class--
<bean class="com.acbee.wms.webservices.impl.WebServices"></bean>
</jaxws:implementor>
</jaxws:endpoint>
4. Web Service Interface Coding
@WebService//This annotation indicates that this interface class belongs to the Web Service
Public interface Ihelloworldservice {
public string SayHello (@WebParam (name = "name") string name);
}
5. Web Service Interface Implementation
@WebService
@SOAPBinding (style = Style.rpc)
public class HelloWorldService implements Ihelloworldservice {
@Override
public string SayHello (string name) {
List<distence> dis=jsonutil.toobjectlist (name, Distence.class);
System.out.println (Dis.get (0). Getdistenceid ());
return null;
}
6. Launch Tomcat, the browser can view the published interface
http://localhost:8080/Project Name/webservices/aa?wsdl
The CXF of Web Service implementation