簡體   English   中英

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

[英]WSSE Security Headers with Digest (SOAP) in Android 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>

我生成上述標題的代碼是

    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);

但是,上面的代碼給出了HTTP 400 (Bad Request)

有人能幫幫我嗎?

您是否嘗試通過使httpTransport.debug = true來查看requestdump

我認為wsu與正確的命名空間無關。 而不是寫這個,Element action4 = new Element()。createElement(null,“wsu: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