Witam,

Mam aplikację, która jest hostowana przez usługę Windows. Do tej pory używałem wsHttpBinding i wszystko było ok - po zainstalowaniu usługi mogłem się do nie podłączyć klientem. Ostatnio zmieniłem binding na basicHttpBinding. Zrobiłem update referencji do serwisu w kliencie - wszystko śmigało, z poziomu Visual Studio uruchamiałem serwis i mogłem się do niego podłączyć klientem.
Zbudowałem ponownie instalatora, uruchomiłem go - usługa się poprawnie zainstalowała i uruchomiła, jednak klientem z nowym bindingiem nie mogę się do niej podłączyć. Za to klient z wsHttpBinding bez problemu się łączy.

Wyjątek jaki otrzymuję prze próbie łączenia się klientem z ustawionym basicHttpBinding:

 
System.ServiceModel.ProtocolException was caught
  Message=Content Type text/xml; charset=utf-8 was not supported by service http://localhost:8732/.  The client and service bindings may be mismatched.
  Source=mscorlib
  StackTrace:
    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 PXR4_Klient.PXR4Service.IModbusService.TestPolaczenia()
       at PXR4_Klient.PXR4Service.ModbusServiceClient.TestPolaczenia() in C:\Documents and Settings\jpawlowski.WILBO\Moje dokumenty\Visual Studio 2010\Projects\PXR4 Klient\PXR4 Klient\Service References\PXR4Service\Reference.cs:line 1010
       at PXR4_Klient.FormStart.TestPolaczenia() in C:\Documents and Settings\jpawlowski.WILBO\Moje dokumenty\Visual Studio 2010\Projects\PXR4 Klient\PXR4 Klient\FormStart.cs:line 44
  InnerException: System.Net.WebException
       Message=The remote server returned an error: (415) Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'..
       Source=System
       StackTrace:
            at System.Net.HttpWebRequest.GetResponse()
            at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
       InnerException: 

Jak wyczytałem na różnych forach może mieć to związek z różnymi bindingami ustawionymi w serwisie i kliencie. Sprawdziłem app.config w obywdu przypadkach - jest ustawiony basicHttpBinding.

App.config serwisu:

 
<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true"/>
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <bindings />
    <services>
      <service name="PXR4_Master.PXR4Service">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
          contract="PXR4_Master.IModbusService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

App.config klienta:

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IModbusService" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:59:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http:\\localhost:8732" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IModbusService" contract="PXR4Service.IModbusService"
        name="BasicHttpBinding_IModbusService" />
    </client>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  </startup>
</configuration>

Czy ktoś ma pomysł dlaczego nie mogę się podłączyć nowym klientem?