标签:c authentication proxy wcf asmx
输入时发现抱歉的答案
我正在尝试连接到需要通过代理进行用户名/密码身份验证的外部Web服务.我正在使用Visual Studio Express 2008生成服务引用
>我已经连接到同一个
web服务使用web reference.We
只需要设置更大的超时
因为它需要很长时间
完.
>我已经连接到另一个
不需要的webservice
用户名/密码验证
使用生成的服务引用
和一些设置来完成它
代理人.
所以我的想法是
拿这个参考,指出它
正确的web服务并添加
认证.
我没有安全使用的配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.net>
<defaultProxy useDefaultCredentials="true">
<proxy bypassonlocal="False" proxyaddress="http://***.***.****:80" />
</defaultProxy>
</system.net>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="AreaWebServiceSoap12">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://www.****.*****.****.com/samplewebservice/service.asmx"
binding="customBinding" bindingConfiguration="AreaWebServiceSoap12"
contract="ServiceReference1.ServiceSoap" name="ServiceSoap" />
</client>
</system.serviceModel>
</configuration>
我已将以下代码添加到我的身份验证调用中:
static void Main(string[] args)
{
ServiceSoapClient s = new ServiceSoapClient();
s.ClientCredentials.UserName.UserName = @"username";
s.ClientCredentials.UserName.Password = @"password";
Service.RawGpsData[] result = s.GetRawGpsData(0);
Console.WriteLine(String.Format("done:{0}",result.Length));
Console.ReadLine();
}
只是使用此设置会出现预期的错误:
HTTP请求未经过客户端身份验证方案Anonymous的授权.收到服务器的身份验证标头,是NTLM.
现在我迷路了并开始尝试愚蠢的事情,因为我刚刚开始使用WCF.
当我将以下部分添加到配置中时
<security authenticationMode="UserNameOverTransport"></security>
我收到以下错误:
对于合同AreaWebServiceSoap.AreaWebServices,绑定CustomBinding.http:// tempuri.org /配置了一个验证模式,需要具有完整性和机密性的传输级别.运输不能提供完整性和机密性.
对不起,在输入这个问题时,我自己偶然发现了答案.我仍然认为人们可能对此感兴趣,所有的评论和想法仍然受到欢迎.所以我会在这里留下问题并将其作为社区并自己发布答案.
解决方法:
将绑定更改为:
<?xml version="1.0" encoding="utf-8" ?>
<customBinding>
<binding name="AreaWebServiceSoap12" closeTimeout="00:01:00" openTimeout="00:10:00"
receiveTimeout="00:20:00" sendTimeout="00:05:00">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Ntlm"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
</customBinding>
所以设置authenticationScheme =“Ntlm”
标签:c,authentication,proxy,wcf,asmx 来源: https://codeday.me/bug/20190622/1260893.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。