我試圖從使用WSE 3.0的MVC3 .NET Web應用程序調用Java Web Service。如何將EncodingType屬性添加到WSE 3.0(.NET)中UsernameToken的Nonce元素
但是,Web服務需要UsernameToken的Nonce元素上的「EncodingType」屬性。下面是一個示例SOAP信封,與該Java Web服務正常工作:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:v1="http://schema.mydomain.org/sms/v1_0">
<soap:Header>
<wsse:Security soap:mustUnderstand="true" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>myUsername</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">myPassword</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">XQkp6oYc3DRv41cxkSTW8w==</wsse:Nonce>
<wsu:Created>2011-09-13T20:50:08.355Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body>
<v1:ping/>
</soap:Body>
</soap:Envelope>
以下是從代理產生的SOAP信封VS2010生產(以小提琴手捕獲):
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<env:Header xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<wsse:Security env:mustUnderstand="true">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-111f922b-72c1-4057-bce4-f6555552ce6a">
<wsse:Username>myUsername</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">myPassword</wsse:Password>
<wsse:Nonce>qYse3Lor9sAJ9pKPefgkKQ==</wsse:Nonce>
<wsu:Created>2011-09-13T20:50:38Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</env:Header>
<soap:Body>
<v1:ping/>
</soap:Body>
</soap:Envelope>
如果這個屬性丟失,此Web服務返回「提供了無效的安全令牌(處理用戶名令牌時發生錯誤)」
如何添加EncodingType屬性?
嗨,我有這個確切的問題。很高興知道有一面旗子,如果你還提到了哪面旗子,現在我還是得看看,那會更好。 – toongeorges