Click here to Skip to main content
15,900,694 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to add username token in SOAP Request in C#. Currently the SOAP call request is working in 3.5 framework . But on upgrading to 4.6.2 I am not getting the property RequestSoapContext.
Below is the current code used.

What I have tried:

  UsernameToken userToken;
                    userToken = new UsernameToken(PLCC_API_UserName, PLCC_API_Password, PasswordOption.SendPlainText);
SoapContext requestContext = objDirectDebitService.RequestSoapContext;
                    // Sets the TTL to one minute.
                    requestContext.Security.Timestamp.TtlInSeconds = 60;
                    // Adds the token to the SOAP header.

1 solution

You need to manually modify the generated proxy class to inherit from WebServicesClientProtocol rather than SoapHttpClientProtocol.
When you build an XML Web service client, whether you use Visual Studio or not, a proxy class is generated to communicate with the XML Web service. When you are using Visual Studio, that proxy class is generated when a Web reference is made or updated. If the .NET Framework SDK is used without Visual Studio, the proxy class is generated using the Web Services Description Language tool (Wsdl.exe). Either way, the proxy class derives from SoapHttpClientProtocol by default. To use the functionality of the WSE, change the class that the proxy class derives from to WebServicesClientProtocol.
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