此方法,只能调用接口里面单个参数的方法,
wsdl地址,后面,不能跟 “?wsdl” 否则抛异常
org.xml.sax.SAXException: Bad envelope tag: definitions
----------------------------------------------------------------
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import javax.xml.rpc.ParameterMode;
public static String callInterfase(String wsdlUrl,String methodNme,String xml) {
if(wsdlUrl.equals("") || methodNme.equals("") && xml.equals("")) {
return null;
}
String result = "";
try {
Service service = new Service();
Call call;
call = (Call) service.createCall();
call.setTargetEndpointAddress(wsdlUrl);
call.setOperationName(new QName(wsdlUrl,methodNme));//要调用的方法
call.setReturnType(XMLType.XSD_STRING);//返回的类型此类型是XML
call.addParameter("arg0", XMLType.XSD_STRING, ParameterMode.IN);
//如果有两个参数
//call.addParameter("arg1", XMLType.XSD_STRING, ParameterMode.IN);
result = (String) call.invoke(new Object[] { xml });//传参内容
}
catch (Exception e) {
System.err.println(e.toString());
}
return result;
}