ChannelFactory.Endpoint 上的 Address 属性为 null。 ChannelFactory 的端点必须指定有效的地址

发布于 2024-08-05 06:29:41 字数 3347 浏览 7 评论 0原文

我收到以下错误,我不确定我做错了什么。有人看到任何明显的东西吗?下面是我的项目的 Web.config 和我的 WCF 类库的 App.config

地址属性 ChannelFactory.Endpoint 为空。这 ChannelFactory 的 Endpoint 必须有一个 指定的有效地址。

服务器上的 APP.CONFIG(在我的类库中)

<system.serviceModel>
    <services>
      <service behaviorConfiguration="Default" name="Trezoro.WebAPI.Trade.TradeService">
        <endpoint address="" behaviorConfiguration="WebEPBehavior" binding="webHttpBinding" 
          contract="ITradeService" name="WebHttpBinding_ITradeService" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/tradeservice/" />
          </baseAddresses>
        </host>
      </service>
      <service behaviorConfiguration="Default" name="Trezoro.WebAPI.Authentication.AuthService">
        <endpoint address="" behaviorConfiguration="WebEPBehavior" binding="webHttpBinding" 
          contract="IAuthService" name="WebHttpBinding_IAuthService" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8081/authservice" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="WebEPBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="Default">
          <serviceMetadata httpGetEnabled="True" />
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

WEB 项目中的 WEB.CONFIG

<system.serviceModel>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

    <bindings>
       <customBinding>
          <binding name="WebHttpBinding_IAuthService">
             <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                messageVersion="Soap12" writeEncoding="utf-8">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                   maxBytesPerRead="4096" maxNameTableCharCount="16384" />
             </textMessageEncoding>
          </binding>
          <binding name="WebHttpBinding_ITradeService">
             <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 binding="customBinding" bindingConfiguration="WebHttpBinding_IAuthService"
    contract="IAuthService" name="WebHttpBinding_IAuthService" />
   <endpoint binding="customBinding" bindingConfiguration="WebHttpBinding_ITradeService"
    contract="ITradeService" name="WebHttpBinding_ITradeService" />
  </client>
    </system.serviceModel>

I am getting the following error and I am not sure what I am doing wrong. Does anybody see anything obvious? Below are my project's Web.config and my WCF class library's App.config

The Address property on
ChannelFactory.Endpoint was null. The
ChannelFactory's Endpoint must have a
valid Address specified.

APP.CONFIG ON SERVER (IN MY CLASS LIBRARY)

<system.serviceModel>
    <services>
      <service behaviorConfiguration="Default" name="Trezoro.WebAPI.Trade.TradeService">
        <endpoint address="" behaviorConfiguration="WebEPBehavior" binding="webHttpBinding" 
          contract="ITradeService" name="WebHttpBinding_ITradeService" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/tradeservice/" />
          </baseAddresses>
        </host>
      </service>
      <service behaviorConfiguration="Default" name="Trezoro.WebAPI.Authentication.AuthService">
        <endpoint address="" behaviorConfiguration="WebEPBehavior" binding="webHttpBinding" 
          contract="IAuthService" name="WebHttpBinding_IAuthService" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8081/authservice" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="WebEPBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="Default">
          <serviceMetadata httpGetEnabled="True" />
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

WEB.CONFIG IN WEB PROJECT

<system.serviceModel>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

    <bindings>
       <customBinding>
          <binding name="WebHttpBinding_IAuthService">
             <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                messageVersion="Soap12" writeEncoding="utf-8">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                   maxBytesPerRead="4096" maxNameTableCharCount="16384" />
             </textMessageEncoding>
          </binding>
          <binding name="WebHttpBinding_ITradeService">
             <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 binding="customBinding" bindingConfiguration="WebHttpBinding_IAuthService"
    contract="IAuthService" name="WebHttpBinding_IAuthService" />
   <endpoint binding="customBinding" bindingConfiguration="WebHttpBinding_ITradeService"
    contract="ITradeService" name="WebHttpBinding_ITradeService" />
  </client>
    </system.serviceModel>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

枕花眠 2024-08-12 06:29:41

您的客户端端点缺少地址。

Your client endpoint is missing an address.

热情消退 2024-08-12 06:29:41

只需在客户端(消费端)为端点标签添加地址属性即可。

Just add address attribute for endpoint tag in client side(consuming end).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文