spring web controller use as web service - web-services

Currently I use Spring mvc to develop my we application. In future there will be a requirement to develop mobile app for this application.
In asp.net c# MVC have ability to use there web controller class as the web service. Then mobile app can use that controller class as web service.
I want to know is there an ability to use Spring MVC controllers as a we service. If yes, then how. Please explain.

You can easily write a Restful webservice using Spring MVC. The controller classes can return XML/JSON as required. It is simply a case of configuring an appropriate ViewResolver in this case a ContentNegotiationViewResolver.
This is an excellent guide which will walk you through the basics of Spring MVC as a webservice.

Related

Is there are any framework for ballerina

I read the documents of Ballerina https://ballerina.io/. I am interesting about Ballerina. Is there are any framework to build the web app using Ballerina?
At the moment there is no Web frameworks similar to ASP.NET MVC or Spring for Ballerina. However you can easily create single page web applications using Ballerina RESTful services. This is similar to ASP.net WebAPI or python with flask.
There you separate the Web pages which are written in HTML/JS.. from the backend APIs which you can write in Ballerina.
Please take a look at this https://ballerina.io/learn/by-guide/restful-service/

Hibernate RESTful webservices in NetBeans

Is it possible to create RESTful Web Service using Hibernate in Netbeans 7.4?
I could see wizard to create RESTful Web Service using Persistence, but would like to know how it can be integrated with Hibernate?
Appreciate any help or insight.
Edit 1
I would like to know what I did is the correct method of generating RESTful web services using Hibernate.
First I generated Hibernate Entity classes using NetBeans and then I created RESTful services from Entity classes. So does this creates RESTful Web Services with Hibernate? I could see AbstractFacade classes that is almost like DAO classes
Edit 2
Screen shot for selecting RESTful Web Service from Entity classes
If you want to build a truly RESTful service, you need to build up a link relation architecture. You're going to need more than Hibernate or Netbeans to do that.
I recommend using the milestone Spring Data REST in conjunction with Hibernate's JPA implementation and Spring HATEOAS. See Spring Restbucks as an example which brings all these technologies together.

Strategy to develop a web service in JAX WS

i'd like your help to designing a wb serice but I don't know how i can't do this.
In fact my application handles data management clients. My application is developped in struts 1.0, spring, weblogic and build-in maven.
He was asked to me to make an evolution because an external application need to access data such as displaying the address of the client or displaying data bank. For this, it was planned to create a web service to retrieve in real time.
I would like to know the strategy to use for designing a web service. Do I need to create a new Dynamite projet maven + JAX WS to my web service and deploy my war on my weblogic server?
Or they have something else to do ?
Thanks a lot !
I am not sure that this question is related to maven.
Adding a WebService (or RestService) could be quite easy with springframework and apache cxf (http://cxf.apache.org/)
see jaxws or jaxrs for more.
create web service in a two types but real time applications using jax-ws web services reason for consumer want to send data into provider.consumer can know the entire information about the provider by seeing its WSDL Document.

Webservices for Spring 2.5.5

I have web application designed using spring 2.5.5 MVC, JBoss server. I want to expose my spring services (like add/update User, comments, documents, etc.) using WebService for EAI. Requirement is like any third-party application should be able to perform operations in my web application after authentication/authorization.
I have novice knowledge of SOAP (Axis2) and REST (Jersey), however i am not sure which will be best suited for my application.
Cheers
We are using Spring 3.0 actually. But former using Axis2 with Spring 2.5.x.
You might review our stack at http://incubator.apache.org/openmeetings the axis.
We simply integrated the regular Axis2 configuration into the web.xml and build a Facade to load the spring beans into the Axis enables Web-Service and forward the calls to the Spring enabled context that way.
Comparable to https://svn.apache.org/repos/asf/incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/axis/services/FileWebServiceFacade.java
It is not the perfect solution, the Axis2 documentation also contains other ways to load the Spring context in the Web-Service enabled class, however it was never possible to make that work stable so we decided for this workaround.

Possible to create REST web service with ASP.NET 2.0

Is it possible to create a REST web service using ASP.NET 2.0? The articles and blog entries I am finding all seem to indicate that ASP.NET 3.5 with WCF is required to create REST web services with ASP.NET.
If it is possible to create REST web services in ASP.NET 2.0 can you provide an example.
Thanks!
I have actually created a REST web service with asp.net 2.0. Its really no different than creating a web page.
When I did it, I really didn't have much time to research how to do it with an asmx file so I did it in a standard aspx file. I know thier is extra overhead by doing it this way but as a first revision it was fine.
protected void PageLoad(object sender, EventArgs e)
{
using (XmlWriter xm = XmlWriter.Create(Response.OutputStream, GetXmlSettings()))
{
//do your stuff
xm.Flush();
}
}
/// <summary>
/// Create Xml Settings object to properly format the output of the xml doc.
/// </summary>
private static XmlWriterSettings GetXmlSettings()
{
XmlWriterSettings xmlSettings = new XmlWriterSettings();
xmlSettings.Indent = true;
xmlSettings.IndentChars = " ";
return xmlSettings;
}
That should be enough to get you started, I will try and post more later.
Also if you need basic authentication for your web service it can be done, but it needs to be done manually if you aren't using active directory.
It is definitely possible to create RESTful web services using ASP.NET. If you are starting a new project I would definitely look into creating RESTful web services using WCF. The 3.5 .NET Framework allows you to specify RESTful endpoint along with a regular old SOAP endpoint and still deliver the same service.
All you really have to do is enable an endpointbehavior that calls out <webHttp />
Here is a good series on creating RESTful web services using WCF:
http://blogs.msdn.com/bags/archive/2008/08/05/rest-in-wcf-blog-series-index.aspx
You can certainly create RESTful web services in ASP.NET 2.0, for example, but there are no high-level APIs to do all the donkey work for you, as provided by WCF in .NET 3.5.
Well, of course you could always implement the spec yourself. It's just that there's nothing built-in to support it. If you use Nathan Lee's solution, do it as an http handler (.ashx) rather than an aspx. You can just about copy/paste his code into a new handler file.
You can do RESTful web services easily by implementing the spec using IHTTPHandlers.
Also check out using ASP.Net MVC. I've written some articles on this at my blog:
http://shouldersofgiants.co.uk/Blog/
Look for my Creating a RESTful Web Service Using ASP.Net MVC series
I'm only just beginning to use them, but from what I've seen 2.0 pretty assumes SOAP.
You can create RESTful service using
1) WCF REST service
2) ASP.NET Web API
If you all care about RESTful service, ASP.NET web api is that you should go with. But if you need service that supports both SOAP webservice and RESTful then WCF REST would be a good choice.
There are some articles that discuss about one versus another. This article may be helpful.