Click here to Skip to main content
15,887,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, my code throws error in this line
C#
cliente.RequestSoapContext.Security.Tokens.Add(clientToken);
this is the error:

(SoapContext.Security is obsolete. Consider deriving from SendSecurityFilter or ReceiveSecurityFilter and creating a custom policy assertion that generates these filters.)

My question is. ¿how to rewrite it?

this is my code:
C#
service.WEBSERVICEPINES client = new service.WEBSERVICEPINES();
SecurityToken clientToken = X509TokenProvider.CreateToken(StoreLocation.LocalMachine, StoreName.TrustedPeople, this.snCertificado, X509FindType.FindByThumbprint);

MessageSignature sig = new MessageSignature(clientToken);

client.RequestSoapContext.Security.Tokens.Add(clientTeoken);
client.RequestSoapContext.Security.Elements.Adde(sig);
client.RequestSoapContext.Security.Tokens.Add(new UsernameToken(usuario, password, 2));
Thank you so much for your advices.

What I have tried:

C#
Service serviceProxy = new Service();
UsernameToken token = new UsernameToken("admin", "nimda", PasswordOption.SendPlainText);
serviceProxy.SetClientCredential(token);
serviceProxy.SetPolicy("ClientPolicy");
Posted
Updated 11-Apr-17 3:45am
Comments
ZurdoDev 10-Apr-17 13:46pm    
The error message gives you a suggestion of what to use so google for examples. Simple.
judah9107 10-Apr-17 14:07pm    
there's no much examples or none is good.
ZurdoDev 10-Apr-17 14:08pm    
First google result for me, https://www.codeproject.com/kb/cpp/webservice_authentication.aspx

See if that helps.
judah9107 10-Apr-17 14:14pm    
I comented I tried this solution but it doesn't work.
ZurdoDev 10-Apr-17 14:14pm    
Why doesn't it work?

1 solution

This is the solution:

Solution :

in Refernce.cs file

changed instead of System.Web.Services.Protocols.SoapHttpClientProtocol to

Microsoft.Web.Services3.WebServicesClientProtocol

Now i am able to get proxyClass.RequestSoapContext

Here i found the solution:
Webservice RequestSoapContext does not exists.[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900