我需要通过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,如果您没有基地址) –