如何将Security header元素添加到Soap Envelope?我已经尝试过以下使用Ksoap2-android-assembly-2.4 lib ...
//Header element....
Element[] header = new Element[1];
header[0] = new Element().createElement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd","wsse:Security");
header[0].setAttribute(null, "soap:mustUnderstand","1");
Element usernametoken = new Element().createElement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "wsse:UsernameToken");
//usernametoken.setAttribute(null, "Id", "UsernameToken-1");
header[0].addChild(Node.ELEMENT,usernametoken);
Element username = new Element().createElement(null, "wsse:Username");
username.addChild(Node.IGNORABLE_WHITESPACE,user_id);
usernametoken.addChild(Node.ELEMENT,username);
Element pass = new Element().createElement(null,"wsse:Password");
pass.setAttribute(null, "Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
pass.addChild(Node.TEXT, password);
usernametoken.addChild(Node.ELEMENT, pass);
// add header to envelope
envelope.headerOut = header;
通过记录我发现信封中没有标题信息,最后面临流异常。,
任何人都可以帮我解决这个问题。
提前致谢。 GM。