直接在第一个webservice调用成功后,if else判断结果 继续调用第二个。
一个线程应该是够了。
一个线程应该是够了。
解决方案 »
- emulator-arm.exe 已停止工作?
- Android多点触控的问题
- 修改源码后模拟器里没用
- 程序卸载后 SharedPreferences 数据 没有删除
- 有关sendBroadcast 问题
- 如何在目的activity中获取intent启动源的名字
- 关于cursor
- 关于使用handle产生The Application has stopped unexpectedly的问题
- http://localhost:8080/ 不能连接上,出错
- 安卓手机越用越慢的真实底层原因是什么??请进讨论
- ubuntu下加载驱动Invalid module format错误
- AlertDialog为什么不能通过new得到一个AlertDialog对象
我目前手头项目是基于phonegap开发,里面也涉及到调用webservice
基本思路像1#所说,我的界面用html5写的,
使用ajax调用webservice:
$.ajax({//调第一个
。
success: function (data, textStatus) {
if(....){//在某个条件情况下调用第二个
$.ajax({
。
success: function (data, textStatus) {}
}
}
strMethodName=“方法1";
StartThread();
strMethodName=“方法2";
StartThread();
private String strMethodName; private void StartThread() throws Exception
{
new Thread(MyGetInfo).start();
}Handler handler = new Handler()
{
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
try{
Bundle data = msg.getData();
String result = data.getString("value");
if (msg.obj.toString().equalsIgnoreCase("方法1")){
//取得结果
}
else if (msg.obj.toString().equalsIgnoreCase("方法2")) {
//取得结果
}
}
catch (Exception e)
{
}
}
};Runnable MyGetInfo = new Runnable()
{
@Override
public void run()
{
String result = "";
try
{
//命名空间
String nameSpace = "http://test.com/";
//调用的方法名称
String methodName = strMethodName;
//EndPoint
String endPoint = "http://" + ServerIp + ":13188/Service.asmx";
//SOAP Action
String soapAction = nameSpace + strMethodName;
//指定WebService的命名空间和调用的方法名
SoapObject rpc = new SoapObject(nameSpace, methodName);
//生成调用WebService方法的SOAP请求信息,并指定SOAP的版本
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.encodingStyle = "UTF-8";
envelope.bodyOut = rpc;
//设置是否调用的是dotNet开发的WebService
envelope.dotNet = true;
envelope.bodyOut = rpc;
//等价于envelope.bodyOut = rpc;
//envelope.setOutputSoapObject(rpc);
HttpTransportSE transport = new HttpTransportSE(endPoint);
//transport.debug = true;
// 调用WebService
transport.call(soapAction, envelope);
// 获取返回的数据
SoapObject object = (SoapObject) envelope.bodyIn;
// 获取返回的结果
result = object.getProperty(0).toString();
}
catch (Exception e)
{
result = "error:" + e.toString();
}
finally
{
Message msg = new Message();
Bundle data = new Bundle();
data.putString("value",result);
msg.setData(data);
msg.obj = strMethodName;
handler.sendMessage(msg);
}
}
};