I am looking to invoke the API from here http://glosbe.com/a-api
I'm creating the client in Netbeans IDE 7.4. But when I try to create the client from netbeans, it only gives me the option to do it from wsdl URL and not from an API. How am I able to invoke that glosbe API from my client?
Ulf Dittmer wrote:Welcome to JavaRanch.
Straight URL access could be done by something as simple as the java.net.URL class: new URL("http://glosbe.com/gapi/....").openStream(), and then slap an InputStreamReader around that, and a BufferedReader around that.
Will this allow me to invoke that API? I'm looking to create a service where users will be able to enter a word into a search box and that will invoke the API available at Glosbe, that in turn will return the definition of the word without the page reloading.
I've been told that I need to create a client so will using the java.net.URL class be appropriate in my situation?
I'm quite new to this so I only know the basics at the moment, any help is very much appreciated.
Ulf Dittmer wrote:Yes, that would invoke the API, judging by a cursory glance at that link.
Thank you Ulf, and thank you for the welcome.
I've got that far but nothing happens at the moment. How am I able to make it so that when the user types in a word in the text box and clicks the submit button the definition is displayed on the page below?
Ulf Dittmer wrote:That depends on the context - is this a Swing app? Have you successfully read the output from the stream? Where exactly are you stuck?
Not as of yet, I just have the file setup. I'm stuck on getting the output from the API and displaying it back on the web page.
I'm not aware of what a swing app entails.
I'm sorry, I will try to explain it better.
I am required to develop a client browser interface which utilises the dictionary web service at Glosbe.com
The user should be able to enter a word or phrase into an output component and submit it without the page reloading. I want the returned data to be displayed on the same web page without the page reloading. The returned data needs to be displayed so that the user can read it easily and see the meaning to the word.
I'm looking to do this within a JS function and a HTML web page. I'm open to using either JSON or XML for the output.