我正在尝试使用远程svc Web服务.我创建了代理类svcutil.exe
,之后我将该类添加到我的控制台应用程序中,但它产生了一个错误:
从另一方收到了不安全的错误或错误的安全故障.有关故障代码和详细信息,请参阅内部故障异常.
System.ServiceModel.FaultException:验证消息的安全性时发生错误
我没有创建WCF端,它是一个远程svc.请帮忙.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="EloquaDataTransferService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://secure.eloqua.com/API/1.2/DataTransferService.svc"
binding="basicHttpBinding" bindingConfiguration="EloquaDataTransferService"
contract="DataTransferService" name="EloquaDataTransferService" />
</client>
</system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)
这是我的app.config
档案.我consoleApp.cs
使用obj.ServiceCredentials.UserName.UserName="xxxxxx"
和提供我的文件中的用户名和密码.Password="xxxXx"
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="EloquaDataTransferService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://secure.eloqua.com/API/1.2/DataTransferService.svc" binding="basicHttpBinding" bindingConfiguration="EloquaDataTransferService" contract="DataTransferService" name="EloquaDataTransferService" />
</client>
</system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)
Ran*_*pho 133
这是WCF服务抛出的一个非常模糊的错误.问题是WCF无法验证传递给服务的消息的安全性.
这几乎总是因为服务器时间偏差.远程服务器和客户端的系统时间必须在(通常)彼此相差10分钟之内.如果不是,安全验证将失败.
我打电话给eloqua.com,找出他们的服务器时间,并将其与服务器时间进行比较.
Xca*_*bur 22
尽管您的问题已通过上述解决方案之一解决,但为了其他人的利益,这是另一种选择.
当不正确的凭据传递到使用用户名消息凭据的基本端点(SOAP 1.1)时,您也可以获得此异常.例如,如果您从代码调用服务并执行以下操作:
var service = new TestService();
service.ClientCredentials.UserName.UserName = "InvalidUser";
service.ClientCredentials.UserName.Password = "InvalidPass";
Run Code Online (Sandbox Code Playgroud)
这与WSHTTP端点(SOAP 1.2)不同,后者AccessDeniedException
在传递无效凭据时抛出.我个人觉得这里包含的信息有点误导(因为这个原因我第一次遇到它时肯定花了几分钟)但是一旦我查阅了WCF诊断跟踪日志,其根本原因就很明显了.
Dan*_*ner 13
您显然遇到了WCF安全子系统的问题.你使用什么装订?什么认证?加密?登录?你必须越过域名界限吗?
如果客户端和服务器的时钟不同步(超过大约五分钟),因为某些安全模式依赖于同步时钟,所以进一步显示其他人正在经历此错误.
同样的问题,我面临的客户端应用程序是WinForms应用程序C#4.0
当我在这里阅读解决方案时,我检查了客户端计算机的日期和时间,但这是正确的,当前时间显示,但我仍然面临着这些问题.
经过一些解决方法我发现选择了错误的时区,我在印度和时区是加拿大,主机服务器位于科威特.
我发现系统将时间转换为通用时间.
当我把时区改为印度的时区时,问题就出现了.