2
設置密碼類型「PasswordText」的WSSE安全首我想有至極的WSSE安全標頭中的密碼類型設置爲「PasswordText」如以下SOAP snipet:如何使用WCF
<wsse:UsernameToken wsu:Id="UsernameToken-2">
<wsse:UsernaWme>usrnm</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">pwd</wsse:Password>
</wsse:UsernameToken>
但我得到的只是一個沒有Type屬性的簡單密碼標籤。
<wsse:UsernameToken u:Id="UsernameToken-2">
<wsse:Username>usrnm</wsse:Username>
<wsse:Password>pwd</wsse:Password>
</wsse:UsernameToken>
什麼是在代碼或app.cfg中指定它的正確方法? 海爾是到目前爲止我的代碼:
service.ClientCredentials.UserName.UserName = "usrnm";
service.ClientCredentials.UserName.Password = "pwd";
var securityElement = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
securityElement.AllowInsecureTransport = true;
var encodingElement = new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8);
var transportElement = new HttpTransportBindingElement();
var binding = new CustomBinding(securityElement, encodingElement, transportElement);
service.Endpoint.Binding = binding;
檢查了這一點http://stackoverflow.com/questions/16028014/how-can-i-pass-一個-用戶名 - 密碼 - 內式頭到一皁的WCF服務 – Vasanthan