This client program is a consumer process to invoke Axis Webservice.
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
import java.io.*;
// Argument 1 : End Point URL
// Argument 2 : Method Name
// Argument 3 : Input Request XML file
public class TestAxisWSClient {
public static void main(String [] args) throws Exception{
if (args[0] ==null || args[1] ==null || args[2] ==null){
System.out.println("Enter all the Inputs for End Point URL (1st arg), Method Name (2nd arg), XML (Input file) (3rd arg)");
}
String endpoint = args[0];
String methodName = args[1];
String fileName = args[2];
String thisLine;
// To process the Request XML file and store as string
BufferedReader br = new BufferedReader(new FileReader(fileName));
String xmlRequest = "";
while ((thisLine = br.readLine()) != null) {
xmlRequest = xmlRequest + thisLine;
}
System.out.println("Request XML is :\n" + xmlRequest);
try {
// Service and Call methods to invoke the webservice
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint));
call.setOperationName(new QName("http://soapinterop.org/", methodName));
Object obj[] = {new String(xmlRequest)};
String ret = (String) call.invoke( obj );
System.out.println("Response : " + ret );
} catch (Exception e) {
e.printStackTrace();
}
}
}