3
支持的内容类型我已经定义了一个自定义在我的客户端和服务器的web.config文件装订,但是当我尝试连接,我得到这个错误, 服务器运行IIS 7WCF自定义绑定 - 不是由服务
内容类型application/xml; charset = utf-8不支持服务http://localhost/contentservice.svc/PairService。客户端和服务绑定可能不匹配。
服务器:
<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>
客户:
<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>
这里是发起呼叫代码:
var chan = New WebChannelFactory(Of IContentService)(New Uri("http://localhost/contentservice.svc")).CreateChannel();
chan.PairService();