Send a REST request via HTTP [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
So I am using an API and it says that you have to use the API via "REST" and then says "Call our service via HTTP". I've never heard of REST and was wondering if it was possible to send a REST request via HTTP and then get the response.
The API I'm trying to use is http://frengly.com/

REST stands for Representational State Transfer. (It is sometimes
spelled "ReST".) It relies on a stateless, client-server, cacheable
communications protocol -- and in virtually all cases, the HTTP
protocol is used.
REST is an architecture style for designing networked applications.
The idea is that, rather than using complex mechanisms such as CORBA,
RPC or SOAP to connect between machines, simple HTTP is used to make
calls between machines.
Lear more about rest through this easy to understand tutorial: http://rest.elkstein.org/
REST basically leverage the use of HTTP methods such as GET,POST, PUT, DELETE to do the CRUD opearation on an entity.

Technically REST doesn't have to be over HTTP. But when someone says REST they usually mean it is over HTTP. Here's a great video explaining the definition of REST.
To send a query to a http REST API using Java, you could either use the low level URLConnection or the higher level HttpComponents.

Related

Is PHP server, and JAVA client possible? [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 8 years ago.
Improve this question
I have searched for some hours now, and can't find an answer. I have a homepage coded in php that needs to frequently send and receive data to a java program.
So far I have done it via POST, but I wonder if it's a better way to do it. I have tried with sockets. But only managed to find tutorials for php client connecting to a java server. But I need the reverse.
All modern languages allow you to send and receive data, no matter from which language is sent or received. Many large applications (such as Facebook API), work with simple methods such as POST, GET, PUT, DELETE, etc., that is a REST API, returning the data in a specific format (JSON, XML, RAW, etc.). This is innecessary if your application is a little piece of code, but you could take this idea and make something simple. So, there is nothing wrong if you are using the POST method, but just in case, I can name you other resources that you could take advantage of.
You can use WebClient.
Also, you can comunicate your PHP code with your Java code using sockets.
TCP sockets: for PHP read this, and this guide for Java.
WebSockets: Java WebSockets for Java and Ratchet for PHP.
Of course, you can use cURL too. For Java you can read this question and connect with php. If your application is very large and complex in the PHP side, I guggest you to use Laravel.

Difference between Rest, RestApi, WebService, RestFulApi [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 8 years ago.
Improve this question
Now a days I hear different terms like Web-service, API, Rest, RestFulAPI, SOAP etc. We write a RestApi by using google cloud end points for our mobile application.
Even though we are implementing RestAPI, I have a lot of confusion about the terms which I have mentioned. Can I call my RestAPI (using google cloud end points) as a Web-service?
I googled about it a lot but I did not get any clarification. Can I assume RestAPI and RestFulAPI are the same?
There are basically two differnt type of Webservices
RESTFul and SOAP based
Representational state transfer (REST) is a style of software architecture. As described in a dissertation by Roy Fielding, REST is an "architectural style" that basically exploits the existing technology and protocols of the Web. RESTful is typically used to refer to web services implementing such an architecture.
To find difference between RESTFul Webservices and RESTApi check this out
More about REST in this thread
Hope this will give you good insight.
Web services are services communicating over a network. This is a general term, and they cover services over HTTP or not, RESTful services or not. An example of non-RESTful web services is SOAP.
To answer your question: a REST API is a web service. REST and RESTful services mean the same thing.
Some prefer not to use the terminology 'web service' when using REST principles and prefer to say 'REST(ful) API' in order to differentiate from 'old school' services, e.g. with RCP or SOAP.
To increase confusion even more, some call their APIs 'RESTful', just because they use JSON over HTTP. This is not REST!

Web-services: remote interfaces vs request/responce scheme [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 8 years ago.
Improve this question
I've never used SOAP or EJB. I read about SOAP and can't grasp one (maybe the main) point.
Question: Why should one use remote interfaces instead of simple request/responce scheme?
My considerations: SOAP allows us to invoke methods of remote services. It uses XML. But why it's better than just use SOA (service oriented approach) and send an JSON request -> get JSON response. I do so in my application with help of WebSockets and JSON. Moreover, SOAP is slow, seems it is slower than approach that I need.
I suppose the advantage of the remote interface is that you wouldn't have to parse any XML. When you receive your reply from a remote interface an object is constructed that you are able to use without any further processing. However SOAP seems to be a more popular method currently as you are not restricted to a particular environment. For instance you have to use java on the client to use the remote interface but with SOAP any client can accept and process the XML
The reason for this is SOAP takes a contract-first approach. This also allows us to build classes from these contracts so we have classes that can be built by a WSDL. This is very useful because it means we don't have to build classes representing the web service endpoint, however, if the endpoints signature changes we need to update our associated generated WSDL classes.
SOAP, in my humble opinion, is much more useful for say .NET or Java because of the classes that can be generated from it and the help your IDE can bring by instantly allowing you to access these classes. When I've used php, I always found it felt like SOAP wasn't quite as easy to work with as REST because of having to build up XML responses when all you want to actually send is "something=true".

Web service using php soap server and java client [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I want to learn to implement web services using soap in php. I also want to utilize the service using java client. I am interested in soap protocol and if there is some othere better protocol.
My research: I got many online tutorials on implementing web service using soap in php. I also got greate content on soap protocol.
My question: How to utilize that service using java client? Is it possible? Can you refer me to tutorial which serves my need? Is there any good book that i can purchase. I also want to know how can a php soap server authenticate a java client. Is authentication done for each request or maintaining session is possible.
By definition:
Web Services have been designed to support interoperable Machine to
Machine interaction over a network.
So consuming a web service is independent of the implementation technology of the web service, now you can search for "implement a Java based SOAP client" on SO.
plus check below URLs:
Java Client – PHP Soapserver
And THIS free book by Nan-Chao Huang.

Work with network in swing application [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am developing swing application that will communicate with server via
web sockets.
I plan to create separate threads for sending/receiving packets, connecting
and disconnecting operations. Also for packet processing i plan to use queue.
Could you suggest, is this correct network layer design?
Or there is exist something better?
Thanks.
It is hard to say something on this subject, it really depends.
If you have experience with Rich Internet Applications you can design your application in a similar way. So, you could have a web service running SOAP and you Swing application exchanging data via asynchronous HTTP calls (similar to Ajax's approach).
Also, I would highly suggest designing some sort of MVC before getting started where the View would be your Swing components, the Controller would handle business rules/validations/threads, and the Model handles the communication between your desktop app and web server.
Finally, I would discourage queueing packages. I did it in the past and regretted because it became too complex and convoluted. In my case, I realized that if something goes wrong I would just throw Exception and handle the error. So, in some cases it would result in a error message on the user interface where the user could take contingency actions; in other cases, the application would try that same operation again latter.
I hope this description can help you somehow.
Cheers,

Categories