locked
WCF in WP7 "The client and service bindings may be mismatched." RRS feed

  • Question

  • I create and tested a WCF service locally and of course it works fine.  I published to a shared hosting site and browsed to the wsdl and appears to be fine.  But when I make a call in WP7 code to the service I get an error with a useless error message.  After enabling includeExceptionDetailInFaults and WCF tracing the error reads.  “System.ServiceModel.ProtocolException: Content Type application/soap+xml; charset=utf-8 was sent to a service expecting text/xml; charset=utf-8.  The client and service bindings may be mismatched.”

    Here are parts of the web.config  

    <bindings>
       <basicHttpBinding>
         <!—- there is not a binding for this service should there be? -->
         <!—- other services… -->
       </basicHttpBinding>
    </bindings>

    <behaviors>
       <serviceBehaviors>
        <behavior name="SL_SeeYaThere_WCF.Web.SeeYaThereWCFBehavior">
         <serviceMetadata httpGetEnabled="true" />
         <serviceDebug httpHelpPageEnabled ="true" includeExceptionDetailInFaults="true"  />
        </behavior>
        <!—- other services… -->
       </serviceBehaviors>
    </behaviors>
    <services>
       <service behaviorConfiguration="SL_SeeYaThere_WCF.Web.SeeYaThereWCFBehavior" name="SL_SeeYaThere_WCF.Web.SeeYaThereWCF">
        <endpoint address="" binding="basicHttpBinding" contract="SL_SeeYaThere_WCF.Web.ISeeYaThereWCF" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
       </service>
       <!—- other services… -->
    </services>

    This is my first experience with WFC and it hasn’t been enjoyable.  What am I doing wrong?

    Thanks for your help.

    Sunday, December 12, 2010 10:59 AM

Answers

  • Ok found the problem.  In the WP7 app there  is a ServicesReferences.clientConfig file that has the client bindings.  There were two end points for the WCF service one for Localhost and one for the shared hosted address.  It must have happened when I 'configure service reference' from the local host to shared host site.

    I changed the local host adderss to shared hosted addresss and it works.

    Monday, December 13, 2010 11:45 PM

All replies

  • Go to 'Configure Service Reference' and check that the 'Collection Type' and 'Dictionary collection type' match with whatever the WCF service uses. Can cause this error so worth a check especially since the defaults are not the same in SL4 and WP7 SL.

    Sunday, December 12, 2010 12:08 PM
  • Thanks for the response xPert360.  Yes in 'Configure Service Reference' I changed the Type Collection to Systems.Collections Generic.List and Dictionary collection type to Systems.Collections Generic.Dictionary.  I also unchecked Reuse types in referenced assemblies.  I encountered that when I initially tried to use the WCF service from WP7... while still on localhost.

    I was hoping that all those types of problems could be ironed out while still hosted local and then just publish.

    Sunday, December 12, 2010 12:30 PM
  • Ok found the problem.  In the WP7 app there  is a ServicesReferences.clientConfig file that has the client bindings.  There were two end points for the WCF service one for Localhost and one for the shared hosted address.  It must have happened when I 'configure service reference' from the local host to shared host site.

    I changed the local host adderss to shared hosted addresss and it works.

    Monday, December 13, 2010 11:45 PM