Android Call WebService Send header authentication unsuccessful

Source: Internet
Author: User
Tags addchild soap

============ Problem Description ============


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

<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 Duration:" + 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 = "Connection server connection exception";
Handler.sendmessage (msg);
}
}

return null;

============ Solution 1============


I've never been in touch, help you with the roof.

============ Solution 2============


Http://stackoverflow.com/questions/11179610/customization-of-ksoap2-android-envelope, the same problem as you.

Android Call WebService Send header authentication unsuccessful

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.