0

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

3 Answers 3

0

Try this in your Web application's (not client's) config:

<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" 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 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>
    <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>
<client>
  <endpoint address="http://123.123.123.123:501/shipmentservice.svc" binding="basicHttpBinding" bindingConfiguration="" contract="Shipping.IShipmentWcfService" name="WSHttpBinding_IShipmentWcfService">
  </endpoint>
</client>
3
  • Do you have any other ideas to try? Nov 7, 2012 at 20:28
  • Check this stackoverflow q/a. May be it applies to you too. It sure makes sense tho. stackoverflow.com/questions/5263150/…
    – Dimitri
    Nov 7, 2012 at 21:10
  • Thanks - Fiddler shows the same error. Modified service so that it is returning a new object - same error. Code works locally so I do not suspect the code. Nov 8, 2012 at 14:18
0

It looks like you're trying to configure two different services using the same service contract. If you actually want to do that, just define different address values for different endpoints within that same service but that probably isn't very useful.

If the Mobile service exposes a different contract then you do need two different service configurations, one for each contract. In this case, clone the company.eShopWorld.Wcf.eShopWorldWCFService service element and change the contract attribute to have the correct .NET namespace and interface type for the Mobile service. You'll also need separate *.svc files for each service. I believe the default addresses for the two service would be something like this:

http://HostName/service.svc

http://HostName/mobileservice.svc
1
  • Thanks - the multipleSiteBindingsEnabled="true" requires that the enpoint addresses be relative. I do have 2 seperate svc files, one for each service Nov 6, 2012 at 22:39
-1

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

2
  • 1
    What rule? Having the same issue.
    – James King
    Mar 20, 2017 at 16:59
  • @JamesKing Agreed, this has no value. Jul 12, 2017 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.