The CXF of Web Service implementation

Source: Internet
Author: User

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

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.