SOAP web service on android

后端 未结 1 585
-上瘾入骨i
-上瘾入骨i 2020-12-21 13:15

I am am trying to connect to a SOAP web service using ksoap2 library. I have read a bunch of docs about it, but i am stuck as my request is not an ordinary one.

I ne

相关标签:
1条回答
  • 2020-12-21 13:57

    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.

    0 讨论(0)
提交回复
热议问题