Tuesday, April 8, 2014

android call webservice send header authentication is unsuccessful


My code
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");

/ / Abcd 34
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", "when callService long:" + 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 other case processing
}
} 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 = "connect to server connection exception";
handler.sendMessage (msg);
}
}
 

return null;
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
163 ;


And there are labels v, instead of soap, a request has been unsuccessful, God help us to see what the problem is large, troubled to a few days
Reply:
Give yourself the top, really looking forward to the big O God, headache dead
Reply:
Online ah
Reply:
No contact, Bangniding it
Reply:
Some help may be about the top, continue to wait for the big God
Reply:
http://stackoverflow.com/questions/11179610/customization-of-ksoap2 -android-envelope this problem like you
Reply:
I did a little bit for use, but did not solve ah, and this should be ksoap own package v good. Server side when they write is based soap: Data obtained such tags, I want them to determine what, if it is based on past data transfer android v: take the data, it should be all right, I do not know feasible feasible, noon to discuss the matter with the service there
Reply:
There is no one to help look ah afternoon it ksoap2 contracted decompile the jar over, which is to add some class of v, I want to change the soap and then re-referenced, but unfortunately has been wrong, jar package can not be used. In this help, and if it is, then there is no way I'm going to stick it knot.

No comments:

Post a Comment