Tool to report rest interfaces - spring

We have a web application using Jersey and Spring's rest template. Does anyone know of a tool that can scan a code base and produce a report that lists all exposed endpoints and also internal references to those endpoints?

You may also take a look at Swagger, a framework for describing, producing, consuming, and visualizing RESTful web services.
Swagger supports multiple REST frameworks and also JAX-RS based on Jersey.
From their GitHub Wiki:
The Swagger framework simultaneously addresses server, client, and documentation/sandbox needs for REST APIs. As a specification, it is language-agnostic. It also provides a long runway into new technologies and protocols beyond HTTP.
With Swagger's declarative resource specification, clients can understand and consume services without knowledge of server implementation or access to the server code. The Swagger UI framework allows both developers and non-developers to interact with the API in a sandbox UI that gives clear insight into how the API responds to parameters and options. Swagger happily speaks both JSON and XML, with additional formats in the works.

Jersey can provide a WADL report at the /application.wadl URI. It doesn't document complex types but at least gives you a list of endpoints.
See https://wikis.oracle.com/display/Jersey/WADL

Related

how to make spring mvc functions available for rest calls

I have a spring mvc application which runs correctly,now another colleague wants to call the same functions from another application but he needs REST URL of my functions.
how is it possible to provide the same functionality through spring REST?
is it just with new annotations .please provide some resource to show me how to do it.
when server has a service, only legal clients which had any contracts with server can access it. And clients can use service by the way such as: use RestTemplate to get/post request to URL of service, and clients can get data as JSON, or XML type if you have an equivalent object as this image:
Also, a service can be support as a interface, ex: google search is a service supported by google, but it's not rest service.
If you know each other URL address you can consume each other REST API from java code by using RestTemplate object.
I would advise you to go over the Spring starter guide which deals with that issue, here is the link (Consuming a RESTful Web Service):
https://spring.io/guides/gs/consuming-rest/

Advantage of Spring Rest Web Services over Servlet

What are the advantages of using Spring Rest Web Services over Core Servlet ?
As we know Spring Rest Web Services also use Servlet internally.
REST is a special kind of web service. Whether this is the right thing for your application varies. If it is you should use a framework/library that is designed for REST to make coding simpler. You might also want to have a look at JAX-RS.
If you need a non-REST web service Servlet may be an option, but there are other options, too.
REST is not a type of Web Service - it is an Architecture and specification - JAX-RS. Spring has its own REST implementation libraries primarily based on its MVC controller. I would recommend you not to go for Spring Rest Web Services until you have any Spring specific requirement (Though I cant think of any such requirement which cant be solved by other light wait JAX-RS implementations). Jersey is the most light weight JAX-RS reference implementation by Sun/Oracle which, has support for Spring as well which, can be plugged in on requirement basis.

Is it worth to use Spring Integration instead of Spring MVC for web-based or mobile based application?

I am developing web application, also in my product we are also providing financial-non financial mobile services.
Going in details.
In my web application, there is nothing like maintaining flows step by step , simple all CRUD operations and currently we are using Spring MVC which fits to our requirement but for mobile based services, we are providing like message bus support to exchange piggy back information between client and server and we have custom code to implement the solution.
Also our mobile based services need to be exposed over different protocols like SOAP,REST along with need of decoupling of communication packets from services.
All above problems we solved using SPRING MVC only.
My Question is
Is it worth to use Spring Integration framework to replace custom code solution to implement message bus with Spring Integration and if so, what will be the flow for my web application?
If I am using Spring Integration for my web application, how it will render HTTP request to SI?
Is Spring Integration is right choice for any standalone web based application?
Spring Integration is modeled on the Enterprise Integration Patterns and can be best thought of as support Message Driven Architecture. Spring MVC's history and origins is in providing a solution for the MVC pattern akin to Struts, exposing Models and Controlling Views, supported by Services, primarily in a linear fashion. One of the cores of Spring MVC was allowing the dynamic population of a Model that would be accessed by a JSP page (View). All of these things being Web App orientated and ending their.
With the evolution of services (Web, RESTful), Spring MVC has filled a gap and continually expanded to support HTTP access to services, though this is an expansion of its duties, rather than first origins. Meanwhile, Spring Integration was designed with the view of handling Messages and a messages interaction with services, independent of the protocol that it was accessed on. To enable different protocols, different endpoints are available to expose the same service. For example, I can have my crud services built in a POJO, exposed through a Service Activator, and now available to a number of different protocols including REST via HTTP, WebServices, Twitter, XMPP chat services, RMI, TCP, etc. etc.
in short, Spring MVC == HTTP access, Spring Integration == Message access (from HTTP, File, DB, etc.)
to expose a service via HTTP in Spring Integration, use the HTTP endpoints. Typically in a Request/Response (say a Read from a database) you'll want to use the <int-http:inbound-gateway/> and it would look something like this;
<int-http:inbound-gateway request-channel="request.channel" reply-channel="reply.channel"
path="/myService" supported-methods="GET"/>
<int:channel id="request.channel"/>
<int:service-activator input-channel="request.channel" ref="myService"/>
<int:channel id="output.channel"/>
(a key point to remember to is the following...
<bean class="org.springframework.integration.http.inbound.UriPathHandlerMapping"/>
this helps map the path attribute of the inbound-gateway to the servletdispatcher)

Are WSDL's like spring dispatch servlet?

im trying to understand where WSDL's fit in, in a typical web service backend application. i am coming from a Spring background and in my experience so far, in Spring, each url request gets mapped to a specific controller class via a dispate servlet running in the web container. you can specify which url matches a given controller via xml config or from annotations.
is using a WSDL the same thing as using an xml config file to map url requests to java objects?
Thanks in advance. im moving from Spring to standard j2ee/EJB3.
WSDL is just a description of Web Service interface, most Web Service systems generate those descriptions on fly like for example when you create asmx web services you can generate WSDL on fly by typing http://yourhost/yourwebcontext/yourwebservicename.asmx?wsdl and it will return you the description of that web service. Then you can use a tools that generate stub proxies for coding using those descriptions automatically, for example in Visual Studio when you add an Web Service Reference those operations are done automatically
No, WSDLs are not like a dispatch servlet.
A WSDL file is a description of a web service (SOAP, REST, etc.). A WSDL can (theoretically) be used by anyone to generate executable code which consumes the web service described by that WSDL.
From the WSDL tag info:
"WSDL" stands for "Web Services Description Language." It is an XML language used to describe a web service to code that wishes to consume it. It describes the messages sent and received, the possible faults, and the communication and security requirements.
From WSDL Essentials:
In a nutshell, WSDL represents a contract between the service requestor and the service provider, in much the same way that a Java interface represents a contract between client code and the actual Java object. The crucial difference is that WSDL is platform- and language-independent and is used primarily (although not exclusively) to describe SOAP services.
Using WSDL, a client can locate a web service and invoke any of its publicly available functions. With WSDL-aware tools, you can also automate this process, enabling applications to easily integrate new services with little or no manual code. WSDL therefore represents a cornerstone of the web service architecture, because it provides a common language for describing services and a platform for automatically integrating those services.

SOAP JAX-WS client in Ruby

I want to write a ruby web service client for a SOAP (JAX-WS) web service. I looked into soap4r and handsoap but couldn't find useful resources to write a (JAX-WS) client
Can you help me to find some resources and some way of doing it. Because as I can see, my web service is developed using oracle JDeveloper and looks little different than examples find in web.
I'm a beginner for SOAP, WSDL web services and finding it hard.
Has anyone done something like this before, or can you turn me to the correct direction?
JAX-WS is an API for the development of web services in Java. Know then that, in order to consume a SOAP/WSDL based web service, it is not necessary to know how that web service was implemented. It could be Java, .NET or any other number of languages. All that is required to create a SOAP based web service client is the WSDL for the service. It is self contained and self descriptive, including all operations and data types supported by the web service.
In order to familiarize yourself with web services, I would recommend trying to exercise some web services directly, for example using SoapUI. This will allow you to import a WSDL for an active web service, try out some of the operations, and see what the corresponding SOAP messages look like. Then, I would look at "What's the best way to use soap with ruby?" for more ruby specific approaches.

Resources