SOAP web service on android

自作多情 提交于 2019-11-29 16:16:46

I have encountered same issue and for that i have created Header in following way,


public static Element[] addheader()
    {
           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");
           header[0].setAttribute(null, "mustUnderstand","1");
           Element usernametoken = new Element().createElement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "UsernameToken");
          // usernametoken.addChild(Node.TEXT,"");
           usernametoken.setAttribute("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", "Id", "UsernameToken-4");
           header[0].addChild(Node.ELEMENT,usernametoken);
           Element username = new Element().createElement(null, "n0:Username");
           username.addChild(Node.TEXT, "username_value");
           //username.setPrefix("n0", null);
           usernametoken.addChild(Node.ELEMENT, username);
           Element pass = new Element().createElement(null, "n0:Password");
           //pass.setPrefix("n0",null);
           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_value");

           usernametoken.addChild(Node.ELEMENT, pass);
           return header;
    }

and add this header as soapEnvelope.headerOut = addheader();

As it is working for me, if should work for you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!