WCF配置netTCp,端点为空

发布于 2024-10-21 00:23:31 字数 7092 浏览 10 评论 0原文

我收到以下错误

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

,我不确定我做错了什么。有人知道它的原因是什么吗?下面是我项目的 App.config 服务器和客户端 感谢您的帮助,问候

 <system.serviceModel>
    <services>
      <service name="Server.DualService" behaviorConfiguration="NetTcpBehavior">
        <endpoint address=""
              binding="netTcpBinding"
              bindingConfiguration="DuplexBinding"
              contract="Server.IDualService" />

        <endpoint address="mex" binding="mexTcpBinding" contract="Server.IDualService" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8731/Service/DualService/" />
          </baseAddresses>
        </host>
      </service>
      <service name="Server.PhoneService" behaviorConfiguration="Server.PhoneServiceBehavior">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="" contract="Server.IPhoneService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:4444/Service/PhoneService" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Server.DualServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="Server.PhoneServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior  name="NetTcpBehavior">
          <serviceThrottling maxConcurrentSessions="10000" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <netTcpBinding>
        <binding name="DuplexBinding" sendTimeout="00:00:11">
          <reliableSession enabled="true" />
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
  </system.serviceModel>

客户端

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="DefaultBinding_IPhoneService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="">
                        <extendedProtectionPolicy policyEnforcement="Never" />
                    </transport>
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
            <binding name="DefaultBinding_IDualService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="">
                        <extendedProtectionPolicy policyEnforcement="Never" />
                    </transport>
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IPhoneService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="Message">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="">
                        <extendedProtectionPolicy policyEnforcement="Never" />
                    </transport>
                    <message clientCredentialType="Windows" negotiateServiceCredential="true"
                        algorithmSuite="Default" establishSecurityContext="true" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint binding="basicHttpBinding" bindingConfiguration="DefaultBinding_IPhoneService"
            contract="IPhoneService" name="DefaultBinding_IPhoneService_IPhoneService" />
        <endpoint binding="basicHttpBinding" bindingConfiguration="DefaultBinding_IDualService"
            contract="IDualService" name="DefaultBinding_IDualService_IDualService" />
        <endpoint address="http://localhost:4444/Service/PhoneService"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPhoneService"
            contract="ServiceReference2.IPhoneService" name="WSHttpBinding_IPhoneService">
            <identity>
                <userPrincipalName value="PANDZIA-PC\PANDZIA" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

I am getting the following error

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

and I am not sure what I am doing wrong. Does anybody see know what is the reson of it? Below are my project's App.config Server and Client Side
Thank you for help, regards

 <system.serviceModel>
    <services>
      <service name="Server.DualService" behaviorConfiguration="NetTcpBehavior">
        <endpoint address=""
              binding="netTcpBinding"
              bindingConfiguration="DuplexBinding"
              contract="Server.IDualService" />

        <endpoint address="mex" binding="mexTcpBinding" contract="Server.IDualService" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8731/Service/DualService/" />
          </baseAddresses>
        </host>
      </service>
      <service name="Server.PhoneService" behaviorConfiguration="Server.PhoneServiceBehavior">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="" contract="Server.IPhoneService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:4444/Service/PhoneService" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Server.DualServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="Server.PhoneServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior  name="NetTcpBehavior">
          <serviceThrottling maxConcurrentSessions="10000" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <netTcpBinding>
        <binding name="DuplexBinding" sendTimeout="00:00:11">
          <reliableSession enabled="true" />
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
  </system.serviceModel>

CLIENT SIDE

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="DefaultBinding_IPhoneService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="">
                        <extendedProtectionPolicy policyEnforcement="Never" />
                    </transport>
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
            <binding name="DefaultBinding_IDualService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="">
                        <extendedProtectionPolicy policyEnforcement="Never" />
                    </transport>
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IPhoneService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="Message">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="">
                        <extendedProtectionPolicy policyEnforcement="Never" />
                    </transport>
                    <message clientCredentialType="Windows" negotiateServiceCredential="true"
                        algorithmSuite="Default" establishSecurityContext="true" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint binding="basicHttpBinding" bindingConfiguration="DefaultBinding_IPhoneService"
            contract="IPhoneService" name="DefaultBinding_IPhoneService_IPhoneService" />
        <endpoint binding="basicHttpBinding" bindingConfiguration="DefaultBinding_IDualService"
            contract="IDualService" name="DefaultBinding_IDualService_IDualService" />
        <endpoint address="http://localhost:4444/Service/PhoneService"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPhoneService"
            contract="ServiceReference2.IPhoneService" name="WSHttpBinding_IPhoneService">
            <identity>
                <userPrincipalName value="PANDZIA-PC\PANDZIA" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

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

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

发布评论

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

评论(2

夏见 2024-10-28 00:23:31

您的配置存在一些问题。服务器通过 net.tcp 指定 DualService,但客户端使用 BasicHttpBinding 并且不指定地址。此外,您的客户端具有比您的服务公开更多端点的配置,并且 DualService 中的 mex 端点具有不正确的合同(应为 IMetadataExchange)。

只有 PhoneService 的客户端端点看起来正确。

There is some problem with your configuration. Server specifies DualService over net.tcp but client uses BasicHttpBinding and does not specify address. Also your client has configuration for more endpoint then your service expose and mex endpoint in DualService has incorrect contract (should be IMetadataExchange).

Only client endpoint for PhoneService looks correct.

桃气十足 2024-10-28 00:23:31

一切正常,你是对的:),再次感谢你,下面我放置了正确的配置,也许有一天它会对某人有所帮助,.. :D:D

在服务器端我已经更正了端点中的 IMetadataExchange :

 <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" /> 

并且我改变了 在客户端,

<behavior  name="NetTcpBehavior">
      <serviceMetadata/>
      <serviceThrottling maxConcurrentSessions="10000" />
    </behavior>

我删除了大多数与 DualService 相关的通用代码,并添加了

<endpoint name=""
              address="net.tcp://localhost:8731/Service/DualService/"
              binding="netTcpBinding"
              bindingConfiguration="DuplexBinding"
              contract="IDualService" />

绑定如下所示的位置:

<netTcpBinding>
        <binding name="DuplexBinding" sendTimeout="00:00:05" >
          <reliableSession enabled="true" />
          <security mode="None" />
        </binding>
      </netTcpBinding>

Everything works, you were right :),Thank you once again , and below I am putting the correct configuration, maybe someday it will help to somebody, .. :D:D

On server side I ve corrected IMetadataExchange in endpoint :

 <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" /> 

and I changed alittle

<behavior  name="NetTcpBehavior">
      <serviceMetadata/>
      <serviceThrottling maxConcurrentSessions="10000" />
    </behavior>

On CLIENT SIDE I deleted most genereted code in retation with DualService and added

<endpoint name=""
              address="net.tcp://localhost:8731/Service/DualService/"
              binding="netTcpBinding"
              bindingConfiguration="DuplexBinding"
              contract="IDualService" />

where binding looks like :

<netTcpBinding>
        <binding name="DuplexBinding" sendTimeout="00:00:05" >
          <reliableSession enabled="true" />
          <security mode="None" />
        </binding>
      </netTcpBinding>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文