Cxf learning, cxf

Source: Internet
Author: User

Cxf learning, cxf

I recently studied java and want to develop j2ee and mobile website development.

IDE: Intellij IDEA 13

JDK: 1.7

Server: Tomcat 8.0.15

System: windows 7X64

Summary:

1: Find out what plug-ins are in IDEA and what plug-ins are!

2: In CXF, do not separately target helloWord during WebService development. java (implement interface IHelloworld) for compile (ctrl + shit + F9). During the warranty period, the build project is directly executed. If you compile helloworld. java separately, IHelloWorld. java is not compiled. Therefore, an Error such as a symbol cannot be found!

3: CXF varies with different versions. At the beginning, there was a great detour. After downloading CXF3.0.2 and referencing the webservice plug-in IDEA, it always fails to be referenced. After half a day, it may be because the CXF version is too high, so it will be reduced to CXF2.7.13, there are still more or less problems in the middle, and they are reduced to 2.6 ., at that time, the lowest version of the official website.

During Restful WebSErvice development, it was quite good to develop it independently. When springframwork was introduced, it was reported that "the corresponding bean could not be found" was a problem in springframework. Isn't that a problem? So I went online to find the answer, for a long time ..... finally, I found the problem of package conflicts. When I saw the problem, I could probably guess it was a package conflict problem, but I don't know which jar conflict it is? I saw a similar error in CXF 2.7.0, saying that there was a cxf-services-ws-discovery-service-2.7.0.jar that conflicted with the springframework package, but the tragedy was, I did not find the corresponding jar package in the CXF2.6 package referenced by my project. At that time, I vomited blood 3L. I simply upgraded the CXF version of the project. We upgraded it to CXF 2.7.13, and we won't report any errors during the operation. It's quite smooth! Test other functions!


It doesn't matter if you don't test it. It's a test. Oh, my mom. You don't want to play with me like this. Why is it always like this? The original access to http: // localhost: 8080/services/rest1/list is easy. How can I suddenly report an error? Report

Org. apache. cxf. jaxrs. interceptor. JAXRSInInterceptor processRequest WARNING: No root resource matching request path ". It's a wave of ups and downs! Why is it so tortuous!

Don't be discouraged. Let's take a look at the source code and find that there is a problem.

@Path(value="sample")public interface RestSample {    @GET    @Produces(MediaType.TEXT_PLAIN)    @Path("/request/{param}")    public String doRequest(@PathParam("param") String param,  @Context HttpServletRequest servletRequest, @Context HttpServletResponse servletResponse);    <span style="color: rgb(204, 102, 204); font-family: Verdana, Georgia, serif; font-size: 14px;">@GET</span>    <span style="color: rgb(204, 102, 204); font-family: Verdana, Georgia, serif; font-size: 14px;">@Produces(MediaType.TEXT_PLAIN)</span>    public String doGet();    @GET    @Path("/bean/{id}")    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })    public User getBean(@PathParam("id") int id);

As shown in the code above, the @ Path parameter is still different. The fuction doGet method or function (C # called method) does not have the Path parameter. During the request, you can use the default/sample for requests, such as "http: // localhost: 8080/services/rest1/sample". However, when you request other methods, you do not need the default Path, use your own path parameter for the request, but after CXF2.7.13 is used, when you make a request, it will not work, and you will report what cannot find the corresponding request path. So, I just adjusted it and tested it. Hey, don't say it's really useful. I just got it done.

It seems that the Path parameter above the Interface has different meanings. 2.7.13 regards value = "/sample" as the parent Path, while 2.6 regards it as the default Path.

And, cxf-servlet.xml and applicationContext-server.xml basically almost, can be replaced, I also tested for a moment, no problem found!



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.