如下代码,到ht.call(null, envelope);这行代码,就报IOException异常,谁能告诉我原因,我是初学者。谢谢!public class MainActivity extends Activity { // WebService所发布的方法
private static final String METHOD_NAME = "SayHelloWorld";
// WebService 的命名空间
private static final String NAMESPACE = "http://www.ghinfo.com/";
// 服务器发布的 url
private static final String URL = "http://cw.ykg.com:66/TestDALService.asmx"; EditText etUserName;
Button btOK; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); etUserName = (EditText) findViewById(R.id.editText1);
btOK = (Button) findViewById(R.id.button1);
btOK.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
etUserName.setText("11111111111111");
}
});
SoapObject soapObject = new SoapObject(NAMESPACE, METHOD_NAME);
soapObject.addProperty("personName", etUserName.getText().toString());
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER12);
envelope.bodyOut = soapObject;
envelope.dotNet = true;
envelope.setOutputSoapObject(soapObject);
HttpTransportSE ht = new HttpTransportSE(URL);
ht.debug = true; // 使用 call 方法调用 WebService 方法
try {
ht.call(null, envelope);
if (envelope.getResponse() != null) {
Object sb = envelope.getResponse();
etUserName.setText(sb.toString());
} else {
System.out.println("用户名或者密码不正确!");
}
} catch (IOException e) {
// TODO Auto-generated catch block
etUserName.setText("IOException");// 获取从服务器端返回的 XML 字符串
e.printStackTrace();
} catch (XmlPullParserException e) {
etUserName.setText("XmlPullParserException");// 获取从服务器端返回的 XML 字符串
// TODO Auto-generated catch block
e.printStackTrace();
} } @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}androidwebservice
private static final String METHOD_NAME = "SayHelloWorld";
// WebService 的命名空间
private static final String NAMESPACE = "http://www.ghinfo.com/";
// 服务器发布的 url
private static final String URL = "http://cw.ykg.com:66/TestDALService.asmx"; EditText etUserName;
Button btOK; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); etUserName = (EditText) findViewById(R.id.editText1);
btOK = (Button) findViewById(R.id.button1);
btOK.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
etUserName.setText("11111111111111");
}
});
SoapObject soapObject = new SoapObject(NAMESPACE, METHOD_NAME);
soapObject.addProperty("personName", etUserName.getText().toString());
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER12);
envelope.bodyOut = soapObject;
envelope.dotNet = true;
envelope.setOutputSoapObject(soapObject);
HttpTransportSE ht = new HttpTransportSE(URL);
ht.debug = true; // 使用 call 方法调用 WebService 方法
try {
ht.call(null, envelope);
if (envelope.getResponse() != null) {
Object sb = envelope.getResponse();
etUserName.setText(sb.toString());
} else {
System.out.println("用户名或者密码不正确!");
}
} catch (IOException e) {
// TODO Auto-generated catch block
etUserName.setText("IOException");// 获取从服务器端返回的 XML 字符串
e.printStackTrace();
} catch (XmlPullParserException e) {
etUserName.setText("XmlPullParserException");// 获取从服务器端返回的 XML 字符串
// TODO Auto-generated catch block
e.printStackTrace();
} } @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}androidwebservice
解决方案 »
- Gallery的setSelection方法没有触发OnItemSelectedListener
- 帮我看一下 数据库修改语句吧,数据库很不好,怎么看都不知道为什么执行不了。。。谢谢了。。。
- 关于多线程与socket的几个问题
- 学习android
- 资源
- 手机游戏 会不会赚流量的钱呢?
- android绘制中国象棋棋盘--旗子周围透明效果
- expandableListView如何实现滑动时自动展开
- 能够实现图片的双指放大缩小,双击放大缩小,类似系统图库应用,有现成的控件可用么?
- android原生登录加h5交互
- 在安卓模拟器中连接数据库(MySQL)来实现用户登录 求大神看哪里出错了
- jni层调用socket(AF_INET, SOCK_DGRAM, 0)失败
仍旧报错。