469,327 Members | 1,292 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

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 IsContentTypeSupported 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
Aug 5 '10 #1
3 8219
Sfreak
64
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=true) when using a ORM.

This is an example of a binding

Expand|Select|Wrap|Line Numbers
  1.  <binding name="Tipos" closeTimeout="00:01:00" openTimeout="00:01:00"
  2.                     receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"
  3.                     transferMode="Buffered" transactionProtocol="OleTransactions"
  4.                     hostNameComparisonMode="StrongWildcard" listenBacklog="10"
  5.                     maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
  6.                     maxReceivedMessageSize="65536">
  7.                     <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
  8.                         maxBytesPerRead="4096" maxNameTableCharCount="16384" />
  9.                     <reliableSession ordered="true" inactivityTimeout="00:10:00"
  10.                         enabled="false" />
  11.                     <security mode="None">
  12.                         <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
  13.                         <message clientCredentialType="Windows" />
  14.                     </security>
  15.                 </binding> 
Hope this can help you

Fernando Mello
Aug 5 '10 #2
Hi Fernando,

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


Expand|Select|Wrap|Line Numbers
  1. <system.serviceModel>
  2. <bindings>
  3. <basicHttpBinding>
  4. <binding name="LargeMessageBinding" closeTimeout="10:10:00" openTimeout="10:10:00"
  5.  receiveTimeout="10:10:00" sendTimeout="10:10:00" allowCookies="false"
  6.  bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
  7.  maxBufferSize="500000000" maxBufferPoolSize="524288" maxReceivedMessageSize="500000000"
  8.  messageEncoding="Text"
  9.  textEncoding="utf-8" transferMode="Streamed" useDefaultWebProxy="true">
  10. <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
  11. maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
  12. <security mode="None">
  13. <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
  14. <message clientCredentialType="UserName" algorithmSuite="Default"/>
  15. </security>
  16. </binding>
  17. </basicHttpBinding>
  18. </bindings>
  19. <services>
  20. <service behaviorConfiguration="IVService.IVServiceBehavior" name="Tusa.Services.IVService.IVService">
  21. <endpoint name="basicHttpBinding" address="" binding="basicHttpBinding" bindingConfiguration="LargeMessageBinding" contract="Tusa.Services.IVService.IIVService">
  22.     <identity>
  23.         <dns value="localhost"/>
  24.     </identity>
  25. </endpoint>
  26. <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  27. </service>
  28. </services>
  29. <behaviors>
  30. <serviceBehaviors>
  31. <behavior name="IVService.IVServiceBehavior">
  32.     <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
  33.     <serviceMetadata httpGetEnabled="true"/>
  34.     <!-- 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 -->
  35.     <serviceDebug includeExceptionDetailInFaults="true"/>
  36. <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
  37. </behavior>
  38. </serviceBehaviors>
  39. </behaviors>
  40. </system.serviceModel>
  41.  
In asp.net application am calling this WCF service using with the web.config as below.

Expand|Select|Wrap|Line Numbers
  1. <system.serviceModel>
  2. <bindings>
  3.     <basicHttpBinding>
  4.         <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">
  5.             <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
  6.             <security mode="None">
  7.                 <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
  8.                 <message clientCredentialType="UserName" algorithmSuite="Default"/>
  9.             </security>
  10.         </binding>
  11.     </basicHttpBinding>
  12. </bindings>
  13. <client>
  14.     <endpoint address="http://chn355/Base/Base.svc" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="IBase" name="basicHttpBinding" behaviorConfiguration="maxItemsInObjectGraphBehaviour"/>
  15. </client>
  16. <behaviors>
  17.     <endpointBehaviors>
  18.         <behavior name="maxItemsInObjectGraphBehaviour">
  19.             <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
  20.         </behavior>
  21.     </endpointBehaviors>
  22. </behaviors>
  23. </system.serviceModel>
Please check and let me know whether am making mistake with config files.

Thanks

Manoj.
Aug 9 '10 #3
Sfreak
64
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:
Expand|Select|Wrap|Line Numbers
  1. <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 
  2.                         <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
Aug 9 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Andrew V. Romero | last post: by
4 posts views Thread by Bryan Tang | last post: by
2 posts views Thread by Veke | last post: by
2 posts views Thread by Niron kag | last post: by
4 posts views Thread by JamesB | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by listenups61195 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.