How to add security header to apache axis web service request? -
i want add following security header through java code web service request header.
"<wsse:security soapenv:mustunderstand="1"> <wsse:usernametoken> <tenant>default</tenant> <wsse:username>admin</wsse:username> <wsse:password type="http://www.visual-rules.com/wss#passwordtext">password</wsse:password> </wsse:usernametoken> </wsse:security> </soapenv:header>"
i using apache axis.
want know , how add programatically.
pls help.
you can add custom soap header in axis 2 v1.6.2 in following way:
omfactory fac = omabstractfactory.getomfactory(); soapfactory factory = omabstractfactory.getsoap12factory(); omnamespace nswsse = fac .createomnamespace( "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "wsse"); soapheaderblock header = factory.createsoapheaderblock("security", nswsse); header.setmustunderstand(true); omelement usernametoken = fac.createomelement("usernametoken", nswsse); omelement tenant = fac.createomelement("tenant", null); tenant.settext("default"); usernametoken.addchild(tenant); omelement username = fac.createomelement("username", nswsse); username.settext("admin"); usernametoken.addchild(username); omelement password = fac.createomelement("password", nswsse); password.addattribute("type", "http://www.visual-rules.com/wss#passwordtext", null); password.settext("admin"); usernametoken.addchild(password); header.addchild(usernametoken); system.out.println(header); serviceclient sender = new serviceclient(); sender.addheader(header);
Comments
Post a Comment