繁体   English   中英

wcf服务端点null

[英]wcf service endpoint null

我的wcf服务库中有这个App.config:

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="addr" value="net.tcp://localhost:22222/AdministrationService/"/>
  </appSettings>
  <system.serviceModel>
    <services>
      <service name="Watchman.WcfService.AdministrationService" behaviorConfiguration="MyBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:22222/AdministrationService/"/>
          </baseAddresses>
        </host>
        <endpoint name="Ep1" address="net.tcp://localhost/AdministrationService/" binding="netTcpBinding" bindingConfiguration="DuplexBinding" contract="Watchman.WcfService.Interfaces.IAdministration"/>
        <endpoint name="mex" address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="MyBehavior">
          <serviceThrottling maxConcurrentSessions="10000"/>
          <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost/AdministrationService/Ep1/wsdl"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <bindings>
      <netTcpBinding>
        <binding name="DuplexBinding" sendTimeout="00:00:01">
          <reliableSession enabled="true"/>
          <security mode="None"/>
        </binding>
      </netTcpBinding>
    </bindings>
  </system.serviceModel>

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
  </startup>

</configuration>

但我得到了错误:

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

似乎应用程序没有此tcp.net端点。 为什么?

我的wcf服务库中有这个App.config

您不能在wcf类库中有一个app.config,并且希望WCF从中读取设置。 这没有道理。 在最终的可执行应用程序项目(例如控制台应用程序,WinForms,WPF等)中定义了诸如app.config之类的配置文件。 或者,如果它是一个Web应用程序,则使用web.config。 但是,类库没有诸如app.config这样的东西。 因此,您可能需要使用类库将此WCF配置包括在应用程序的app / web.config中。

您已为net.tcp指定了基地址,因此net.tcp端点上的地址成为相对地址。 因此,端点的地址实际上变为net.tcp:// localhost:22222 / AdministrationService / localhost / AdministrationService /。

将端点上的地址更改为相对地址,然后使用svcutil重新生成代理类。

我只是注意到svcutil在wcf客户端项目中生成了错误的端点。

<endpoint binding="basicHttpBinding"
          bindingConfiguration="DefaultBinding_IAdministration" 
          contract="IAdministration" 
          name="DefaultBinding_IAdministration_IAdministration" />"

而不是我的net.tcp端点。

我还观察到这是由于生成了ProxyFile.csApp.config

svcutil WcfServiceLibrary.dll

如果我从元数据生成此文件,例如:

svcutil net.tcp://localhost:8080/AdministrationService/mex /language:C# /out:ProxyFile.cs /config:App.config

然后工作正常(在App config中描述了正确的net.tcp端点)

有谁知道为什么与* .dll的svcutil合作出错?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM