This article describes how to install the cxf plug-in eclipse [3.3.2. Develop a simple Java Web Service and integrate it with spring.Install plug-ins:1. Download STP all_in_one fromInstall this plug-in, you can use the link file to install, refer to http://blog.csdn.net/kkdelta/archive/2009/03/12/3983999.aspx2. Download the jar package required by the cxf runtime environment,
Http://people.apache.org/repo/m
, put all the jar packages under the CXF Kit Lib under the project Lib. The CXF Toolkit version used here is: apache-cxf-2.7.13, or maven reference:3, Spring.xml in the configurationxmlns:jaxws= "Http://cxf.apache.org/jaxws"xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/
1, Download CXF development tool Apache-cxf-3.1.4.zip from the Internet ,Unzip the file and locate the Apache-cxf-3.1.4\bin directory containing a Wsdl2java file2. Setting Environment variables1, cxf_home=f\cxf\
This article mainly describes how to use CXF built-in examples, learn to develop Webserivce, use in Web projects, and include spring support.Webserivce can be developed using CXF or axis, as well as httpclient and so on. has been studied many times before, the internet searched a lot of other people's example, wrote the code down, but did not summarize, less nonsense, on dry.1. Download the jar package to C
1. Generate client code
Go to the src directory of the project under cmd: cd d: \ workspaces \ myeclipse 10 \ webservice_cxf_client \ srcd: generate the client code wsdl2java wdsl address
wsdl2java http://localhost:8080/WebService_CXF/WebService/userManager/UserServiceWs?wsdl2. Write a client Interceptor (add a user name to tell the server that it is a valid caller)
Package interceptor; import Java. util. list; import javax. XML. namespace. QNAME; import Org.
popular Web service framework. CXF Way to implement Web Service service demo 1, configuring environment variables Add E:\apache-cxf-2.6.2\lib to ClasspathNew cxf_homee:\apache-cxf-2.6.2Add%cxf_home%\bin in Path 2, using CXF to
Apache cxf:an open-source Services FrameworkThe Apache CXF is an open Source services framework. CXF helps you to build and develop services using frontend programming APIs, like Jax-ws and Jax-rs. These services can speak a variety the protocols such as SOAP, Xml/http, RESTful HTTP, or CORBA and work over a variety of
WEB Service technology widely used, can realize different platform data exchange, now do a CXF WebService small example, for WebService beginners reference.1. Environment construction1.1 Downloads Apache CXF can go to the official download http://cxf.apache.org/. You can also click Http://pan.baidu.com/s/1jIPyOYU I share the cloud disk download (
("system exiting... "); // wait for 60 seconds after hibernation and exit system. exit (0 );}}
If no exception is found after running the main function above. The basic information is as follows:
Service start ......23:29:15 org. Apache. cxf. Service. Factory. reflectionservicefactorybean buildservicefromclassInformation: creating service {http://service.hoo.com/?helloworldserviceservice from class com. Ho
.-----------------------
Apache cxf an open source service framework that implements some of the key standards of JCP and Web service. CXF simplifies construction, integration, and flexible reuse of service-oriented architecture (SOA) business components and technologies. In CXF, Service uses the WSDL standard definit
definition under the project Src/main/webapp/web-inf directory: Cxf-servlet.xml as follows:The definition file takes advantage of the functions of spring and CXF, publishes an ID of HelloWorld, implements Class Com.test.HelloWorldImpl, and publishes a relative path of/helloworld (corresponding absolute directory is: Http://host:port /{webappname}/helloworld) of the webservice.Because we need to use
the server side. CXF generates a remote service proxy object through runtime, and completes access to webservice on the client.
Required fields: setAddress-this is the address when we release webservice.
HelloWorldService: the server must provide a separate Jar file.
package com.crazycoder2010.webservice.cxf.client;import org.apache.cxf.interceptor.LoggingInInterceptor;import org.apache.cxf.interceptor.LoggingOutInterceptor;import org.apache.cxf.jaxw
The service address published on the server is http: // localhost: 8080/webp/WebService/helloworld.
1) Visit the client first to see if it can be accessed. Add URL + to the address published on the server? WSDL; for example: http: // localhost: 8080/webp/WebService/helloworld? WSDLAccess.
If you see the XML document information, it means it is normal.
2) in DOS input cmd run, find the decompressed apache-cxf
BlockerCXF provides input log interceptors Loggingininterceptor and output log interceptors Loggingoutinterceptor, which can be used on the server as well as on the client side. When testing or debugging, the log interceptor can be used to output the server, client requests and received information.Service-Side Log contentJuly 30, 2015 10:51:37 am Org.apache.cxf.services.HelloWSService.HelloWSPort.HelloWSinformation: Inbound message----------------------------Id:1address:http://localhost:8280/c
. userwebservice ") public class userwebserviceimpl implements userwebservice {@ overridepublic user queryuser (User user, integer ID) {system. out. println ("Current User name:" + User. getUserName (); system. out. println ("ID parameter:" + id); Return user ;}@ overridepublic integer querycount (integer count) {return count ;}}
After completing the above steps, we will start to configure our XML
Finally, write a main test result.
Package COM. shadow. extras.
1Course Plan1. Getting Started with WebService (learn) 2, based on jdk1.7 development WebService Service (understand)3, Apache CXF Framework Primer (master) 4. build CRM system based on CXF framework (master)1.1WSDL WebService description / definition language commonly known as "Web service usage manual "Network Service Description / definition language: Each
Introduction
In this article, you will use CXF and Spring to build and develop an order Processing Web service. The WEB service processes or validates orders placed by the customer and returns a unique order ID. After reading this article, you will be able to apply the concepts and features of CXF to build and develop WEB services.
System Requirements
To run the examples in this article, make sure that t
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.