C# 从WCF客户端连接到服务器时出现问题-HTTPS端点-在本地开发人员上有效,但在服务器上无效
更新日志:C# 从WCF客户端连接到服务器时出现问题-HTTPS端点-在本地开发人员上有效,但在服务器上无效,c#,web-services,wcf,.net-4.0,windows-server-2008-r2,C#,Web Services,Wcf,.net 4.0,Windows Server 2008 R2,更新日志: 添加了更多细节-包括WCF跟踪 首先,没有太多的WCF经验,所以如果这是一个明显的错误,请道歉。我正在编写一个简单的控制台应用程序,它需要连接到第三方SOAPWeb服务。供应商提供的WSDL如下所示: 我已经使用它在VisualStudio2010中创建了一个服务参考(使用.NET 4.0)来创建自动生成的代码。我还为各种配置设置了app.config: <?xml version="1.0"?> <configuration> <configSe
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="CompanyCustomConfig"
type="Company.Common.CustomConfigSections.EncryptedSomethingQuiteStrangeCredentialsSection, Company.Common"
/>
<section name="CompanyMachineConfig"
type="Company.Common.CustomConfigSections.MachineEnvironmentKeySection, Company.Common"
/>
</configSections>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="sessionMethodsSoap"
receiveTimeout="00:10:00"
closeTimeout="00:10:00"
openTimeout="00:10:00"
sendTimeout="00:10:00"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="Transport" />
</binding>
<binding name="sessionMethodsSoap1" />
<binding name="recipientMethodsSoap">
<security mode="Transport">
<!--<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>-->
</security>
</binding>
<!--<binding name="recipientMethodsSoap1" />-->
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https:test.jsp"
binding="basicHttpBinding" bindingConfiguration="sessionMethodsSoap"
contract="Session.sessionMethodsSoap" name="sessionMethodsSoap" />
<endpoint address="https:test.jsp"
binding="basicHttpBinding" bindingConfiguration="recipientMethodsSoap"
contract="Recipient.recipientMethodsSoap" name="recipientMethodsSoap" />
</client>
</system.serviceModel>
<appSettings>
<add key="SomethingQuiteStrangeActionsClientBaseUrlWL0280" value="http://localhost.fiddler:13298/api/ua"/>
<add key="SomethingQuiteStrangeActionsContentTypeWL0280" value="application/json"/>
<add key="SomethingQuiteStrangeActionsClientBaseUrlTesting" value="http://localhost:13298/api/SomethingQuiteStrangeactions"/>
<add key="SomethingQuiteStrangeActionsContentTypeTesting" value="application/json"/>
<add key="SomethingQuiteStrangeDetailsClientBaseUrlLocalDevelopment" value="http://localhost.fiddler:13298/api/detailsofsomething/>
<add key="SomethingQuiteStrangeDetailsContentTypeLocalDevelopment" value="application/json"/>
<add key="SomethingQuiteStrangeDetailsClientBaseUrlTesting" value="http://localhost:13298/api/SomethingQuiteStrangedetails"/>
<add key="SomethingQuiteStrangeDetailsContentTypeTesting" value="application/json"/>
<add key="LogFileDirectoryTesting" value="C"/>
<add key="LogFileDirectoryLocalDevelopment" value="C:\LogFiles\CRM"/>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<CompanyCustomConfig>
<EncryptedSomethingQuiteStrangeCredentials>
<EncryptedSomethingQuiteStrangeCredential service="ThingLocalDevelopment" SomethingQuiteStrangeName="un" password="pw"/>
</EncryptedSomethingQuiteStrangeCredentials>
</CompanyCustomConfig>
<CompanyMachineConfig>
<MachineEnvironmentKeys>
<MachineEnvironmentKey name="DEV" environment="LocalDevelopment" />
<MachineEnvironmentKey name="SERVER" environment="Testing" />
</MachineEnvironmentKeys>
</CompanyMachineConfig>
</configuration>
为了清晰起见,下面是一幅图像:
现在,即使我们使用的是HTTPS,第三方也不需要证书-Logon()操作为我提供了一个sessionId供以后使用-因此我假设使用basicHttpBindingi fine
需要知道的事情:
执行一些SSL故障排除。一些选择:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
最后的问题是我需要在Windows2008服务器R2上安装.NET4.5.1。尽管我的目标是.NET4.0。这解决了问题,现在可以正常工作。实际错误似乎是超时<代码>.System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)位于System.ServiceModel.Channels.RequestChannel.Request(消息消息,TimeSpan timeout),位于。既然您说它在本地环境中工作,我相信这是服务器和WS主机之间的网络问题。检查防火墙设置和防火墙日志。他们可能会给你一些线索。@KosalaW我正在查看我们谈话时的防火墙日志-我想可能是这样的。我们拭目以待如果启用WCF跟踪,您可以得到更清晰的错误消息。请参阅下面的文章了解如何hey@StackTrace-我已经这样做了,我将更新这个问题:)看来防火墙没有阻止传出的数据包,所以我被难住了。将在我开始工作时更新,包括*svclog文件。添加了更多详细信息。我与我们的第三方供应商合作,他们确认他们根本没有收到来自服务器应用程序的任何请求,但他们确实从同一服务器盒收到了我们的SOAP UI请求-这必须指向服务器.net配置?
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;