7

I have a asp.net website in visual studio 2013. I added a webservice. I need to send authentication parameter (username and password) as SOAP header. But it cannot find the property RequestSoapContext.

I added using Microsoft.Web.Services3; in my code.

CCWS.Service proxy = new CCWS.Service();
UsernameToken userToken = new UsernameToken("", "", PasswordOption.SendPlainText);
proxy.RequestSoapContext.Security.Tokens.Add(token);

Some forum says to change reference type in reference.cs file. But I cannot find any such file in my solution. Can anyone please help?

masum7
  • 822
  • 6
  • 17

2 Answers2

9

This question is rather old but after searching around, it appears the solution is to hand modify the generated proxy code to inherit from Microsoft.Web.Services3.WebServicesClientProtocol not System.Web.Services.Protocols.SoapHttpClientProtocol.

speckledcarp
  • 6,196
  • 4
  • 22
  • 22
  • 3
    Here is the Microsoft [source](https://msdn.microsoft.com/query/dev15.query?appId=Dev15IDEF1&l=EN-US&k=k(Microsoft.Web.Services3.WebServicesClientProtocol);k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.5);k(DevLang-csharp)&rd=true) that describes this. Especially this is important: ***"...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."*** – inwenis Jun 04 '18 at 21:04
  • 2
    Microsoft.Web.Services2.WebServicesClientProtocol also worked for me Iin case you can't add v3) – Roisgoen Jan 18 '19 at 23:15
1

Generate Code Using WseWsdl3.exe Locate the WseWsdl3.exe downloaded as part of wse 3.0 and execute the following command: C:\samples\wse>WseWsdl3.exe C:\samples\wse\us.wsdl /out:c:\samples\wse\myProxyClass.cs /protocol:SOAP /type:webClient

I guess this may help you.

Feng
  • 83
  • 6