android调用webservice发送header身份验证不成功


====================问题描述====================
我的代码
SoapObject request = new SoapObject(
"http://webservices.home.whot.com", "getVoteImgPath");
String namespace = "http://webservices.home.whot.com";
Element[] header = new Element[1];
header[0] = new Element().createElement(namespace,
"authenticationtoken");

//Element userName = new Element().createElement(namespace, "username");
//userName.addChild(Node.TEXT, "q1101876746");
//header[0].addChild(Node.ELEMENT, userName);
//
//Element pass = new Element().createElement(namespace, "password");
//pass.addChild(Node.TEXT, "252931024");
//header[0].addChild(Node.ELEMENT, pass);

header[0].setAttribute(namespace, "username", "q1101876746");
header[0].setAttribute(namespace, "password", "252931024");

//<soap:Header><authenticationtoken><username>abcd</username><password>34</password></authenticationtoken></soap:Header>
request.addProperty("id", 163);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.headerOut = header;
envelope.bodyOut = request;
envelope.dotNet = true;
//envelope.setOutputSoapObject(request);

HttpTransportSE ht = new HttpTransportSE(
"http://test.rank365.cn/open/services/StartVotes");
ht.debug = true;
try {
long start = System.currentTimeMillis();
ht.call(null, envelope);
long timeNum = System.currentTimeMillis() - start;

Log.i("SoapService", "callService时长:" + timeNum);
// Object bodyIn = envelope.bodyIn;
Object response = envelope.getResponse();
//Object response = envelope.bodyIn;
if (response != null) {
// String str = JsonUtils.object2Json(response);
// System.out.println(str);
System.out.println(response.toString()+"-------------");
System.out.println(ht.requestDump);
System.out.println("-----------------------------");
System.out.println(ht.responseDump);
return response;
} else {
// TODO 其他情况处理
}
} catch (Exception e) {
e.printStackTrace();
System.out.println(ht.requestDump);
if (handler != null) {
Message msg = handler.obtainMessage();
// msg.what = Constants.HANDLER_WHAT_EXCEPTION;
msg.obj = "连接服务器连接异常";
handler.sendMessage(msg);
}
}

return null;
====================解决方案1====================
没接触过,帮你顶吧
====================解决方案2====================
http://stackoverflow.com/questions/11179610/customization-of-ksoap2-android-envelope这个问题和你一样的

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。