2015-11-18 19 views
5

UPDATE LOG:Problema di connessione al server da WCF client - HTTPS endpoint - Funziona su Dev locale ma non Server

  1. aggiunta più in dettaglio - Incluso il WCF Trace.

In primo luogo, non un sacco di esperienza WCF, quindi scuse se questo è un errore evidente. Sto scrivendo una semplice applicazione console, che deve connettersi a un servizio web SOAP di terze parti. Il WSDL fornita dal fornitore è qui:

http://pastebin.com/LJurv0qA

Ho usato questo per creare un Service Reference all'interno di Visual Studio 2010 (Utilizzo di .NET 4.0) per creare il codice generato automaticamente dietro. Ho anche impostare l'app.config per le varie configurazioni:

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

Ora sul mio LocalDevelopment scatola (cioè il mio computer portatile) il client funziona bene, sono in grado di connettersi al servizio terzi si crea, usando il loro Azione di accesso(). Quando schiero il mio codice al nostro server di prova, lo stesso codice e configuratio, n genera la seguente eccezione:

file di log è iniziata: 18/11/2015 20:11:25 sulla macchina TESTSERVER ==== ================================================== ====================== 18/11/2015 20:11 >>>> *** Applicazione registrata: Data di registrazione: 18/11/2015 20 : 11: 25 Messaggio: Problema nel client (Client.Logon()) - comunicazione - Messaggio: si è verificato un errore durante l'esecuzione della richiesta HTTP su test.jsp. Questo potrebbe essere a causa del fatto che il certificato del server non è configurato correttamente con HTTP.SYS nel caso HTTPS. Ciò potrebbe anche essere causato da una mancata corrispondenza dell'associazione di sicurezza tra il client e il server. dello stack:

Server stack trace: a System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException (WebException WebException, HttpWebRequest richiesta, HttpAbortReason abortReason)
a System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest. WaitForReply (TimeSpan timeout) a System.ServiceModel.Channels.RequestChannel.Request (messaggio messaggio, TimeSpan timeout) a System.ServiceModel.Dispatcher.RequestChannelBinder.Request (messaggio messaggio, TimeSpan timeout) a System.ServiceModel.Channels.ServiceChannel.Call (azione String, booleana a senso unico, il funzionamento ProxyOperationRuntime, Object [] in, Object [] out, TimeSpan timeout) a System.ServiceModel.Channels.ServiceChannelProxy.InvokeService (IMethodCallMessage methodCall , ProxyOperationRuntime funzionamento) a System.ServiceModel.Channels.ServiceChannelProxy.Invoke (IMessage messaggio)

Eccezione rilanciati a [0]: a System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage (IMessage reqMsg, IMessage retMsg) a System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (MessageData & MSGDATA, tipo Int32) a Hachette.CRM.AdobeCRMService.Session.sessionMethodsSoap.Logon (LogonRequest richiesta) a Hachette.CRM.AdobeCRMService.AdobeClient.Logon() in C: \ My Documents \ Hachette .CRM \ Hachette.CRM.AdobeCRMService \ AdobeClient.cs: linea 84other: System.Collections.ListDictionaryInternal

su consiglio di un commentée sotto, ho acceso WCF analisi sul server in cui si verifica l'errore . L'eccezione viene gettata dopo un messaggio è stato inviato su un canale

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. 

Ecco un'immagine per chiarezza:

enter image description here

Ora, anche se stiamo usando HTTPS, il doesnt di terze parti richiede certificazioni - l'azione Logon() mi fornisce un ID di sessione da utilizzare in seguito, quindi presumo di utilizzare basicHttpBinding ok?

Cose da sapere:

  1. La mia casella di sviluppo locale è in esecuzione Windows 8.1
  2. Il server di prova Im distribuzione su è in esecuzione Windows Server2008 R2 Standard (SP1).
  3. Il mio client è una app di console C# 4.0.
  4. Provato UI SOAP sul server che non funziona, utilizzando lo stesso WSDL - la richiesta ha funzionato e ha lasciato la rete, quindi deve essere un problema WCF/.NET sulla scatola.
  5. Inoltre l'attivazione WCF deve essere attivata per le app che utilizzano WCF come la mia - con riferimenti di servizio aggiunti e codice generato automaticamente dietro? La nostra è fuori perché ha causato altri siti per Crash (che necessitano di modello di servizio 3.0.0.0):

enter image description here

+0

L'errore effettivo sembra essere un timeout. '.System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply (timeout TimeSpan) a System.ServiceModel.Channels.RequestChannel.Request (messaggio messaggio, timeout TimeSpan) a'.Dato che stai dicendo che funziona nel tuo ambiente locale, credo che questo sia un problema di rete tra il server e l'host WS. Controlla le impostazioni del firewall e i log del firewall. Potrebbero darti qualche indizio. –

+0

@KosalaW Sto osservando i registri del firewall mentre parliamo - ho pensato che potesse essere qualcosa del genere. Vedremo! : P – garfbradaz

+1

È possibile ottenere un messaggio di errore molto più chiaro se si abilita la traccia WCF. Vedere il seguente articolo per come http://www.codeproject.com/Articles/420538/Simple-Steps-to-Enable-Tracing-in-WCF – StackTrace

risposta

1

Il problema alla fine era la necessità di .NET 4.5.1 installato su Windows 2008 Server R2. Anche se stavo prendendo di mira .NET 4.0. Questo risolve il problema e ora funziona.

0

fare un po 'di risoluzione dei problemi SSL. Alcune opzioni:

  1. tentativo rapida: C'è un Stack Overflow question with the same error message "Received an unexpected EOF or 0 bytes from the transport stream" in cui la soluzione era quella di impostare in modo esplicito la versione SSL prima della chiamata:

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; 
    
  2. Enable the System.Net trace che potrebbero dare ulteriori indizi.

  3. Utilizzare Wireshark o simile a sniff the SSL handshake.

Problemi correlati