日期:2014-05-19 浏览次数:20772 次
import javax.xml.namespace.QName; import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis.description.OperationDesc; import org.apache.axis.description.ParameterDesc; public class TestInteface2 { public static void main(String[] args) throws Exception { String url = "省略"; String method = "method"; String result = getOrderInfo(url,"domain",method, null); System.out.println(result); } public static String getOrderInfo(String url, String domain, String method, String req) throws Exception { OperationDesc oper = new OperationDesc(); ParameterDesc param = new ParameterDesc( new QName(domain, "xmlDoc"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false ); ParameterDesc param2 = new ParameterDesc( new QName(domain, "xmlDoc"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false ); ParameterDesc param3 = new ParameterDesc( new QName(domain, "xmlDoc"), ParameterDesc.IN, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false ); param.setOmittable(true); oper.addParameter(param); oper.addParameter(param2); oper.addParameter(param3); oper.setReturnType( new QName("http://www.w3.org/2001/XMLSchema", "string") ); Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(url); call.setOperation(oper); call.setSOAPActionURI(domain+method); call.setOperationName(new QName(domain, method)); try { Object resp = call.invoke(new Object[] {"1","2","3"}); if (resp instanceof java.rmi.RemoteException) { throw (java.rmi.RemoteException)resp; } else { try { return (String) resp; } catch (Exception _exception) { return (String) org.apache.axis.utils.JavaUtils.convert(resp, String.class); } } } catch (org.apache.axis.AxisFault axisFaultException) { throw axisFaultException; } } }