package com.chaoran.thread;

import android.os.Handler;
import android.os.Message;
import com.sys.SysData;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
public class UpdatePwdThread implements Runnable {
	private Handler handler;
	private String  userid;
	private String  newPwd;
	public  UpdatePwdThread(Handler handler,String  userid,String  newPwd) {
		this.handler=handler;
		this.userid=userid;
		this.newPwd=newPwd;
	}
	@Override
	public void run() {
		String url = SysData.url + "/webservice/ServiceInterface?wsdl";
		String method = "updatePwd";
		SoapObject rpc = new SoapObject("", method);
		rpc.addProperty("userid",userid);
		rpc.addProperty("newPwd",newPwd);
		HttpTransportSE ht = new HttpTransportSE(url,SysData.timeout);
		ht.debug = true;
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		envelope.bodyOut = rpc;
		envelope.dotNet = true;
		envelope.setOutputSoapObject(rpc);
		Message msg = new Message();
		try {
			ht.call("", envelope);
			String backmsg=envelope.getResponse().toString();
			msg.obj =backmsg;
			handler.sendMessage(msg);
		} catch (Exception e) {
			msg.obj =e.toString();
			msg.what = -1;
			handler.sendMessage(msg);
		}
	}

}
