安卓调用.net的本地发布的webservice问题不能解决,求助

jianxuandie 2012-09-13 04:27:55
java代码
public class RegisterActivity extends Activity {

String text_account = "";
String text_pasword = "";
String text_mail = "";
String AddUserresult = "";
String nameSpace = "http://tempuri.org/"; // 空间名可以修改
String methodAddUser = "AddUser"; // 需调用 web service 名称
String serviceUrl = "http://10.0.2.2:8089/Service.asmx";

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.register);
// 获取应用程序中的注册按钮
Button re_register = (Button) findViewById(R.id.register_re);
Button close = (Button) findViewById(R.id.register_exit);
// 获取edit text
final EditText Edit_Account = (EditText) findViewById(R.id.edit_account);
final EditText Edit_PassWord = (EditText) findViewById(R.id.edit_password);
final EditText Edit_Mail = (EditText) findViewById(R.id.edit_mail);
re_register.setOnClickListener(new OnClickListener() {
public void onClick(View source) {
// 此处写入注册代码
text_account = Edit_Account.getText().toString();
text_pasword = Edit_PassWord.getText().toString();
text_mail = Edit_Mail.getText().toString();
HttpTransportSE htAdduser = new HttpTransportSE(serviceUrl);
htAdduser.debug = true;
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
SoapObject soapObject = new SoapObject(nameSpace, methodAddUser);
soapObject.addProperty("arg0", text_account);
soapObject.addProperty("arg1", text_pasword);
soapObject.addProperty("arg2", text_mail);
envelope.bodyOut = soapObject;
envelope.dotNet= true;

try {
htAdduser.call(null, envelope);
if (envelope.getResponse()!=null) {
SoapObject result = (SoapObject)envelope.bodyIn;
AddUserresult = result.getProperty(0).toString();
Toast toast = Toast.makeText(RegisterActivity.this, "注册成功", Toast.LENGTH_SHORT);
toast.show();
} else {
Toast toast = Toast.makeText(RegisterActivity.this, "注册失败", Toast.LENGTH_SHORT);
toast.show();

}
} catch (IOException e) {
e.printStackTrace();
}catch(XmlPullParserException e){
e.printStackTrace();
}

}




...全文
113 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jianxuandie 2012-09-14
  • 打赏
  • 举报
回复
木人回答啊
jianxuandie 2012-09-13
  • 打赏
  • 举报
回复
点击按钮之后没什么反映
是什么问题

51,409

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧