Do Java REST frameworks like Restlet and Jersey allow one to send a file as input to a web service?
This would encompass the client sending the file and the server then receiving and processing the file.
If you're asking if you can do an HTTP PUT to a Restlet service, then, absolutely, yes you can. You can use the Directory class if you just want to store the file, or you can implement your own ServerResource to handle the new resource.
I haven't used Jersey, but Restlet is a fantastic api.
Well, there's no restriction for them not to do it. REST handles files without any problems.
Take a look at:
http://mikedesjardins.us/wordpress/2007/04/restful-services-on-ftp/
You can also use REST Assured which builds on HTTP Client. It's very simple:
given().multiPart(new File("/somedir/file.bin")).when().post("/fileUpload");
Related
I have a Jersey REST webservice and it works fine with java client. Now I'm wondering is it possible to use C# or VBA to call this webservice? Sorry I am new to C#/VBA. I am trying to create a add-in for excel. As far as I know I can use these two to create add-in. So my questions are:
What's the best way to create add-in in excel for getting/uploading data? Is Java possible? Or should I use C#?
If I use C#, is it possible to call java webservice in C#? I want to upload data via this webservice.
Thanks in advance.
Anything that can build an HTTP request matching the input expected for your Jersey REST service will work. JAX-WS and JAX-RS services are going to be exposed as agnostic access points for anything which can send an XML/JMS or HTTP request. You can confirm this by simply opening the endpoint in your web browser and trying to submit some GET requests that way.
That is the beauty of web services, they SHOULD be language agnostic. Basically you are just calling a url to return you some xml/json data which c# can handle.
I need to implement web services, send json to a server and read the response. All of the requests are send to the service https://api.polldaddy.com/
This will take place within a web application. This is the api I have to implement :
http://support.polldaddy.com/api/
It seems straightforward, just send some json to the server and consume the json response that is sent back. There seems to be so many options of doing this task that its a little daunting where to start ?
So, where is the best place to start in learning how to implement this service, ie : send json to a server and consume the response.
First of all, you are using the wrong terminology. "Implement web services" implies you will create a service, it sound like you just want to call a web service. You could say "leverage web services" if you need it to be business speak complaint.
The harder way. If you can't add on any additional libraries use java.net.HttpURLConnection.
The easier way. If you can add libraries use the Jersey client API. http://jersey.java.net/nonav/documentation/latest/user-guide.html#client-api
Java EE 7 will include an official client API, EE 6 only included the REST server-side API.
But you should prefer the XML content over the JSON content yourself. JSON is great because it is easy for JavaScript to parse. Java has more ways to parse XML than it does JSON. If you really want to use JSON you could look at something like http://jettison.codehaus.org/
If there is no JAVA API already written I would go for a JAX-RS approach with a client framework like jersey client. Look at http://jersey.java.net/nonav/documentation/latest/client-api.html.
Since you're creating a web app that needs to do HTTP request handling... Start with either Tomcat or Jetty, and Apache HTTP Client, and use a JSON library such as available from json.org.
If you are familiar with maven, you could get all this wrapped up and building within 10 minutes. Otherwise, you'll have to build the webapp and handle dependencies yourself.
If you are on Java EE 7 and want to use the included JAX-RS 2.0 API then have a look at https://github.com/tobiasdenzler/jee7-rest-crud. Its a simple CRUD project using JSON.
I need comunicating using java with a WebService that uses the WSDL technology.
I tried some libraries but with no success, thus, I decided to do it manually.
My plan is getting a .xml which uses the comunication (filtering with fiddler for example) and copy it manually building a string. So the .xml will be ok. Do I need to take care of anything else?
Do I have to do any more? Http request, response?
I wouldn't like to create all the structure for the xml and after that, find that I can't continue the comunication.
Thanks
Java comes with a complete API for XML Web Services, this is JAX-WS. (lot of documentation available with a simple serach with google)
it allows developers to build a working client with very little effort starting from a WSDL file (seems your case)
I really discourage you to build the client by yourself. You should care about SOAP message building, message sending, response parsing and so on.
What is the best way of save data using Restful web service without using Ajax? As a example I need to add a new Customer to the database using submit button.
What is the best way of transfer data format (text,json,xml) ?
How to read POST or GET data from HttpRequest object?
If you can please give me a example in java .
Thank you
I think you need to separate the concepts a bit. A "Restful Web Service" is a web service designed using REST principals, whereas AJAX is a set of technologies used often on the client side for asynchronous requests to multiple resources (without fully reloading the page). The web service really shouldn't care how the HTTP request is generated, just the contents of the HTTP request.
Now if you're concerned about writing a rest service in Java, I would highly recommend looking into JAX-RS and the reference implementation Jersey. There are lots of examples of how to get up and running. You can use MessageBodyReader implementations are to convert data from the HTTP request entity into Java objects.
Obviously this is not the only way to get started with writing a Restful web service in Java, but is one way.
It's very definitely worth your time to carefully study Richardson and Ruby's RESTful Web Services to learn the REST architectural style. In addition to #ach_l's recommendation to use Jersey, take a look at the Restlet Java framework, which is completely wonderful.
I am new to web services. I have a requirement in my project. I have to consume the web services of our vendor in my project. All he has shared with me is a WSDL file and a document about the description of the the different operations.
Question:-
1: What do I need to do consume these web services in my java project? I have been advised to use axis2, eclipse with tomcat6.
2: Do I need to ask for some other files/information from WS vendor OR wsdl file is enough to consume these web services?
3: Do I need to write a java WS client (using axis2 plugin) or another webservice which will talk to vendor web service?
Please suggest the best possible way.
I am sorry if the question sounds like a naive..
Axis is a solid choice for such application.
You need to generate an axis client based on the provided WSDL. Then you import the generated client and use it's methods. You can see the details of this process here (read whole page or starting from the linked section): http://ws.apache.org/axis2/1_0/userguide3.html#Writing_Web_Service_Clients_using_Code_Generation_with_Data_Binding_Support
You could also need some entry-point (WebService URL).
You need to generate a client, not a webservice. See point 1.
Don't use Axis if you need ambient authentication in a Windows environment. I went down that path and ended up going with Apache CXF - which seems better to me anyhow.
You can use SOAP UI to test the web service. It'll read the WSDL, let you create requests by filling in values, and display the response that you get back. It might help you get a better understanding of what the service does before you start writing your classes.
You don't need to create a new web service in order to consume a web service, you need to write a web service client.
Similar question to this one:
Steps in creating a web service using Axis2 - The client code
All the standard web frameworks have a command (normally called wsdl2java) that will read the WSDL and then generate a java based client object.
I can recommend Axis2, but another popular choice is CXF