1
我是新来的android。我需要连接到android的web服务。 webservice方法返回一个大于10MB的字符串值。我想过尝试使用KSOAP。有人可以给我一个简短的例子,使用Android的KSOAP连接到SOAP web服务吗?从android使用KSoap连接到webservice
我是新来的android。我需要连接到android的web服务。 webservice方法返回一个大于10MB的字符串值。我想过尝试使用KSOAP。有人可以给我一个简短的例子,使用Android的KSOAP连接到SOAP web服务吗?从android使用KSoap连接到webservice
添加KSOAP jar文件,并使用异步方法用于web服务
public class Connection extends AsyncTask<Void,Void,Void> {
@Override
protected Void doInBackground(Void... params) {
String SOAP_ACTION = "http://www.example.com/Get/GetCount";
String METHOD_NAME = "GetCount";
String NAMESPACE = "http://www.example.com";
String URL = "http://www.example.com/Get.php?wsdl";
String Result;
SoapObject request1 = new SoapObject(NAMESPACE, METHOD_NAME);
request1.addProperty("AppId", 1);
SoapSerializationEnvelope envelope = new soapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true; envelope.setOutputSoapObject(request1);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true; try {
//this is the actual part that will call the webservice
androidHttpTransport.call(soapaction, envelope);
}
catch (IOException e) {
e.printStackTrace(); }
catch (XmlPullParserException e)
{ e.printStackTrace(); }
// Get the SoapResult from the envelope body.
SoapObject result = (SoapObject)envelope.bodyIn;
Result = result.getProperty(0).toString();
JSONObject jArray = new JSONObject(Result);
JSONArray Count = jArray.getJSONArray("Details");
ArrayList<HashMap<String, String>> myList = new ArrayList<HashMap<String, String>>();
for(int i=0;i < Count .length();i++){
HashMap<String, String> map = new HashMap<String, String>();
JSONObject e = Count .getJSONObject(i);
map.put("id", e.getString("ID"));
myList.add(map);
}
}
ahaaaa你是怎么谷歌呢?已经有很多例子可用。 – 2012-03-30 07:43:36
我会建议你为此使用'Json'。它轻巧,方便,快捷。 – waqaslam 2012-03-30 07:44:14
我需要一个简单的应用程序,读取一个大于10MB的文件并与之一起玩。可能吗? (在它的内存中加载一个文件,使用它并返回它) – user1222905 2012-03-30 07:54:22