我在客户端和服务器web.config文件中定义了自定义绑定,但是当我尝试连接时出现此错误, 服务器正在运行IIS 7
内容类型application / xml;服务http://localhost/contentservice.svc/PairService不支持charset = utf-8。客户端和服务绑定可能不匹配。
服务器
<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();
答案 0 :(得分:0)
找到解决方案,
我必须使用ChannelFactory
而不是WebChannelFactory
var proxy = ChannelFactory(Of IContentService).CreateChannel(New EndpointAddress("http://localhost/service.svc"))