Search code examples
wcfwcf-bindingwcf-client

WCF works in VS but not in IIS


Have a web application. It runs 2 wcf services, and is a client for another. One wcf service works fine, the other does not work on the dev server but does work locally. The error is "The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding"

The the wcf part of the web application config is

 <system.serviceModel>
<diagnostics>
  <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
  <service name="company.eShopWorld.Wcf.eShopWorldWCFService" behaviorConfiguration="company.Web.Wcf.ServiceBehavior">
   <endpoint address="" binding="basicHttpBinding" contract="Nad.CheckoutVendor.Interfaces.ICheckoutVendorService" /> 
   <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
  </service>
    <service name="company.Mobile.Wcf.MobileService" behaviorConfiguration="company.Mobile.Wcf.ServiceBehavior" />
        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
    </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="company.Web.Wcf.ServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>

      <behavior name="company.Mobile.Wcf.ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
  </serviceBehaviors>
</behaviors>
<bindings />
<client>
  <endpoint address="http://123.123.123.123:501/shipmentservice.svc" binding="basicHttpBinding" bindingConfiguration="" contract="Shipping.IShipmentWcfService" name="WSHttpBinding_IShipmentWcfService">
  </endpoint>
</client>

The test client wcf part of the config is

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_ICheckoutVendorService" closeTimeout="00:02:00"
                openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02: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>
            <binding name="BasicHttpBinding_ICheckoutVendorService1" closeTimeout="00:02:00"
                openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02: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://test.com:50128/eShopWorldService.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICheckoutVendorService1"
            contract="eShopWorldSvc.ICheckoutVendorService" name="BasicHttpBinding_ICheckoutVendorService" />
    </client>

The mobile service works, so I assume iis is set up correctly. If I put the svc url in a browser it shows me service page and if I add the wsdl to the url is shows the wsdl.

Have been beating my head against this for 2 days now and cannot find a problem.

Any help is sorley appreciated

So trying Dimitri's suggestion my web.config now looks like this

 <services>
        <service name="company.eShopWorld.Wcf.eShopWorldWCFService" behaviorConfiguration="company.Web.Wcf.EshopServiceBehavior">
            <endpoint address="/eShopWorldService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICheckoutVendorService" contract="Nad.CheckoutVendor.Interfaces.ICheckoutVendorService"/>
            <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
        </service>
        <service name="company.Mobile.Wcf.MobileService" behaviorConfiguration="company.Mobile.Wcf.ServiceBehavior" >
            <endpoint address="/MobileService.svc" binding="basicHttpBinding" contract="company.Mobile.Wcf.IMobileService" />
            <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="company.Web.Wcf.EshopServiceBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>

            <behavior name="company.Mobile.Wcf.ServiceBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_ICheckoutVendorService" closeTimeout="00:02:00"
                openTimeout="00:02:00" receiveTimeout="00:10:00" sendTimeout="00:02: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>

But I still have the error. Note that I had to include the name of the service to prevent a 404 error

I am somewhat confused by the fact that each of the services have their own web.config as well as the web app's web.config. I assume they somehow get rolled up into the project when compiled as if there are errors in them they get thrown. Any other ideas? thnx


Solution

  • So the problem turned out to be a rule that was converting the service name to all lower case. It did not cause problems in VS debug, but did in IIS