简体   繁体   English

使用kso​​ap2在Android中使用摘要(SOAP)的WSSE安全标头

[英]WSSE Security Headers with Digest (SOAP) in Android using ksoap2

In Android programming, I am trying to generate the following soap Header (WSSE Security with Password Digest Header) using ksoap2. 在Android编程中,我尝试使用kso​​ap2生成以下soap Header(带密码摘要标头的WSSE安全性)。

  <soap:Header>
    <wsse:Security soap:mustUnderstand="1">  
      <wsse:UsernameToken>
         <wsse:Username>user</wsse:Username>
         <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">DbIekaN2kkkEHsC2dHVrWYj0Lj0=</wsse:Password>
         <wsse:Nonce>KCkqLywtiK8wMTIzND9N2e==</wsse:Nonce>
         <wsu:Created>2013-06-18T21:18:11Z</wsu:Created>
     </wsse:UsernameToken>
   </wsse:Security>
  </soap:Header>

My code for generating the above header is 我生成上述标题的代码是

    Element headers[] = new Element[1];
    headers[0]= new Element().createElement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security");
    headers[0].setAttribute(null, "soap:mustUnderstand", "1");

    Element to = new Element().createElement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "UsernameToken");


    Element action1 = new Element().createElement(null, "n0:Username");
    action1.addChild(Node.TEXT, "user");
    to.addChild(Node.ELEMENT,action1);

    Element action2 = new Element().createElement(null, "n0:Password");
    action2.setAttribute(null, "Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest");
    action2.addChild(Node.TEXT, "DbIekaN2kkkEHsC2dHVrWYj0Lj0=");
    to.addChild(Node.ELEMENT,action2);


    Element action3 = new Element().createElement(null, "n0:Nonce");
    action3.addChild(Node.TEXT, "KCkqLywtiK8wMTIzND9N2e==");
    to.addChild(Node.ELEMENT,action3);

    Element action4 = new Element().createElement(null, "wsu:Created");
    action4.addChild(Node.TEXT, "2013-06-18T13:18:11Z");
    to.addChild(Node.ELEMENT,action4);


    headers[0].addChild(Node.ELEMENT, to);

    soapEnvelope.headerOut = headers[0];
    // soapEnvelop is created using the following code
    // SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

However, the above code gives HTTP 400 (Bad Request) . 但是,上面的代码给出了HTTP 400 (Bad Request)

Can any one help me please? 有人能帮帮我吗?

Did you try having a look at the requestdump by making httpTransport.debug = true 您是否尝试通过使httpTransport.debug = true来查看requestdump

I think wsu is not related to the proper namespace. 我认为wsu与正确的命名空间无关。 Instead of writing this, Element action4 = new Element().createElement(null, "wsu:Created"); 而不是写这个,Element action4 = new Element()。createElement(null,“wsu:Created”);

please try Element action4 = new Element().createElement(" http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd ", "Created"); 请尝试元素action4 = new Element()。createElement(“ http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd ”,“Created”) ;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM