// nameSpace 命名空间,methodName:方法名字;maps:参数集合;webserviceUrl:访问的webservice的网址;比如:http://17.18.199.100:80805/doReqToWebWs.asmx
private String ws(String nameSpace,String methodName,HashMap<String,String> maps,String webserviceUrl){ String result=""; try{ SoapObject request=new SoapObject(nameSpace,methodName);//NameSpace //webService方法中的参数,这个根据你的webservice来,可以没有。 //但请注意,参数名称和参数类型客户端和服务端一定要一致,否则将可能获取不到你想要的 Iterator<String> it = maps.keySet().iterator(); while (it.hasNext()) { String keyString = it.next(); request.addProperty(keyString, maps.get(keyString)); } SoapSerializationEnvelope envelope=new SoapSerializationEnvelope( SoapEnvelope.VER11); envelope.dotNet=true; envelope.setOutputSoapObject(request); HttpTransportSE ht=new HttpTransportSE(webserviceUrl); ht.call(nameSpace + methodName, envelope); if(envelope.getResponse()!=null){ SoapPrimitive response=(SoapPrimitive)envelope.getResponse(); result=response.toString();//这里获得了webService的返回值 Log.e("resultCode",result); } }catch(Exception e){ result=e.getMessage(); Log.e("resultCode22",result); } return result; }