As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
From yesterdays i have started learning java web services, have seen many blogs still confuse, about which service is best for practice. either SOAP or Rest?
Please suggest me best service method for request and response.
Thank You.
There is no best, only choices. Choose the one that meets your needs and get on with it. Or simply pick one if you don't know what meets your needs.
REST is a style based on HTTP. It requires a level of knowledge that you probably don't have. I'd recommend starting with SOAP because it's so well supported with tools. Once you're comfortable, learn REST.
I think this article could help you: When to use rest or soap.
Personally I always use SOAP because it uses XML to transport the information, and it is easy to understand the structure of the data you are using in the comunication. Rest hasn't exactly a format to read, so it makes the things more complex to understand.
If you are just starting to learn about Web services I think you should go with SOAP.
Best Answer I found on SO
Both methods are used by many of the large players. It's a matter of preference. My preference is REST because it's simpler to use and understand.
SOAP:
SOAP builds an XML protocol on top of HTTP or sometimes TCP/IP.
SOAP describes functions, and types of data.
SOAP is a successor of XML-RPC and is very similar, but describes a standard way to communicate.
Several programming languages have native support for SOAP, you typically feed it a web service URL and you can call its web service functions without the need of specific code.
Binary data that is sent must be encoded first into a format such as base64 encoded.
Has several protocols and technologies relating to it: WSDL, XSDs, SOAP, WS-Addressing
Representational state transfer (REST):
REST need not be over HTTP but most of my points below will have an HTTP bias.
REST is very lightweight, it says wait a minute, we don't need all of this complexity that SOAP created.
Typically uses normal HTTP methods instead of a big XML format describing everything. For example to obtain a resource you use HTTP GET, to put a resource on the server you use HTTP PUT. To delete a resource on the server you use HTTP DELETE.
REST is a very simple in that it uses HTTP GET, POST and PUT methods to update resources on the server.
REST typically is best used with Resource Oriented Architecture (ROA). In this mode of thinking everything is a resource, and you would operate on these resources.
As long as your programming language has an HTTP library, and most do, you can consume a REST HTTP protocol very easily.
Binary data or binary resources can simply be delivered upon their request.
There are endless debates on REST vs SOAP on google.
My favorite is this one.
Well, REST is more used than SOAP (something like 70% of the webservices, but I can't figure out where those figures come from). So if you want to be a professional developer, it may be more interesting to learn REST.
This question has been asked multiple times on SO over the years. You can find answers at Main differences between SOAP and RESTful web services in java and WSDL vs REST Pros and Cons and Restful vs Other Web Services
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I followed this (paragraph 7) tutorial to create a Rest service using jersey. However in the end i was kinda disappointed as it wasn't exactly what i was looking for.
What i had in mind was to create a java server with jersey that a client could make post requests to it , and the server could save the data in a MySQL database.
In the tutorial i was shown maybe how to make a post request? And even for that i used some html and 4 different java classes without any explanation on what anything does. In php the same thing was less than 40 lines of code and everything actually made sense.
I am not sure where to go from here , as everyone suggested to me to read this tutorial for what i needed. But i can't see why as i don't understand its purpose.
Do you know any tutorial i could have a look at , or point me to the right direction here? I ve never developed in java before neither have i used tomcat , so everything seems pretty new to me. I was used to php and apache.
The tutorial you have mentioned focus on creating RESTful Webservices with Java. It aims at distributed systems, where a client can make requests to a server. I think the tutorial is very helpful for that matter.
On the other hand, you seem to be searching for a tutorial that helps you creating a web application that can save/retrieve data to/from a database. You can find one, for example, in http://zetcode.com/tutorials/jeetutorials/mysqldatabase/
Then, for web clients, you have different alternatives, such as GWT or JSF. Also, for the persistence layer you might want to check Hibernate or JPA.
Relatively to Tomcat, it implements the Java Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems, and provides a "pure Java" HTTP web server environment for Java code to run. In short, Tomcat is the place where you deploy and run your Java web application; like you deploy a PHP application in Apache (with PHP installed).
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm not a Python developer, but I work with Python developers.
The scenario is the following: I have been asked to implement part of a system that integrates with a Python framework. I then agreed with the other team to develop my part in Java and provide full support to them implementing REST bindings. So I implemented a webapp in Java using Spring MVC and Hibernate. I can't go in detail but the design contract resembles the following:
The Python framework invokes a REST API with special authentication and authorization headers. The Spring MVC controller uses interceptor to perform authentication and authorization based on such HTTP headers, then gets invoked. The controller itself uses a path variable and two optional GET parameters to determine the type of object being accessed and the timestamp range
/api/{datatype}?[starttime=AAA]&[endtime=BBB]
Using a proper switch statement I choose the right Hibernate repository to query with these parameters and return an object (mapped to a table) that is translated to JSON by Jackson mapper for Spring MVC.
As a system integrator, I'd tell the guys to simply form legal HTTP requests to my component running on Tomcat and decode JSON (which is designed according to THEIR database model).
Instead the guys asked me to translate all the thing to Python. Apart being totally inexperienced in Python (I could barely write a console application that computes binomial coefficient, just not to implement yet another hello world or simple calculator), I guess that in Python no such thing as Hibernate, Spring and Jackson exist.
So, let's go to the question. Are there in Python any frameworks that allow me to...?
Easily create REST APIs with little code (Django????)
Easily intercept existing REST APIs and modularize the HTTP pipeline properly, i.e. doing authentication out-of-api-code, post-processing output stream, etc. through a mechanism similar to interceptors (I have seen something like that in their code base for authentication... we may mark this as solved)
Perform Dependency Injection. When switching between dev, staging, production, I currently change the class implementing an interface invoked by business code
Map objects to relations, such as Hibernate. That's currently my darkest point. I don't think there is any ORM in Python
Map objects to JSON (I know it's feasible, they already do in their codebase)
I won't post sample code believing it useless. I have tried to post a question as a general problem, not digging into specifics.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I developed a mobile application using PhoneGap, to connect to a database through a web service. Since, I am familiar with the .NET environment, I used a WCF service, or more specifically an Ajax Enabled WCF Service, so that I could call the web service through an Ajax call.
Now, I am an absolute beginner in web services and I don't even know the difference between REST and SOAP web services and whether this Ajax Enable WCF service is SOAP or REST web service. Also, can I develop the same web service using Java?
Can you please recommend a book or a tutorial where I can have a crash course on web services and find an answer for all these questions please?
A web service is simply a definition for how two logically or otherwise separated systems can communicate. REST and SOAP are simply two protocols in which this communication can occur. Think of it in terms of a human language wherein one language requires about 100 syllables to get a message across to a listener while another language allows you pass the same message across in 75 syllables or less.
From the metaphor above, REST will be the slimmer 75 syllable language and SOAP the more elaborate 100+ syllabic language.
Note that the transport mechanism remains the same ( oral or spoken word) which is the same case with web services, I.e. the same protocol (REST or SOAP) can be transmitted over different transport channels http, low level sockets, SMTP etc. You can have an overview here
At the end of the day, the founding principle of web services is interoperability, enabling disparate and technologically different systems communicate via open protocols in a platform agnostic manner. Meaning your WCF based service will basically be able to do the same thing as a java(JAX-WS or RS) web service albeit they'll go about it differently.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I want to code a server daemon application that provides some backend functionality. I'd like to stick to Java since I'm pretty familiar with this language and I figure it'd be much easier to just dig into a new framework and not a new language in parallel.
So far I found many promising frameworks, but all of them resemble somehow a webserver. Thing is, I don't want to code a web-application in terms of web-sites so I doubt that I'll need all the webserver-functionality such as templates and this stuff.
What would be a good suggestion for this purpose or would using a regular web-framework such as "play" without the template-stuff be the best choice?
JAX-WS is a standard for creating SOAP web services. Wikipedia link to see what it is about.
For RESTful you would need to make http requests, usually get and post and this type of service works best if you develop a website. From what I understand you don't want this, but still if ever just check the spring framework.
Raw TCP/IP is so much harder and unless you know exactly what you want (performance and optimization wise) you`re better off using a framework.
A webserver is used to implement webservices. A webserver may serve more than html to clients.
I have a personal "stack" using for a long time that is Jetty + RESTEasy and it serves no html at all (only XML and Json).
Javascript + Rest (Glassfish + Jersey for rest). Glassfish – Java EE Full profile certified reference application server (server will used for REST host).
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am a newbie to web-services. What is a good way to learn web-services implementation using java, xml and spring? Are there any good books which cover this topic in good width?
Or, are there any online resources, tutorials, etc.?
Also, what would be good projects to understand this hands-on?
Any recommendations>?
I originally learned Web Services concepts without books, so my opinions may be biased, but I don't think books would help much in the beginning. Once you get to some intermediate state where you need to study security, SOA, etc, maybe books would help.
I needed to get an intern up to speed on Web Services, so I made him implement a two-player game of Reversi using Web Services as the business logic layer with SQL Server underneath it. The UI layer was a desktop executable hitting the service.
You can do something like that using Axis2 and Swing. Once you've built the first UI, you can then try to consume the same service using .NET/Ruby/jQuery or something too to demonstrate the interoperability.
Spring in Action Second Edition has a fair bit of information about using Spring and web services with examples. It worked for me anyway.
I've never read this, but it has good reviews on Amazon: Java Web Services: Up and Running
alt text http://ecx.images-amazon.com/images/I/51OXWAyftOL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA240_SH20_OU01_.jpg
I found books okay, but in the end I used spring web services and it was such a breeze. Highly recommend the reference manual. It has a great introduction on the approach spring web services has taken with the contract first approach and why it is recommended.
http://static.springframework.org/spring-ws/sites/1.5/reference/html/index.html
Cheers.
Some IDEs have web service wizards and projects that take you through setting up a service. They might not be a great way to learn about web services by themselves, but you'll be exposed to some key terms and ideas that can help you build a vocabulary and starting point.
You don't need spring or XML to do web services. Just a simple jetty and stringtemplate will allow you concentrate on the java and web service stuff, and allow you to refactor your code easily in the ide.
I expect to be down voted by the spring fanatics, but honestly, it's whet you want to be doing!
The Java SOA Cookbook is very good - but it does not really cover Spring.
The Spring Recipes book is pretty good at explaining How-To do things in Spring.
I own this book but haven't read it: SOA Using Java Web Services