0
雖然發送SOAP請求,我需要這樣的創建頭部分:Android的SOAP信封與安全頭
我在這裏看到了一個類似的問題: create soap envelope with security header in android using ksoap2
我刪除了部分這我不需要在代碼部分。
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
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","Security");
Element usernametoken = new Element().createElement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "UsernameToken");
header[0].addChild(Node.ELEMENT,usernametoken);
Element username = new Element().createElement(null, "n0:Username");
username.addChild(Node.TEXT,"User");
usernametoken.addChild(Node.ELEMENT,username);
Element pass = new Element().createElement(null,"n0: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, "pass");
usernametoken.addChild(Node.ELEMENT, pass);
// add header to envelope
envelope.headerOut = header;
我需要添加什麼東西嗎?謝謝!!
我解決了它,我只需要刪除一些未使用的元素屬性。所以是的,它沒有任何錯誤。感謝您的關注。 – Rnklnc 2013-04-26 07:22:37