There is a growing need for SOA concepts in today's projects, and in a recent project I have taken on a business requirement that requires access to a Java-developed web system in a client system developed by. NET, a business requirement that naturally requires the operation of information data through WebService. Below, we will explore in the development of a bit of experience and lessons to summarize the following, for everyone's reference.The entire architecture of our project uses a more pop
the client and server side use gzip compression is also based on HTTP protocol negotiation (check the request header for Accept-encoding:gzip). But it needs to be weighed carefully. For small data volumes, enabling gzip compression support is a thankless behavior, when the amount of data is small, gzip compression results are not obvious, but also a waste of CPU. We need to weigh the size of the data and set threshold to 10*1024byte based on experience.Enable the following configuration in the
As the project is serviced, the use of WebService is common in some large projects, and here are two ways to generate client code based on the service address provided.
Note: You need to configure the environment variables when using both of these methods. CXF Configuration and JDK configuration is roughly the same, here is not explained, not configured a good Baidu.
(1) The JDK provides a wsimport.exe command that is used to generate client code for
Theory with practice, only to talk about the theory that it became an armchair, with a HelloWorld demo can be more intuitive. Let's start with the explanation:First to the official Apache network download apache-cxf-2.2.2, (now has a higher version 2.4) address: http://cxf.apache.org/Create a new Java Project, import cxf common. Jar packages, CXF common jar packa
Theory with practice, only talk about theory that became an armchair, with a HelloWorld demo can be more intuitive. Let's start with the explanation below:First to the Apache official Web download apache-cxf-2.2.2, (now has a higher version 2.4) address: http://cxf.apache.org/Create a new Java Project, import cxf common. Jar packages, CXF common jar packages are
In the previous article, WebService's server and client were started separately, but in real-world projects, it was not practical to start the server alone, or to integrate the framework to start, so today it will document how to integrate the spring framework.The jar package is as follows:http://yun.baidu.com/share/link?shareid=547689626uk=2836507213(i), add Spring and CXF configuration in Web. xml(ii), create new interface file, implement classinter
Publish the WebService interface via springSpring jar Package +CXF jar Java package The following files missing jar packages need to be downloaded by themselvesProject structure1. Entity classPackage Com.test.entity;public class User {public user (string name, string pwd, string sex) {super (); this.name = Name;this . pwd = Pwd;this.sex = sex;} private string Name;private string Pwd;private string Sex;public string GetName () {return name;} public voi
(); } os.close (); }//organization SOAP data public static string GetXML (String cityname) {string soapxml = "Third way of using browser access2. CXF FrameworkCXF is an open-source WebService frameworkCXF Support Soap1.1/1.2,rest ProtocolCXF support for Xml,json (rest only) data formatsServer-side JAX-ws mode (SOAP)@BindingType (soapbinding.soap12http_binding) is published by default SOAP1.1, which is published Soap1.2@webservicepublic interface
This article link: http://blog.csdn.net/kongxx/article/details/7527094
Apache CXF One of the actual combat Hello World Web Service
Apache CXF Combat II Integrated sping and Web container
The first two articles describe how to build the most basic web Service through CXF, and the exposed interface parameters and return values are strings, and let's look at a sligh
Java_home---The meaning of this variable is the Java installation path, the machine is D:\JDK, remember not to add in the back; the semicolon is written D:\JDK;
In the future to be anywhere else with D:\JDK\bin can be written directly%java_home%\bin, equivalent to the path named, its
It's OK to not configure java_home, but for example, your JDK path has changed, and it will be troublesome to change places accordingly, and
Some Third-party software will agree to use Java_home variables (such as:
For example, call the Ipaddresssearchwebservice service provided by http://www.webxml.com.cn/.1. Using the Wsdl2java tool to generate JAX-WS clients based on WSDLWsdl2java-client "HTTP://WEBSERVICE.WEBXML.COM.CN/WEBSERVICES/IPADDRESSSEARCHWEBSERVICE.ASMX?WSDL"2. Import the generated code into the project. (May error, need to modify)3. Access the service. Packagecom.huey.demo.test;ImportOrg.apache.cxf.interceptor.LoggingInInterceptor;ImportOrg.apache.cxf.interceptor.LoggingOutInterceptor;ImportOr
1.maven Configurationxsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" >2. Web. XML configuration"-//sun Microsystems, INC.//DTD Web application 2.3//en""Http://java.sun.com/dtd/web-app_2_3.dtd" >Classpath:spring.xmlNote: Spring version 3.2.8 CXF version 2.5.2CXF + Spring + Maven Development WebService
The previous two articles introduced how to build the most basic Web Service through CXF, And the exposed interface parameters and return values are strings. Let's take a look at a slightly more complex example.
1. A common pojo object is used to represent an object class.
packagecom.googlecode.garbagecan.cxfstudy.jaxws;
importjava.util.Date;
publicclassCustomer{
privateStringid;
privateStringname;
privateDatebirthday;
pub
. getOutInterceptors (). add (new GZIPOutInterceptor ());
The above code tells CXF to use the compressed Interceptor to compress and decompress data packets.
packagecom.googlecode.garbagecan.cxfstudy.compress;
importorg.apache.cxf.endpoint.Client;
importorg.apache.cxf.endpoint.Endpoint;
importorg.apache.cxf.frontend.ClientProxy;
importorg.apache.cxf.interceptor.LoggingInInterceptor;
importorg.apache.cxf.interceptor.LoggingOutInt
CXF calls webservice timeout settings, and cxfwebservice times out
I found a lot of methods on the Internet and finally found one. record it.
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean (); factory. setServiceClass (Service1Soap. class); // set the request interface factory. setAddress ("http ://*. *. *. */SMSService/Service1.asmx? WSDL "); Service1Soap esbServer = (Service1Soap) factory. create (); // create a client object // Set Clie
In CXF (2.7.10)-restful services describes the RESTful WebService service, where data transfer is based on XML format. If you want to transfer data based on JSON format, @Produces ("Application/xml") is modified to @Produces ("Application/json"). Packagecom.huey.demo.ws;Importjava.util.List;ImportJavax.jws.WebService;ImportJavax.ws.rs.DELETE;ImportJavax.ws.rs.GET;ImportJavax.ws.rs.POST;ImportJavax.ws.rs.PUT;ImportJavax.ws.rs.Path;ImportJavax.ws.rs.Pat
; - wsdl:definitions>Then we'll create a new Java engineering webservice_client:Using the Wsdl2java command and the Wsdlurl parameter, we generated some code in the SRC directory:Then we write a class Clientmain.java:1 Packagecom.war3.ws.client;2 3 ImportCom.war3.ws.HelloWorld;4 ImportCom.war3.ws.impl.HelloWorldWSService;5 6 Public classClientmain {7 8 Public Static voidMain (string[] args) {9Helloworldwsservice factory =NewHelloworldwsservice ();TenHelloWorld HW =Factory.gethelloworldwsp
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.