/*** 请求webservice并返回响应* @param namespace webservice命名空间* @param webServiceURL WSDL文档的URL * @param soapAction SOAPAction* @param methodName 要调用的webservice方法名* @param propertyInfos PropertyInfo参数数组* @param timeout 超时时长 毫秒* @param mappingName 对象参数类名* @param mappingClass 对象参数类* @return* @throws XmlPullParserException * @throws IOException */public static Object visitWebService(String namespace,String webServiceURL,String soapAction,String methodName,PropertyInfo[] propertyInfos,int timeout,String mappingName,Class mappingClass) throws IOException, XmlPullParserException{Object result = null;//创建SoapObject对象,并指定WebService的命名空间和调用的方法名SoapObject soapObject = new SoapObject(namespace, methodName);//设置WebService方法的参数if(propertyInfos!=null)for(int i=0;i
ht.call(soapAction, envelope);//使用getResponse方法获得WebService方法的返回结果 result = envelope.getResponse();return result;}
PropertyInfo[] propertyInfos = new PropertyInfo[1];PropertyInfo propertyInfo = new PropertyInfo();propertyInfo.setName("model");propertyInfo.setValue(new Model("BB", 99));propertyInfo.setType(Model.class);propertyInfos[0] = propertyInfo;
终于可以调用带对象参数的方法了。