Content Error with WCF Service

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Arulmanoj
    New Member
    • Mar 2009
    • 34

    Content Error with WCF Service

    Hi,

    I have writtent a WCF service and accessing it in a asp.net page. Some times am the below error.

    "The content type text/html of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSu pported method is implemented properly. The first 1024 bytes of the response were:"

    What needs to be done to solve this problem.

    Help needed.

    Thanks

    Manoj
  • Sfreak
    New Member
    • Mar 2010
    • 64

    #2
    Take a look in your app.config declarations and check if mets with your class declaration. Also make sure to do not make circular references (even declaring IsReference=tru e) when using a ORM.

    This is an example of a binding

    Code:
     <binding name="Tipos" closeTimeout="00:01:00" openTimeout="00:01:00"
                        receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"
                        transferMode="Buffered" transactionProtocol="OleTransactions"
                        hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                        maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                        maxReceivedMessageSize="65536">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <reliableSession ordered="true" inactivityTimeout="00:10:00"
                            enabled="false" />
                        <security mode="None">
                            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                            <message clientCredentialType="Windows" />
                        </security>
                    </binding>
    Hope this can help you

    Fernando Mello

    Comment

    • Arulmanoj
      New Member
      • Mar 2009
      • 34

      #3
      Hi Fernando,

      Below i have given the web.config file info from my WCF service.


      Code:
      <system.serviceModel>
      <bindings>
      <basicHttpBinding>
      <binding name="LargeMessageBinding" closeTimeout="10:10:00" openTimeout="10:10:00"
       receiveTimeout="10:10:00" sendTimeout="10:10:00" allowCookies="false"
       bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
       maxBufferSize="500000000" maxBufferPoolSize="524288" maxReceivedMessageSize="500000000"
       messageEncoding="Text"
       textEncoding="utf-8" transferMode="Streamed" useDefaultWebProxy="true">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="None">
      <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
      <message clientCredentialType="UserName" algorithmSuite="Default"/>
      </security>
      </binding>
      </basicHttpBinding>
      </bindings>
      <services>
      <service behaviorConfiguration="IVService.IVServiceBehavior" name="Tusa.Services.IVService.IVService">
      <endpoint name="basicHttpBinding" address="" binding="basicHttpBinding" bindingConfiguration="LargeMessageBinding" contract="Tusa.Services.IVService.IIVService">
      	<identity>
      		<dns value="localhost"/>
      	</identity>
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
      </services>
      <behaviors>
      <serviceBehaviors>
      <behavior name="IVService.IVServiceBehavior">
      	<!-- 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="true"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
      </behavior>
      </serviceBehaviors>
      </behaviors>
      </system.serviceModel>
      In asp.net application am calling this WCF service using with the web.config as below.

      Code:
      <system.serviceModel>
      <bindings>
      	<basicHttpBinding>
      		<binding name="basicHttpBinding" closeTimeout="00:50:00" openTimeout="00:50:00" receiveTimeout="00:50:00" sendTimeout="00:50:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" maxBufferSize="500000000" maxBufferPoolSize="524288" maxReceivedMessageSize="500000000">
      			<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
      			<security mode="None">
      				<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
      				<message clientCredentialType="UserName" algorithmSuite="Default"/>
      			</security>
      		</binding>
      	</basicHttpBinding>
      </bindings>
      <client>
      	<endpoint address="http://chn355/Base/Base.svc" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="IBase" name="basicHttpBinding" behaviorConfiguration="maxItemsInObjectGraphBehaviour"/>
      </client>
      <behaviors>
      	<endpointBehaviors>
      		<behavior name="maxItemsInObjectGraphBehaviour">
      			<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
      		</behavior>
      	</endpointBehaviors>
      </behaviors>
      </system.serviceModel>
      Please check and let me know whether am making mistake with config files.

      Thanks

      Manoj.
      Last edited by Frinavale; Aug 10 '10, 02:22 PM. Reason: Please post code in [code] ... [/code] tags.

      Comment

      • Sfreak
        New Member
        • Mar 2010
        • 64

        #4
        Arulmanoj,

        There are a little tips that you can change there.
        Remembering that WCF only works with Microsoft technologies, the question you should make is WHY AM I USING WCF INSTEAD OF WEBSERVICES? When i ask this the first answer that pops in my mind is PERFORMANCE. You can just take advantage of that when you use NETTCPBINDING instead of HTTPBINDING. Why? Because HTTPBINDING encapsulates the SOAP protocol just like Webservices do. Other thing to your concern is that the maintenance of WCF is a little bit boring. Because you must have the same app.config on the server and client. Check the:
        Code:
        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 
                                <message clientCredentialType="Windows" />
        And take a look at this tag. Because it seems that you have a configuration problem there...

        I hope it can help you

        Fernando Mello

        Comment

        Working...