I want to create a webservice that allows users to enter the longitude and latitude for a particular building. Buildings will belong to a broader category called a Region. If a specific building does not exist in a region the user could add the longitude and latitude data through the webservice. Similarly if a user finds data to be inaccurate, they could update it.
This webservice would not need to have a web front-end only a RESTful API that would only be accessible to my application(s). I want the webservice to be able to accept new and updated data (as described above) and also print out relevant data (in xml format) based on the appropriate API calls.
I need to ensure that this data would be secure - i.e. nobody would be able to gain access to the data i have accumulated.
What is the best way to do this? I have familiar with client side Java and not much server side technology (not familiar with server-side Java, rails, django, etc...). What language/frameworks should i use that would accomplish my needs with the shallowest learning curve?
You can just use basic authentication (username/pw) with ssl enabled. That way you are encrypting the connection and providing a broadly supported means of authentication. I believe apache Axis will take care of most of it for you.
I've used the Restlet framework to deploy web services that are password protected. It supports basic authentification and several others out of the box. You can also set up your services behind an https "server connector".
Another approach is to run your application in a Java EE application server which supports JSR 196 (eg, Glassfish or JBoss). You would then use the server's facilities to establish the authentication.
Here is the Glassfish security page.
If you have never programmed server-side code you will be facing a pretty steep learning curve, I'm afraid. If you are comfortable with Java then the Restlet framework mentioned by another commenter is a good choice. It is easy to use, includes both client and server tools, and has pretty decent documentation. The video screencasts are very good.
Another option is Ruby on Rails. I am currently implementing something very similar to what you are planning and Rails has worked extremely well. Rails has built-in support for XML output through both the ActiveRecord class and XML Builder templates. I used Atom Authentication (http://www.xml.com/pub/a/2003/12/17/dive.html) between the client and server and it is working beautifully. There is a learning curve for both Ruby and Rails but the power of the framework makes it worth it. I am partial to the Ruby and Rails books at The Pragmatic Programmer but O'Reilly has some good ones, too.
Related
I'm new to REST API's in general and I have the following questions:
I want to make a website, and an App that share the same users, and data from database in general. For the website I plan to make it with spring for the backend, and for the app I plan to make it in kotlin, as well as an IOS version, to which I havent decided what language I will use. I also want an API the public can use. Is this when I would make a rest API, for the data, and the public API?
The website and app would both contain login, registration, and more
How do I make the website/app retrieve data from the REST API?
Also, what do I make the API in? Is this something I could use spring for?
Sorry if this is a really stupid question.
I am not sure why you want to use kotlin. You can use Angular for UI and Spring Boot for Rest API. I have some POC for user registration. Please have a look.
https://github.com/numery009/springmvc-security-aop-hibernate-user-registration
https://github.com/numery009/numery009.github.io
For UI with Angular -- https://numery009.github.io/
Unlike your question supposes, which is declared as "general", you are mentioning Spring MVC as backend for REST-Endpoint API as well as Angular as independent frontend solution, altogether handling user, groups and their special rights on objects.
There are some dozen if not hundreds of possibilities to build an API, but I suppose you look at jhipster.tech, which is a code generator serving you the basic fundament for Spring backend and Angular frontend (you can choose other frontends, but I recommend to use Angular for generation as it is similar to Java in Spring framework).
As you can generate from easy first monolithic constructs for testing and learning all the modules and technics as well as high-level company-driving microservices for ERP including process-management and accounting, API for field workers, partner companies and clients, one or more Webstores, connecting mobile devices and everything else "in minutes", it is not only a splendid tool, that shows you best practice in development including good documentation, but it is also used as generator for professionals to start a project.
With jhipster and its community you'll learn from pro's and get some steps further - at least for me the work of those guys was and is an eye-opener - after years of reading books about programming and turning left and right, often enough to nowhere.
Of course, it is opinionated like Spring and Angular themselves. But the technics which are used are reliable, well combinated and do build the daily software-stack in many companies since and for years.
You'll code in Java or Kotlin in Spring and ECMAScript (Typescript as Javascript Transpiler) in Angular framework. The structure and ideas behind these programming languages are comparable - "Typescript is easy to understand for Java-guys". And you'll stay independent from support companies, platforms or library changes. Besides you'll learn how to update your own software, which is often forgotten in business software, too.
tl;dr: Is Spring + Django back-end possible?
When I was new to industry and was still working my way around the office, I got interested in Django and created a very small, basic-level application using the framework. When I got to meet my team after a few weeks, they said to go for Spring framework. After spending half a year on the framework and the main proj, I finally started to get time to start working off-hours. But, I don't want to lose both the skills - My teammate(when we were still in office ;) ) once told me that they worked on a project that started with python code, and then later added features using Java. And I am unable to find any helpful google searches(mostly showing Spring vs Django).
How should I go about it? Is it too much to ask for? Is it worthwhile? Will I learn some new concepts of application architecture a noob like me would have missed. Please provide me with some insight.
Are there resources(docs) I can go through?
P.S. I'm not a diehard fan of either of the frameworks right now, just another coder testing waters.
You can't write java in python.
You can extend Python with C/C++ which is quite common: Extending Python with C or C++
And about the part that they told that they added features with java:
It's common to create different parts of a project using different languages and tools. Microservice architecture is a common architecture for these kinds of use cases. You basically code different parts of the project in a language you want and then you connect all the parts using different methods like REST APIs, gRPC and etc.
Imagine you are creating a website like youtube that lets others upload videos. There is a form that users upload their files and you store them in your storage and then you have to encode the video file for different qualities. You can code the form handler using Python and Django to store the files in your storage. Then you can code another service using java that handles the encoding part which is a heavy process. When an upload is completed, you send the file or file path to your java service using an internal REST API and tell the service to start encoding the video and notify the Django service and then the Django service will publish the video on the feed that can itself be written in another language.
I would say go for 1 framework and stick with it. For example Django if you want to code in python, and spring if you want to code in java. Learning both frameworks however brings a lot of value, because you can compare their benefits (eg. spring forces you to write clean code, django has build-in and simpler database management)
I like Django's build-in tooling a lot, you only need to know python for it to work. Spring requires a bit more knowledge of eg. hibernate for database management. However I predict Django will outgrow spring at some point, because of cloud valuing fast iteration over code and quick startup time (auto-scaling apps) over large overhead apps and long boot times. Hoever, if you like java, I can recommend JHipster for java/spring webapp development to get up to speed very fast and learning the ways of REST CRUD api fast.
To combine 2 programs: write your main logic in one app, and write a small service in the second language, making sure its independent of the first app (no back and forth communication and complicated logic, but simple independent request/response, as if the main app was never there). Add a REST api to the second app and use eg. http requests to communicate.
What's possible in terms of combining languages:
connect different applications with each other: by letting them communicate through their APIs. For example a python api developed with flask or django can send requests to a java api developed with spring, as long as they have a way to communicate (eg over http, or via some queue like rabbitmq)
connect a webapp to 2 different backends: by using a shared authentication system: For example a keycloak authentication server to handle tokens, that your backend applications know about.
What's not possible (and also not preferable):
combining java with python code in the same program: there are some hacky ways to get it to work, but its asking for trouble and not readable.
I am about to start developing a private TODO website (that later will be extended to Web applications). I am unsure what framework to use. I have read about GWT and PHP frameworks such as Yii. What advantages do each one have over another.
Background
- experience in Java
- got an apache web host that supports php
Doubts:
Would developing in GWT mean that refactoring would be easier than developing in PHP (especially since you can use Eclipse)
seems like PHP frameworks such as Yii design objects for you once you create database layout ... can this be done with GWT?
Thanks!
One big difference I haven't seen mentioned in the question or answers/comments is that Yii is a server-side framework, which runs entirely on your own/hosted server, whereas GWT compiles to JavaScript, and is therefore runs in the client's browser only. These two offerings (and ideas) serve very different purposes, and can be used together.
When using GWT to build the client, the server can be built using any tool desired, so long as it exposes data to the JS-based client. That can be in the form of JSON or XML, or some other data encoding (GWT's built in RPC, for example, can pass complex object graphs to and from a Java servlet container).
If you were to use them together, Yii could be used to create PHP objects from the database schema/layout, and to build the various rules for authentication/authorization so the client can read and write data. GWT could then be used to build a client which reads and updates that data, making calls to services exposed by Yii/PHP code.
If you like Eclipse you can certainly stay with Eclipse and still develop in PHP. The PHP tools from eclipse.org are very good and the IDE plugin from Aptana is even better.
Regarding Yii vs GWT, it really depends on your language of choice. If you are highly proficient in Java and really like the strong typing of the Java language then GWT is a good choice (although there are certainly other choices that keep you in the Java world such as Tapestry). PHP frameworks vary quite widely in how much they embrace OOP and concepts such as creating your business objects based on your database. Yii definitely stands out as a framework due to the code generation capabilities built in. That will definitely help you if you're getting started with PHP.
I come from a .Net background and recently x-training to java.
I wanted to develop an Android application that required simple functionality to communicate with a server. For example, functionality such as post a username/score to a website (or service), or request information such as top 10 scores.
What type of communications should I focus on? What is the common technology to use? Does Java have the equivalent of WCF? Or does it have some sort of simple web service? Can web services be secured with authentication?
Ive heard other references to xml-rpc. Should this be something I should look into?
Depends on what your server is running. I usually just use URLs to fetch and/or send data and then parse the response with whatever is suited (such as org.json for JSON or org.w3c.dom for XML or HTML).
Java has the equivalent of WCF in the fact that you can develop Web Services with Java and use frameworks to develop such services to benefit from different features. The format which you send messages to these web services I think is what you are asking as such you literally can use any format you want (Dependent on support of such format by the service). You will find libraries for many of the well known formats like SOAP (KSOAP2), REST (JSON,XML) etc... Since the transport of these can be over HTTP, and you get a library in android to develop such services over HTTP you have quite a choice.
For Reference:
http://ksoap2.sourceforge.net/
https://metro.dev.java.net/
http://msdn.microsoft.com/en-us/netframework/cc950529.aspx
Hope this helps,
Andrew
Without knowing all of your requirements but assuming it's gaming-related, you might be better served trying one of the Android gaming APIs rather than trying to roll-your-own networking solution. Scoreloop and OpenFeint, the two I am currently considering for my own Android game, both offer Android APIs that make it fairly straight-forward for posting and retrieving high-scores, in addition to other game-related features such as challenges and social network integration.
The advantage of this option is that you don't have to worry about how the phone talks to the server nor do you have to host the server itself - they have already solved those problems for you - and they're free which makes it great for us indie developers.
I've been using the following web development stack for a few years:
java/spring/hibernate/mysql/jetty/wicket/jquery
For certain requirements, I'm considering switching to a NoSQL datastore with an AJAX frontend. I would probably build the frontend with jQuery and communicate with the web application middleware using JSON. I'm leaning toward MongoDB because of more dynamic query capabilities, but am still considering CouchDB.
I'm not sure what to use in the middle. Probably something RESTful? My preference is to stick with Java (or maybe Scala or Groovy) since I'm using tools like Drools for rules and Shiro for security. But then again, I want to pick something that is quick an easy to work with, so I'm open to other solutions.
If you are building ajax/json/nosql solutions, I'd like to hear details about what tools you are using and any pros/cons you've found to using them.
Pick whichever middleware you are most comfortable with.
CouchApp is very experimental at the moment. The main issue is being able to add security to your app without having a standard HTTP pop-up box. This is obviously a big issue for standard web apps.
Try and avoid parsing each DB request in the middleware and rebuilding the query for couchdb. You can make your middleware act like a proxy so most requests are forwarded on without modification. You can also add a security layer in the middlelayer on top of all requests that need authentication.
Pick a middleware/framework with good URL routing capabilities. For example you could route all requests that go to mydomain.com/db/ to couchdb.
If you go with CouchDB, you can use CouchApp which is a set of scripts for deploying an application directly to a CouchDB database. In essence, you skip the middleware and use CouchDB's views, lists, and show functions along with clientside JavaScript to implement the whole app. If your app works in this architecture, it's surprisingly refreshing, simple and cool.
Also if you like the idea of JSON/REST and sticking to JavaScript client to server, the newer generation of Persevere's core, Pintura is pure JS JSON/REST framework that is designed specifically to work well with NoSQL DBs.
I've been tinkering with a few. Ultimately, I'd like to move my controller layer of MVC to the jQuery/javascript frontend and use pure JSON/REST to talk with the backend. Though the backend will need strong security and, for my application some ability to do workflow, queries, and rules.
You also might want to look at:
1) Couldkit, which runs on Tokyo Cabinet. Supports JSONQuery and OAuth. Runs on Ruby/Rack may have enough functionality. Loks like a strong REST implementation.
2) Persevere, which is Java based and strongly supported in Dojo. It is REST-ish but also has some RPC type calls. Seems very powerful overall, with server-side java scripting, etc.
I wouldn't mind hearing how you're coming along.
Cheers,
Alex
I wrote a gem called Rack::JSON for exactly this purpose, it acts as a basic REST interface to a MongoDB db. It was inspired by Cloudkit and supports JSONQuery and also runs on Ruby/Rack. It allows you to store and then access/query JSON documents.