Notes:
CXF framework, publish webservice services, and use the client to remotely access Webservice Apache CXF is an open services framework, CXF helps you build and develop Services. These Services can support multiple protocols, such as SOAP, POST/HTTP, RESTful HTTP CXF greatly simplifies the service can be naturally and seamlessly integrated with Spring 1. CXF introduction: soa framework is Celtrix (ESB framework ) And XFile (webservice) merged and donated to apache The core is org.apache.cxf.Bus (bus), similar to Spring’s ApplicationContext< span style="white-space:pre"> by default depends on the jar in the Spring Apache CXF distribution package, if all are placed in the lib , JDK1.6 and above are required, otherwise the JAX-WS version inconsistency will be reported. CXF has built-in Jetty server, which is a servlet container, like tomcat2.CXF features is seamlessly connected with Spring and Servlet, and the Servlet container Jetty is integrated in the CXF framework; Support annotated way to publish WebService can display the service list of webservice can add interceptor : Input interceptor, output interceptor, input log information interceptor, output log interceptor, user authority authentication interceptor 3. Configure CXF< span style="white-space:pre">–Client access release: org.apache.cxf.frontend.ServerFactoryBean;//Insufficient specification org.apache.cxf.jaxws.JaxWsServerFactoryBean;//Annotations can be recommended
< p>4.jar package address: http://download.csdn.net/download/qq510372845/9988794< /span>
You can also download it from the apache official website
Example: Implementation: Query development language based on ranking
package com.zhijiao.lkm.language;import javax.jws.WebParam;import javax.jws.WebResult; import javax.jws.WebService;@We bService(serviceName="languageManager")public interface LanguageService {/** * You can modify the return type, method description, and method parameters * @param position * @return */ //@WebMethod(operationName="getlang") public @WebResult( name="languageResult")String getLanguage(@WebParam(name="position")int position);}
package com.zhijiao.lkm .language;import org.apache.cxf.frontend.ServerFactoryBean;import org.apache.cxf.jaxws.JaxWsServerFactoryBean;/** * Development language ranking description service* @author lenovo * */public class LanguageServiceImpl implements LanguageService {/* (non-Javadoc) * @see com.zhijiao.lkm.language.LanguageService#getLanguage(int) */ @Override public String getLanguage(int postion) {String language = null; switch (postion) {case 1: language = " java"; break; case 2: language = "c"; break; case 3: language = "Objective-C"; break; case 4: language = "C#"; break; default: break;} return language;} /** * Publish webservice through the cxf framework ServerFactoryBean * @param address * @param languageService */ private void testWebService1(String address,LanguageService languageService) {ServerFactoryBean serverFactoryBean = new ServerFactoryBean(); serverFactoryBean.setAddress(address);// serverFactoryBean.setServiceClass(LanguageService.class);//The business class or interface of webservice is provided externally. If there is an interface, write the interface, and if there is no interface, write the class serverFactoryBean. setServiceBean(languageService);//Realization of service bean serverFactoryBean.create(); System.out.println("Address:"+address);} /** * Publish webservice through the framework * @param address * @param languageService */ private void testWebService2(String address,LanguageService languageService) {JaxWsServerFactoryBean jaxWsServerFactoryBean = new JaxWsServerFactoryBean(); jaxWsServerFactoryBean.setAddress(address); jaxWsServerFactoryBean.setServiceClass(LanguageService.class); jaxWsServerFactoryBean.setService)(jaxWsServerFactoryBean.setService); jaxWsServerFactoryBean.setAddress(address); ryBean.create(); System.out.println("Address:"+address);} /** Publish webservice through the cxf framework * 1.ServerFactoryBean * --You can publish webservice services without setting annotations, but it is not standardized enough. Support annotations, you cannot modify the label information of wsdl through annotations * --Does not support interceptor adding * 2.JaxWsServerFactoryBean * @param args */ public static void main(String[] args) {LanguageService languageService = new LanguageServiceImpl (); String address="http://127.0.0.1:8080/ws/cxf/languangeService"; LanguageServiceImpl service = new LanguageServiceImpl(); //service.testWebService1(address,languageService); service.testWebService2("http: //127.0.0.1:8080/ws/cxf/languangeService2",languageService); }}