2010-07-08 10 views
3

J'ai défini une liaison personnalisée dans mon client et serveur de fichiers web.config, mais quand je tente de me connecter, je reçois cette erreur, serveur exécute IIS 7WCF contraignant sur mesure - Type de contenu non pris en charge par le service

Type de contenu application/xml; charset = utf-8 n'était pas supporté par le service http://localhost/contentservice.svc/PairService. Les liaisons client et service peuvent être incompatibles.

Serveur:

<system.serviceModel> 
    <client> 
    <endpoint binding="customBinding" bindingConfiguration="BinaryBinding" contract="Me.IContentService" name="ContentStagingEndpoint" /> 
    </client> 
    <bindings> 
    <customBinding> 
     <binding name="BinaryBinding"> 
     <binaryMessageEncoding/> 
     <httpTransport/> 
     </binding> 
    </customBinding> 
    </bindings> 
    </system.serviceModel> 

Client:

<system.serviceModel> 
    <behaviors> 
    <serviceBehaviors> 
     <behavior name="ContentService"> 
     <serviceMetadata httpGetEnabled="true"/> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
    </serviceBehaviors> 
    </behaviors> 
    <services> 
    <service behaviorConfiguration="ContentService" name="Me.ContentService"> 
     <endpoint address="" binding="customBinding" bindingConfiguration="BinaryBinding" contract="Contracts.IContentService"> 
     <identity> 
      <dns value="localhost"/> 
     </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
    </service> 
    </services> 
    <bindings> 
    <customBinding> 
     <binding name="BinaryBinding"> 
     <binaryMessageEncoding/> 
     <httpTransport/> 
     </binding> 
    </customBinding> 
    </bindings> 
</system.serviceModel> 

et est ici le code qui lance l'appel:

var chan = New WebChannelFactory(Of IContentService)(New Uri("http://localhost/contentservice.svc")).CreateChannel(); 

chan.PairService(); 

Répondre

0

trouvé la solution, Je devais utiliser ChannelFactory au lieu de WebChannelFactory

var proxy = ChannelFactory(Of IContentService).CreateChannel(New EndpointAddress("http://localhost/service.svc"))