UPDATE LOG:
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With