import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.client.Options;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.transport.http.HTTPConstants;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;

public class webClientBean {

	public void callWebServiceSet(String command, String message){    
		ServiceClient serviceClient;
    		try {
        		serviceClient = new ServiceClient();
        		Options options = new Options();
        		options.setTo(new EndpointReference("https://****.ac.uk/axis2/services/Service"));
        		options.setAction(command);
        		serviceClient.setOptions(options);
        		OMElement result = serviceClient.sendReceive(createPayload(command,message));
    		}catch (AxisFault ex) {
               System.out.println("Error whilst creating Service Client");
    	}

	public OMElement createPayLoad(String method_name, String mess) {
        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace omNs = fac.createOMNamespace(
                      "http://services.****.ac.uk","Service");
        OMElement method = fac.createOMElement(method_name, omNs);
        if (!mess.equals("null")){
        OMElement value = fac.createOMElement("value", omNs);
        value.setText(mess);
        }
        method.addChild(value);
        return method;
}

}
