Problem description
I want to provide an external HTTP interface to others to call ... But I don't know how to do this interface with Java. Please tell me in detail. From development to how to publish to the server. Thank you.
Solution Solutions
If you have a very simple and very small number, it is advisable to solve the problem directly with a servlet. Using Open source WebService components is a hassle. There are several ways, you can refer to the following: 1 servlet implementation, this way you need to parse the content, if you input and output is relatively simple, the use of this approach, the integration is simple, and the variability is very strong. Full client service side separation. If the interface is relatively simple recommended this way 2 using the JDK recommended WebService scheme Jaxws. It seems to be the name, specifically forget, this is the Java comes with, relatively lightweight, you can completely according to the document design one out, 3 using open source software. Similar to axis, CXF. The advantage of these components is that he encapsulates well and is completely object-oriented. The disadvantage is that the system architecture is greatly aggravated. These components are typically used in situations where you provide a lot of service. Since you are only providing a word, I personally suggest you servlet fix it, the big deal with JAXWS, do not complicate the simple things, cxf axis really want to add a lot of jars. If you are a neat freak, you will be more irritable.
Solution Two:
Please landlord look at rest WebService way!
Solution Three:
is to write a method, return a data, then let others access, and then receive the data, parse the data, so that the understanding is not much easier?
Solution IV:
Just make a spring MVC C that prints out the JSON data.
Solution Five:
Jersey
Solution VI:
Do a normal HTTP server on the line, there is no need to use WebService.
Solution VII:
Webservie three ways, cxf,xfire,axis these three kinds of way basically if use xfire words, The MyEclipse7.5 already has this function to provide, does is very simple, many things can directly generate them to transmit the value is already the XML form transmits, in carries on the parsing net about this many, casually to find a small sample to experiment to know
Solution Eight:
Publishing an interface, you might consider publishing it in a webservice way. Supports XML format and JSON format. And the release of WebService third-party plug-ins are also many, such as Cxf,axis. Moreover, the Java EE 6 specification provides support for RESTful Web Services (JAX-RS), which provides a pojo-based framework for building lightweight Web services. As long as a few annotations, you can publish the interface, very convenient. In addition to the above, you can also consider publishing interface services directly using the servlet. This, of course, needs to be considered in terms of security and so on.
Solution IX:
Don't know if you're using WebService? If so, you can use cxf,spring has been integrated, you can go to Spring's official website to see, there are many tutorials online. Configuration is very simple, the final release is the access URL of your interface, in addition to generate a client, the client's code to the other side of the developer, let them follow the client's call way to call your interface on the line. Very simple, only need to configure, write point interface business code on the line. Also, if you need to test, you can use the Soupui tool, which allows you to invoke your interface locally.
Java makes HTTP interface