Spring integration CXF

Source: Internet
Author: User
Tags webservice annotation

I. Overview

We can add a Web Service layer based on traditional Java EE applications, so that our Java EE applications can leak Web services externally, in this way, the Java EE application can be called by any platform or program written in any language.


2. Steps




<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + CjEuINDCvah3ZWK5pLPMc3ByaW5nQ1hGLCCyori01sbQ6NKqtcRKYXKw/fill = "brush: java;"> ContextConfigLocation /WEB-INF/config/applicationContext. xml Org. springframework. web. context. ContextLoaderListener CXFServlet Org. apache. cxf. transport. servlet. CXFServlet CXFServlet /WebService /*

3. Import the Schema and xml configuration file provided by CXF in the Spring configuration file applicationContext. xml, and use the jaxws: endpoint element to expose the web service.

 
 
  
  
  
  
  
  
 
4. interfaces and implementation classes:

HelloService

// Annotation with @ WebService Annotation, indicating that this interface will correspond to a Web Services @ WebServicepublic interface HelloService {// define a method, this method will be exposed as a Web Services Operation public void sayHello (String name );}
HelloServiceImpl

@WebService(endpointInterface = "com.zdp.service.HelloService")public class HelloServiceImpl implements HelloService{ public void sayHello(String name) {System.out.println("hello " + name + ", current time is " + new Date());}}
5. Start the tomcat server

6. Create a Java project cxf_Client and enter the src directory of the project on the command line.

Run the following command: wsdl2java http: // localhost: 9999/springCXF/webService/sayHello? Wsdl

7. Write a test class:

Public class MyClient {public static void main (String [] args) {HelloServiceImplService factory = new HelloServiceImplService (); HelloService helloService = factory. getHelloServiceImplPort (); // return a proxy helloService. sayHello ("zhangsan ");}}


3. Configure the interceptor

In fact, the configuration interceptor is to add a configuration in applicationContext. xml, the specific interceptor class see the previous blog: http://blog.csdn.net/zdp072/article/details/29245575

 
 
  
  
  
  
        
   
  
                 
              
    
  
 


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.