从WCF客户端连接到服务器的问题-HTTPS端点-在本地Dev上有效,但在服务器上不起作用 [英] Issue connecting to Server from WCF Client - HTTPS endpoint - Works on Local Dev but not Server

查看:74
本文介绍了从WCF客户端连接到服务器的问题-HTTPS端点-在本地Dev上有效,但在服务器上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新日志:


  1. 添加了更多详细信息-包括WCF跟踪。

首先,没有太多的WCF经验,如果这是一个明显的错误,请您道歉。我正在编写一个简单的控制台应用程序,该应用程序需要连接到第三方SOAP Web服务。供应商提供的WSDL在这里:





现在,即使我们使用的是HTTPS,第三方也不需要证书-Logon()操作为我提供了一个sessionId以便以后使用-所以我想使用 basicHttpBinding 可以吗?



要知道的事情:


  1. 我的本地开发箱正在运行Windows 8.1

  2. 部署到的测试服务器正在运行Windows Server2008 R2 Standard(已安装SP1)。 / li>
  3. 我的客户端是一个.NET 4.0 C#控制台应用程序。

  4. 使用相同的WSDL在服务器上尝试SOAP UI失败-该请求有效
  5. 此外,是否还需要为使​​用像我的WCF的应用程序设置WCF激活-后面添加了服务参考和自动生成的代码?我们的关闭是因为它导致其他站点崩溃(需要Service Model 3.0.0.0):

解决方案

最后的问题是我需要在Windows 2008 Server R2上安装.NET 4.5.1。即使我的目标是.NET 4.0。这样可以解决问题,现在可以解决问题。


UPDATE LOG:

  1. Added more detail - Included the WCF Trace.

Firstly, not a lot of WCF experience, so apologies if this is an obvious error. I'm writing a simple console application, that needs to connect to a third-party SOAP web service. The WSDL supplied by the supplier is here:

http://pastebin.com/LJurv0qA

I have used this to create a Service Reference within Visual Studio 2010 (Using .NET 4.0) to create the auto-generated code behind. I have also setup the app.config for the various configurations:

<?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>

Now on my LocalDevelopment box (i.e. my laptop) the client works fine, I'm able to connect to the thirdparties service, using their Logon() action. When i deploy my code to our Testing server, the same code and configuratio,n throws the following exception:

Log File Started: 18/11/2015 20:11:25 on machine TESTSERVER ============================================================================ 18/11/2015 20:11 >>>> *** Application Logged: Date Logged: 18/11/2015 20:11:25 Message: Issue in Client (Client.Logon()) - communication problem - Message: An error occurred while making the HTTP request to test.jsp. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server. Stack Trace:

Server stack trace: at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Hachette.CRM.AdobeCRMService.Session.sessionMethodsSoap.Logon(LogonRequest request) at Hachette.CRM.AdobeCRMService.AdobeClient.Logon() in C:\My Documents\Hachette.CRM\Hachette.CRM.AdobeCRMService\AdobeClient.cs:line 84other: System.Collections.ListDictionaryInternal

On the advice of a commentee below, I have turned on WCF Tracing on the Server where the error is occurring. The exception is being thrown after a message has been sent over a channel

Exception Type:
System.Net.WebException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Message:
The underlying connection was closed: An unexpected error occurred on a send.

Exception Type:
System.IO.IOException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Message:
Received an unexpected EOF or 0 bytes from the transport stream.

Here is an image for clarity:

Now even though we are using HTTPS, the thirdparty doesnt require certifcates - the Logon() action provides me with a sessionId to use later on - so i presume using basicHttpBinding i fine?

Things to know:

  1. My local development box is running Windows 8.1
  2. The test server Im deploying to is running Windows Server2008 R2 Standard (SP1 installed).
  3. My Client is a .NET 4.0 C# Console App.
  4. Tried SOAP UI on the Server that is failing, using the same WSDL - the request worked and left out network, so it must be a WCF/.NET Issue on the box.
  5. In addition does the WCF Activation need to set on for apps that use WCF like mine - with added Service References and auto-generated code behind? Ours is off because it caused other sites to crash (needing Service Model 3.0.0.0):

解决方案

The issue in the end was i needed .NET 4.5.1 installed on the Windows 2008 Server R2. Even though I was targeting the .NET 4.0. This fixed the issue complete and now works.

这篇关于从WCF客户端连接到服务器的问题-HTTPS端点-在本地Dev上有效,但在服务器上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆