Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue connecting to Server from WCF Client - HTTPS endpoint - Works on Local Dev but not Server

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:

enter image description here

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):

enter image description here

like image 272
garfbradaz Avatar asked Nov 09 '22 01:11

garfbradaz


1 Answers

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.

like image 158
garfbradaz Avatar answered Nov 14 '22 21:11

garfbradaz