执行我的CSharp应用程序时出错。
未处理的例外情况: System.Web.Services.Protocols.SoapHeaderException:提供了无效的安全令牌(处理用户名令牌时发生错误“{0}”) 在System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(System.Web.Services.Protocols.SoapClientMessage message,System.Net.WebResponse response,System.IO.Stream responseStream,Boolean asyncCall)< 0x403b5b40 + 0x00d7b> in:0
这是我的soapheader xml请求。
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1">
<wsse:UsernameToken>
<wsse:Username>username</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
这是我的C#源代码中的代码段。
private String passwordField;
public string Password
{
get { return this.passwordField; }
set { this.passwordField = value; }
}
public UsernameToken(string username, string password)
{
this.Username = username;
this.Password = password;
}
我怀疑这个问题的原因是我没有在密码属性中添加名称空间 PasswordText 。
我在Password属性上面添加了名称空间PasswordText,但是我收到了错误。
[XmlAttribute("Password", Namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText")]
public string Password
{
get { return this.passwordField; }
set { this.passwordField = value; }
}
如何在C#代码中的Password属性中添加命名空间PasswordText?
谢谢你们!