permaculture playing cards
The moose likes Websphere and the fly likes Non JSP client for Web Service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "Non JSP client for Web Service" Watch "Non JSP client for Web Service" New topic

Non JSP client for Web Service

Sam Gehouse
Ranch Hand

Joined: Jul 21, 2003
Posts: 281
Cany anybody point me to an article, or source code that shows an example of a client created to invoke a web service.

I created a web service using RAD 6.0. It gernerated corresponding wsdl etc. RAD can also create a client project for you that uses a JSP (Test.jsp) to test the service code.

However, I would like to know how I can write clinet code myself, instead of relying on the client code that can be generated by RAD.

I would like to write client code that will be invoked from a non web app. As such, I do not want the client code to be JSP or Servlet based.

Any help with example, or pointing out any article will be helpful.
viswa vishveswara

Joined: Sep 19, 2007
Posts: 2
Hi Sam Gehouse
Other than Web Client (JSP) created by the RAD we can write the normal Standalone java class (main method) or we can write the EJB client

fine the example client below.


import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;

public class Client {

// Creates new HelloWorldClient
public Client() {

public static void main (String args[]) {
try {
// EndPoint URL for the SparePartPrice web service.
String endpointURL =
// Method Name to invoke for the SparePartPrice web service
String methodName = "getMessage";
// Create the Service call
Service service = new Service();
Call call = (Call) service.createCall();
call.setOperationName(new QName("getMessage",methodName));
call.addParameter("name",XMLType.XSD_STRING, ParameterMode.IN);

Object[] params = new Object[] {"INDIA"};

//Invoke the SparePartPrice web service
String response= (String) call.invoke(params);
//Print out the result
System.out.println("Message is "+response);
catch (Exception e) {
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Be aware that this example uses the obsolete JAX-RPC API. You can find a client that uses the SAAJ API (which is still current) here.
I agree. Here's the link:
subject: Non JSP client for Web Service
It's not a secret anymore!