1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| package client;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.description.OperationDesc;
import org.apache.axis.description.ParameterDesc;
import org.apache.axis.encoding.XMLType;
public class AxisDynamicClient {
public static void main(String args[]) {
try {
String EPR = "ENDPOINTREFERENCE";
String TNS = "TARGETNAMESPACE";
OperationDesc desc = new OperationDesc();
desc.addParameter(new ParameterDesc(new QName("INPARAM"), ParameterDesc.IN, XMLType.XSD_STRING));
desc.setReturnType(XMLType.XSD_STRING);
Call call = (Call)new Service().createCall();
call.setOperation(desc);
call.setTargetEndpointAddress(new URL(EPR));
call.setSOAPActionURI(TNS + "OPERATIONNAME");
call.setOperationName(new QName(TNS, "OPERATIONNAME"));
String inparam = "MyParam";
String outparam = (String)call.invoke(new Object[] {inparam});
} catch(MalformedURLException e) {
e.printStackTrace();
} catch(RemoteException e) {
e.printStackTrace();
} catch(ServiceException e) {
e.printStackTrace();
}
}
} |