我需要通過WCF服務傳遞超過64kb的數據。要做到這一點我已經配置了服務器端(託管WCF服務)的方式如下:通過WCF服務傳輸大量數據(超過64kb)
<services>
<service name="MyService" behaviorConfiguration="MyServiceBehavior" >
<endpoint address="" binding="customBinding" contract="MyContract"
bindingName="testBinding" bindingConfiguration="testBinding" />
<endpoint address="mex" binding="customBinding" contract="IMetadataExchange"
bindingName="testBinding" bindingConfiguration="testBinding" />
</service>
</services>
<bindings>
<customBinding>
<binding name="testBinding" >
<textMessageEncoding>
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</textMessageEncoding>
<httpTransport transferMode="Buffered"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"/>
</binding>
</customBinding>
</bindings>
和客戶端(即消費服務):
<client>
<endpoint address="http://localhost:82/MyService.svc"
binding="customBinding" bindingConfiguration="testBinding"
contract="MyContract"
name="MyName" />
</client>
<bindings>
<customBinding>
<binding name="testBinding" >
<textMessageEncoding>
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</textMessageEncoding>
<httpTransport transferMode="Buffered"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"/>
</binding>
</customBinding>
</bindings>
當我打電話要求的方法我已收到以下錯誤:
Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:82/MyService.svc . The client and service bindings may be mismatched.
請指教,什麼是我的綁定不匹配?
謝謝。
事實上,如果您願意將元數據作爲WSDL提供服務,則根本不需要mex端點 - 只需在serviceMetadata行爲中設置httpGetEnabled = true(可能還有httpGetUrl,如果您沒有基地址) –