我在我的客户机和服务器web.config文件中定义了一个自定义绑定,但是当我尝试连接时出现了这个错误,
内容类型应用/xml;服务不支持字符集=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();