Web Services on Command Line

Can Web services be consumed on Command line? Yes you can. But how? Well, you can post an XML document using wget to the service. Well, what if you want to use WS-Addressing or WS-Security? Well then you can use wsclient that comes with WSO2 WSF/C.

What is wsclient? It is a program that be used as a Web services client. It can do both REST as well as SOAP calls. More over, it can deal with WS-Addressing, WS-Security as well as binary attachments.

Here is a very simple example on consuming Yahoo search with REST API

1. Save the following request XML payload to ysearch.xml file

<webSearch>
    <appid>WSClientDemo</appid>
    <query>WSO2 WSF/C</query>
    <form/>
</webSearch>

2. Run the wsclient command

wsclient.exe -get http://search.yahooapis.com/WebSearchService/V1/webSearch < ysearch.xml

It is as simple as that.

There are samples that shows hot to consume the Flicker API both using REST as well as SOAP.

The key advantage of wsclient, is that, you can use that in shell scripting, the way you would do with other familiar command line programs. Shell scripts, batch files, and even scripts written in scripting languages like Perl could call the program.

wssclients could integrate geeks and power users to SOA :-)

Comments

Vivek said…
Try wsdlpull.sf.net