麻烦大家发一点点时间帮我看看,为什么就是连接不起呢!
package com.example.getservice;import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 命名空间

String nameSpace = "http://WebXml.com.cn/";
// 调用的方法名称
String methodName = "getMobileCodeInfo";
// EndPoint
String endPoint = "http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx";
// SOAP Action
String soapAction = "http://WebXml.com.cn/getMobileCodeInfo";
// 指定WebService的命名空间和调用的方法名
SoapObject rpc = new SoapObject(nameSpace, methodName);
// 设置需调用WebService接口需要传入的两个参数mobileCode、userId
rpc.addProperty("mobileCode", "13154668959");
rpc.addProperty("userId", "");
// 生成调用WebService方法的SOAP请求信息,并指定SOAP的版本
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
// 设置是否调用的是dotNet开发的
envelope.dotNet = true;
// 等价于envelope.bodyOut = rpc;
envelope.setOutputSoapObject(rpc);
HttpTransportSE transport = new HttpTransportSE(endPoint);
try {
// 调用WebService
transport.call(soapAction, envelope);
} catch (Exception e) {
e.printStackTrace();
}
// 获取返回的数据
SoapObject object = (SoapObject) envelope.bodyIn;
// 获取返回的结果
String result = object.getProperty("getMobileCodeInfoResult").toString();

TextView textView=(TextView)findViewById(R.id.text1);

//textView.setText(result);

textView.setText(getlogindata());

}

static final String SERVICE_NS = "http://WebXml.com.cn/";

static final String SERVICE_URL = "http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx";


//接受登陆反馈数据
public String getlogindata(){


final String methedName = "getMobileCodeInfo";

SoapObject soapObject = new SoapObject(SERVICE_NS, methedName);
soapObject.addProperty("mobileCode", "13154668959");
soapObject.addProperty("userId", "");
final HttpTransportSE ht = new HttpTransportSE(SERVICE_URL);
ht.debug = true;
final SoapSerializationEnvelope enveloper = new SoapSerializationEnvelope(SoapEnvelope.VER11);
enveloper.dotNet = true;
enveloper.bodyOut = soapObject;

FutureTask<SoapObject> task = new FutureTask<SoapObject>(new Callable<SoapObject>() {
@Override
public SoapObject call() throws Exception {
ht.call(null, enveloper);
if(enveloper.getResponse() != null){
//SoapObject result = (SoapObject)enveloper.getResponse();
SoapObject result = (SoapObject)enveloper.bodyIn;
return result;
}
return null;
}
});
new Thread(task).start();
try {
String string=(String) task.get().getProperty("getMobileCodeInfoResult");
return string;
} catch (Exception e) {
e.printStackTrace();
}
return "0";  
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}}
webservice