One of my current favorite features in the IDE is the Web Service Registry:

You can register web services there yourself and/or use the defaults provided by the IDE. Expand a node and you will end up with the specific method on the web service you'd like to invoke. Then you can drag that node into the Java editor. When you do so, all the background files are created (e.g., even including the file that will hold a registration key, if any, such as required by Yahoo, for example). Plus, you get a chunk of code in your Java class for invoking and processing the method on the web service.
And so that's how I ended up with the code below. Most of it comes from the node I dropped into the Java class, the rest of it is from the NetBeans Command Line Parsing API: @ServiceProvider(service = OptionProcessor.class) public class YahooNewsOptionProcessor extends OptionProcessor { private Option news = Option.requiredArgument('n', "news"); private Option language = Option.requiredArgument('l', "language"); @Override protected Set getOptions() { return Collections.singleton(OptionGroups.allOf(news, language)); } @Override protected void process(Env env, Map values) throws CommandException { String[] args1 = (String[]) values.get(news); String[] args2 = (String[]) values.get(language); if (args1.length > 0) { try { String query = args1[0]; String type = "all"; java.lang.Integer results = 10; java.lang.Integer start = 1; String sort = "rank"; String language = args2[0]; String output = "xml"; String callback = null; RestResponse result =, type, results, start, sort, language, output, callback); if (result.getDataAsObject( wssearchresponse.ResultSet.class) instanceof yahoo.newssearchservice.newssearchresponse.ResultS et) { yahoo.newssearchservice.newssearchresponse.ResultS et resultObj = result.getDataAsObject( ssearchresponse.ResultSet.class); List result1 = resultObj.getResult(); for (ResultType resultType : result1) { String summary = resultType.getSummary(); System.out.println("--->"); System.out.println(summary); } } LifecycleManager.getDefault().exit(); } catch (Exception ex) { ex.printStackTrace(); } } } }
I then created a ZIP distribution of the application. Then I unzipped that and went to the command line. I typed this:
yahoonews --news "world peace" --language "en"
And then I had Yahoo News on the command line:

I intend to include this demo, or one very much like it, in a BOF I am doing with Milan Kuchtiak on Wednesday, 22 September, at 14:15, entitled "Hello RRCD: Rapid REST Client Development".

Read More about [Yahoo News on the Command Line...