把 HttpTransportSE ht = new HttpTransportSE(URL); 换成AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
androidHttpTransport.call(NAMESPACE + METHOD_NAME,envelope);
SoapObject result = (SoapObject) envelope.getResponse();
androidHttpTransport.call(NAMESPACE + METHOD_NAME,envelope);
SoapObject result = (SoapObject) envelope.getResponse();
解决方案 »
- android 如何在彩信中的“幻灯片”中插入文本?
- Activity中放置图片的问题
- 请有过android平板开发的进来谈一下经验吧
- android google map开发中,怎么改变自动放大缩小控件的默认位置
- 关于android 出现“Unfortunately,程序名 has stopped” 的问题
- Android的ListView控件如何实现新加入的item从上往下排列
- 安卓生成jar后 调用出错
- android 中 overlay 的被废弃了吗?
- Android pull解析这种格式不一致的xml怎么做
- 右下角总是弹一个错误 求根治Sorry but paren。。。。。。。
- android2.2
- 有关内核更新问题
//创建SoapObject对象,指定WebService的命名空间和调用的方法名
SoapObject request = new SoapObject(Utils.WS_NAME_SPACE, Utils.WSF_SET_PHONE_NUMBER);
// 设置WebService方法的参数
request.addProperty("phone", editPhone.getText().toString());
// 创建SoapSerializationEnvelope对象,并指定WebService的版本
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
// 设置bodyOut属性
envelope.bodyOut = request;
try {
// 创建HttpTransportSE对象,并指定WSDL文档的URL
HttpTransportSE ht = new HttpTransportSE(Utils.WS_URL, Utils.WS_TIMEOUT);
// 调用WebService
ht.call(null, envelope);
Object obj = envelope.getResponse();
if (obj != null) {
//使用getResponse方法获得WebService方法的返回结果
SoapPrimitive soapPrimitive = (SoapPrimitive) envelope.getResponse();
wsResult = soapPrimitive.toString(); }
} catch (Exception e) {
isWsOver = true;
return null;
}
txt = (TextView)findViewById(R.id.txt);
String URL = "http://mysmser.zy.hhnw.com/service1.asmx?WSDL";
String NAMESPACE = "http://tempuri.org/"; // targetNamespace wsdl
String METHOD_NAME = "HelloWorld";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = request;
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
try
{
androidHttpTransport.call(NAMESPACE + METHOD_NAME,envelope);
}
catch(Exception e)
{
txt.setText("Call出错啦");
}
try
{
SoapObject result = (SoapObject) envelope.getResponse();
try
{
if (result == null)
txt.setText("返回的是空结果");
else
txt.setText(result.getProperty("string").toString());
}
catch (Exception e)
{
txt.setText("操作Result出错");
}
}
catch (Exception e)
{
txt.setText("Resault 出错啦");
}webservcie的返回结果是:<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://tempuri.org/">something....</string>