import org.apache.axis.AxisFault;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.encoding.JAFDataHandlerSerializer;
import org.apache.axis.encoding.JAFDataHandlerDeserializer;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.xml.rpc.namespace.QName;

import java.net.URL;

public class AxisClient3
{
	public static void main(String [] args)
	{
		try
		{
			//Create the data for the attached file.
			String fileName = "user.properties";
			DataHandler dhandler = new DataHandler(new FileDataSource(fileName));

			String endpointURL = "http://localhost:8080/axis/services/urn:greetingService2";

			String methodName = "sayHello";

			Service service = new Service();

			//Create a Call object and set the parameterss
			Call call = (Call) service.createCall();
			call.setTargetEndpointAddress(new java.net.URL(endpointURL));
			call.setOperationName(methodName);
			call.setProperty(Call.NAMESPACE, "urn:greetingService2");

			QName qname = new QName("urn:greetingService2", "DataHandler");

			call.addSerializer(DataHandler.class,qname, new JAFDataHandlerSerializer());

			call.addDeserializerFactory(qname, DataHandler.class, JAFDataHandlerDeserializer.getFactory());

			call.addParameter("source", new XMLType(qname), Call.PARAM_MODE_IN);

			String response = (String)call.invoke(new Object[]{dhandler});
System.out.println("response = " + response);
			System.out.println("The Resonse:");
			System.out.println(response);
		}
		catch (AxisFault fault)
		{
			System.out.println(fault.toString());
		}
		catch(Exception e)
		{
			System.out.println(e);
		}
	}
}
