Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 找不到WebService RequestSoapContext属性_C#_Asp.net_Web Services_Wse - Fatal编程技术网

C# 找不到WebService RequestSoapContext属性

C# 找不到WebService RequestSoapContext属性,c#,asp.net,web-services,wse,C#,Asp.net,Web Services,Wse,我在visual studio 2013中有一个asp.net网站。我添加了一个Web服务。我需要将身份验证参数(用户名和密码)作为SOAP头发送。但它找不到属性RequestSoapContext 我使用Microsoft.Web.Services3添加了;在我的代码中 CCWS.Service proxy = new CCWS.Service(); UsernameToken userToken = new UsernameToken("", "", PasswordOption.SendP

我在visual studio 2013中有一个asp.net网站。我添加了一个Web服务。我需要将身份验证参数(用户名和密码)作为SOAP头发送。但它找不到属性RequestSoapContext

我使用Microsoft.Web.Services3添加了;在我的代码中

CCWS.Service proxy = new CCWS.Service();
UsernameToken userToken = new UsernameToken("", "", PasswordOption.SendPlainText);
proxy.RequestSoapContext.Security.Tokens.Add(token);
一些论坛建议更改reference.cs文件中的引用类型。但在我的解决方案中找不到任何这样的文件。
有人能帮忙吗?

使用WseWsdl3.exe生成代码 找到作为wse 3.0的一部分下载的WseWsdl3.exe,并执行以下命令: C:\samples\wse>WseWsdl3.exe C:\samples\wse\us.wsdl/out:C:\samples\wse\myProxyClass.cs/协议:SOAP/类型:webClient


我想这可能会对你有所帮助。

这个问题很老了,但在四处搜索之后,解决方案似乎是手动修改生成的代理代码,以从Microsoft.Web.Services3.WebServicesClientProtocol继承,而不是
System.Web.Services.Protocols.SoapHttpClientProtocol

以下是描述此问题的Microsoft。尤其重要的是:“……代理类默认从SoapHttpClientProtocol派生。若要使用WSE的功能,请将代理类派生的类更改为WebServicesClientProtocol。”Microsoft.Web.Services2.WebServicesClientProtocol在无法添加v3的情况下也适用于我)