Click here to Skip to main content
14,177,003 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hi, my code throws error in this line
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:
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:

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?
judah9107 10-Apr-17 14:29pm
   
First in this line: serviceProxy.SetClientCredential(token);
serviceProxy doesn't have that attribute (SetClientCredential)

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.[^]
   

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web05 | 2.8.190526.1 | Last Updated 11 Apr 2017
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100