web services and their usage in practice [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
There are tons of information about web services on the internet i know. But I couldn't find a simple and clear example or tutorial about how to use web services in practice for Java. I will be appreciated if someone guide me through what do i need to know to develop a webservice
using java and what re webservices usage in practice.
The reason I am asking this is because whenever I look for a job advertisement i come across these Restful, SOAP, JSON, XML web services.. So I wonder about the practical usage of this web services especially if u re not working in a company. For example i will be appreciated if u give an example of how to use web services especially for Android platform..

What web service is? A Web service is a method of communications between two electronic devices over the World Wide Web source.
In IT industry now a days web service developers are on demand,because web service are platform independent you can create a web-service using any technology and this can be consume by using any technologies. Basically web services are on demand when the organization start thinking about the product. For example If a industry wants to develop a product using java technology as a web application. letter on one of the client want to use the same application using front-end as PHP or Android or any other technology. Then organization again need to develop the same application using PHP or any other even though the organization has all the business done already. Here if the product was developed using web services then the organization just need to change the front-end technology his business are already done using web service so just need to consume the web services which will reduce the development time and cost of the product. I hope the above example will help you to understand needs of web services.
Restful and SOAP are the web services where JSON and XML are the message type of web services. you can find lots of differences between Rest and SOAP on the stackoverflow also.

A web service is an API that you give others to access data's that you have. Like how facebook
gives others websites the user friends list, and others sorts of information.
A ref to the WEB API.
restful-web-services-api-using-java-and-html Tutorial

When you expose some kind of functionality to others then you create a webservice. For example, you can create a webservice - it is just a trivial example - which receives 2 integers and returns the sum of them. Here is a small exmaple how you can implement WebService in JAVA.
WebService JAVA

A web service is a way to communicate with a server, basically since most of the apps collect some data on the user (that can also be for a login or something similar) you want to store the data in a place s.t. even if the user will switch a phone all the data of his "profile" will not be lost a practical and good place to start will be something like this

Related

Best practices to build a hybrid Java application for both mobile and Web [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
We need to build a hybrid Java application for both mobile and Web. We plan to use Spring MVC and React Native.
Could you please advise us the best practices so that we can re-use the code as much as possible for both mobile and Web and it should be easy to maintain.
Should we build a common service layer and two different controllers for Web and mobile (using #Controller and #RestController). After that, these two controllers can call the same service.
For example, to display the information of all users of our application, we can have a common service UserInfoService, then we create two different controllers WebUseInforController (with path like /web/users/info) and MobileUserInfoController (with path like /mobile/users/info). These two controllers call the same UserInfoService. Is this a good idea?
Thanks a lot.
It all depends on your client requirement but I can suggest you some ways that may be helpful for you:
I worked on an enterprise financial application, on that application we follow the approach that we created a single server side (in your context single controller). That server side was used by by web application as well as android application. You can create services oriented or micro services application and expose your different services that will be reused in both android as well as web application.
**Web Application -----------> |Server side| <--------- Android Mobile Application**
Best Practise is that you should have a single server side and expose your services
And nevertheless there is another less economical and fast option as well:
You can go for web progressive applications. Progressive web apps are websites that look and feel like an app. This means users can access all information and capabilities without downloading a mobile app. Some big giants converted there applications into WPA e.g Ali Express, FlipKart, Twitter Lite, BookMyShow, Forbes and many more.
In the web progressive application you can follow any WEB architecture you want. You can even create an android application by using that website link in android. or that Application will work perfect in mobile browser as well.

How do i link a JAVA 8 backend to an Angular frontend? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have developed a stand-alone java application (java 8 + javafx) using the MVC pattern. Now I should start to develop the web app and , according to the MVC pattern, only the View should change. My problem is: I don't know how to link the Angular frontend with the Java backend of the stand-alone app. How do these parts communicate? How do the frontend invoke the controller's methods?
Welcome to stackoverflow.
An Angular application is a Front-End web application. That means that it will execute in a web browser.
You cannot just plug-in an Angular app to a Java app.
What you need to do is:
on je Back-End side (Java 8 side): develop a REST server, i.e. a set of REST services that will recieve and process REST queries from the Front-End. Typically, people use Spring nowadays to wirte this kind of code (but there are other libs, frameworks...)
on the Front-End side (Angular): develop a REST client, i.e. a set of REST services that will emit queries and recieve the answers from the Back-End. Don't go looking too far: Angular comes with a full REST facility out of the box.
My recommandation at this point: Angular has a tutorial that will explain pretty well how to build client REST services. Start by doing this tutorial. If you need extra info, the documentation is pretty neet. And of course, for any complementary questions, SO is the place.
The most common way is to use REST.
Your backend needs to expose a REST API which will be used by the Angular to access/modify data.
If you're using Spring, you can use the #RestController to create your endpoints.
IIRC, you can use the HttpClient class in Angular to call rest APIs.
You'll find many examples on the web.
As I understood, you don't see how your Frontend application (Angular) lays down on MVC pattern.
It doesn't
You MVC pattern in the current case won't be fully implemented, as you will implement Model and Controllers but not View.
So you implement your controllers to return JSON results, not View, and you call those routes from your Frontend(Angular) application which is parallel to your Java application and should be started(hosted) separately or as static resources from your Java Backend.
Develop a frontend using Angular. Develop rest api with Java to communicate with the Angular frontend. Can use spring to develop rest api. Angular can process json or xml data. A rest api endpoint can output as json/xml and take input as json/xml data.

Styling Java with HTML/CSS [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
So im fairly new to Java, anyway i have a implemented a simple Java program on IntelliJ which runs in the IntelliJ terminal, it basically ask the user to input some details and then records them along with the current time.
I now want to style it out using HTML/CSS to convert it into a webpage, where the user would enter the details into input boxes etc.
Im not sure how to approach this, what would be my best shot?
Also the user input is also being stored in a variable at the moment, would i have to use a database instead for a webpage?
Thanks.
Well I would recommend you to read first about what is Model-View-Controller paradigm in web page architecture, then you can probably better reply to yourself in terms of what you need for your webpage in order to do what you want.
I will grasp some about the things that you need:
You will need a database to store your user input details along with with the current time. (MySQL for example)
After that you need to define which type of data you need to save, you will have to make models in java for parsing those details from java to the db and vice versa.
Then you will need to create some services (You can learn about repositories before services if you need, which you probably would) to support those connections with the database in which you will retrieve data from DB.
A way to control how those services to serve your webpage is having a controller for processing the HTTP requests.
Last but not least, the controller will "glue" your jsp views with the data from services to be shown in your browser.
There will be many other ways, at least this is the way I know. I use Spring framework for building the MVC.
You have to do full stack page with java backend and html & css for the front-end.
Do a webservice with spring boot this generate a restful API to communicate with your web page using HTTP methods ( Get, Post, Put and delete ) and use AngularJS for example to parse the webservice created.
check out this : example
Quite simply, you'll need a web server to spit out HTML. I mean, there's lots of ways you could do it, but far and away the most popular is a web server.
There are lots of options for you. As an Eclipse fanboy myself, I can't say specifically, but a cursory google search yields this Tomcat plugin which should allow you to run a web server via IntelliJ. There are probably dozens of other plugins for differnt web servers you could use.
What you put into that server is up to you - it could be a simple html document populated by parameters, a REST endpoint, a JSP, who knows what. That's beyond the scope of the question - the first step is getting your web server up and running and then deciding the framework to use.

Creation of a client-server desktop application [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I've in the past created client-server web applications using Javascript, AJAX, Node, Express and MongoDB, but now I'm required to creare a client-server desktop application. It will therefore basically consists of a desktop program which will connect to a server program by doing requests. The server program will respond to the client program with the requested data which it can fetch from the database.
Since I'm really new to these kind of applications in Java, I have no idea how to create such an application in Java. Since the project will be large, we cannot hard-code all the server. We need probably a framework on the server side that listens for requests, but I've not found any for now. For example, Play Framework seems only to work for web applications. Which frameworks are useful for these purpose? Is this the right approach for this kind of applications? How would I connect client and server applications?
Please, do not suggest "use sockets". This will be quite a big "serious" project, and we need high level tools. We don't know how usually these kind of projects are created. Please, explain a little bit which patterns are usually used. Examples of concrete programs, maybe with open source code will be useful for us to understand. Also a list of the requirements that we need for these project would be very useful.
Note: I'm not asking for a exhaustive list of frameworks that we can use. I rather asking which kind of tools (with concrete examples) should we use and how to combine them. How to structure such a project.
You could write the server side application in Node JS or whatever other server side language you prefer - and implement that using REST services. Then in your Java desktop application, it would just communicate with the server using HTTP REST / SOAP etc.
That way if you were to then want to swap to use something like .NET to make your desktop application you would be free to do so without it changing anything on the server side. Also you would be able to implement a mobile application / tablet app / other web application and reuse all of the server side implementation easily without changing anything server side.
Another option is to use ServerSocket for the Java server side, and then connect to that from the client but you seem to know and dislike that option.
Another option to connect each side of the application would be to use some kind of pub / sub middleware messaging service - check out JMS as a framework - you will need some kind of implementation of JMS such as Active MQ, Websphere MQ or one of the many other free implementations. Check out : http://docs.oracle.com/javaee/6/tutorial/doc/bncdq.html
Difficult question to answer, but those are 3 high level options.
Use web technologies to connect client to server HTTP REST, or SOAP
Use ServerSockets and Socket connections and do everything manually
Use a messaging framework such as JMS

When and when not to use webservices? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
we are creating an appraisal system ,in which there will be a no. of validations and computations. Team leader decided to use web services for most of their logic ,which we are going to write.
I am just curious ,when we can moreover when we should web services and when we should avoid using it?
The team leader decided to use web services for most of their logic.
I would not advise putting the logic in web service code. Put it in a business logic layer, that can then be exposed via, for example, web services.
When should web services not be used?
When they are unncessary - without a specific scenario it's difficult to give a more meaningful answer.
Avoid using web services for method invocations that can be resolved locally (on the same JVM). Otherwise, use them.
Web services are the best/easiest way to do distributed operations. For example central server and many clients. If you have that sort of architecture then you need either web services or a web application.
If everything is stand-alone and local though then you don't need them and they will be less efficient than just doing things directly.
Web services and web application..
web services provide a standard means of interoperating between software applications.
When all major platforms could access the Web using Web browsers, different platforms couldn't interact. For these platforms to work together, Web-applications were developed.

Categories

Resources