我创建了一个用作 WCF 客户端的控制台应用程序。app.config 包含以下内容:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="WebHttpBinding_IWebContentService">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:1252/SomeService.svc" binding="customBinding" bindingConfiguration="WebHttpBinding_IWebContentService"
contract="WebContentClient.IWebContentService" name="WebHttpBinding_IWebContentService" />
</client>
</system.serviceModel>
</configuration>
当我运行它时,我收到以下错误:
The address property on ChannelFactory.Endpoint was null
端点元素有一个地址属性,但我不确定我应该分配什么属性。我在本地主机上运行我的网络服务。
更新 1:
我添加了地址并更新了原始代码。但是我收到错误消息,说没有端点监听地址=“http://localhost:1252/SomeService.svc”。如果我访问 wcf url,我可以看到 Web 服务。