aspose file tools*
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
Author

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
Greenhorn

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.

package com.ibm.Client;

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 =
"http://localhost:9080/JaxRPCExamples/services/HelloWorld";
// 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.setTargetEndpointAddress(new java.net.URL(endpointURL));
call.setOperationName(new QName("getMessage",methodName));
call.addParameter("name",XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType(XMLType.XSD_STRING);

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) {
System.out.println(e.toString());
}
}
}
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41816
    
  62
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.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Non JSP client for Web Service