2011-02-04 9 views
5

L'eccezione:WCF - codifica binaria su HTTP gettando client e il servizio vincolante eccezione non corrispondente

applicazione Content Type/soap + msbin1 non è stato supportato da un servizio http://localhost:1500/MyService.svc. Le associazioni client e servizio potrebbero essere non corrispondenti.

La configurazione del client:

<system.serviceModel> 
    <bindings> 

    <customBinding> 
     <binding name="NetHttpBinding" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"> 
      <binaryMessageEncoding /> 
      <httpTransport allowCookies="false" bypassProxyOnLocal="false" 
         hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" 
         maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
         transferMode="Buffered" useDefaultWebProxy="true" /> 
     </binding> 
     </customBinding> 

    </bindings> 
    <client> 
     <endpoint address="http://localhost:1500/MyService.svc" 
     binding="customBinding" bindingConfiguration="NetHttpBinding" 
     contract="APP.BLL.IMyServiceContract" name="MyServiceEndpoint" /> 
    </client> 
    </system.serviceModel> 

La configurazione del server:

<system.serviceModel> 
    <bindings> 
     <customBinding> 
     <binding name="NetHttpBinding" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"> 
      <binaryMessageEncoding /> 
      <httpTransport allowCookies="false" bypassProxyOnLocal="false" 
         hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" 
         maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
         transferMode="Buffered" useDefaultWebProxy="true" /> 
     </binding> 
     </customBinding> 
    </bindings> 

    <services> 
     <service name="MyAppService"> 
     <endpoint address="" binding="customBinding" bindingConfiguration="NetHttpBinding" 
        contract="APP.BLL.IMyServiceContract"> 
     </endpoint> 
     </service> 
    </services> 

    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- 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"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 

    </system.serviceModel> 
+0

Il servizio è ospitato in IIS o in un'altra applicazione di hosting? –

+0

L'ho ospitato all'interno di Visual Studio per ora. Il webserver integrato (non ricordo mai il suo nome). Lo distribuirò a IIS una volta terminato. – mbursill

+0

Ho avuto lo stesso problema se il server [endpoint ** Contratto **] (http://msdn.microsoft.com/en-us/library/system.servicemodel.description.serviceendpoint.contract.aspx) non corrisponde al contratto effettivo utilizzato dall'endpoint. – SliverNinja

risposta

4

Non è possibile utilizzare binaryMessageEncoding e HTTP senza customBindings. È possibile utilizzare textMessageEncoding o mtomMessageEncoding fuori dalla scatola.

Vedere questo post del blog per reference on using customBindings with HTTP transport.

<bindings> 
    <customBinding> 
     <binding name="basicHttpBinaryBinding"> 
     <binaryMessageEncoding />    
     <httpTransport /> 
     </binding> 
    </customBinding> 
</bindings> 
+3

Ciò contraddice ciò che ho letto su alcuni siti: http://jeffbarnes.net/blog/post/2007/02/22/WCF-Enable-Binary-Encoding-Over-Http.aspx Hai un articolo che parla di questo? – mbursill

+1

HTTP è un protocollo basato su testo. MTOM è stato specificamente progettato per aggiungere allegati binari (il vecchio protocollo DIME) a ​​HTTP. Il codificatore binario richiede un flusso binario e non un flusso di testo. –

+0

@mbursill - Ho aggiornato la risposta per riflettere le funzionalità testate. È possibile ottenere il tipo di contenuto 'application/soap + msbin1' usando una configurazione' customBinding'. [Jeff Barnes posting] (http://jeffbarnes.net/blog/post/2007/02/22/WCF-Enable-Binary-Encoding-Over-Http.aspx) è accurato. – SliverNinja

Problemi correlati