簡體   English   中英

IIS Hosting中的WCF庫未從客戶端連接

[英]WCF Library in IIS Hosting not connecting from client

您好,我有一個WCF服務庫項目,並且我已經創建了一個WPF應用程序來承載它進行測試,並且效果很好,但是我還創建了一個Web應用程序來承載它在IIS中進行生產,以及嘗試連接到IIs時我永遠做不到

我正在使用net.tcp bininding,並且已經進入IIS,並將net.tcp biniding添加到Web應用程序和網站中。

基本上,這是一種雙工服務,其方法標記為一種方法。 當我在客戶端中調用該方法時,永遠不會調用該回調,而最終我只是坐在那里等待了幾分鍾,然后關閉了應用程序。 當我自托管服務時,幾乎立即在回調上得到響應。

我也嘗試使用localhost:808和localhost。 如果我使用svcutil生成配置,它將使端口脫離地址。 我沒有發現任何錯誤,但是老實說我真的不知道如何判斷是否從IIS拋出了任何錯誤。

另外,如果我轉到http://localhost:9595/EcuWebService/Service.svc看到告訴我使用svcutil生成客戶端代理的頁面。

正如Jocke在下面建議的那樣,我連接了調試器並收到此錯誤:服務'/ EcuWebService / service'不存在。

這也是我的svc文件的內容:

<%@ ServiceHost Language="C#" Debug="true" Service="EcuWeb.ServiceLib.Contracts.EcuWebServiceMain" %>

下面是我的Web.config:

<?xml version="1.0"?>
  <configuration>
<configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
  <appSettings>
     <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
 <system.web>
   <compilation debug="true" targetFramework="4.5" />
   <httpRuntime targetFramework="4.5"/>
 </system.web>
<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" minFreeMemoryPercentageToActivateService="1" multipleSiteBindingsEnabled="true"/>
    <services>
        <service name="EcuWeb.ServiceLib.Contracts.EcuWebServiceMain">
            <endpoint address="net.tcp://localhost:808/EcuWebService/service" binding="netTcpBinding" bindingConfiguration="" name="netTcp_EcuWebServiceEndpoint" contract="EcuWeb.ServiceLib.Contracts.IEcuWebServiceMain">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="net.tcp://localhost:808/EcuWebService/mex" binding="mexTcpBinding" bindingConfiguration="" name="mexTcp_EcuWebServiceEndpoint" contract="IMetadataExchange" />
            <host>
               <baseAddresses>
                  <add baseAddress="http://localhost/EcuWebService" />
                </baseAddresses>
            </host>
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="">
                <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

這是客戶端應用程序的配置。 注釋掉的終結點是我不在IIS中托管時使用的終結點,並且可以正常工作。

<?xml version="1.0" encoding="utf-8" ?>
  <configuration>
    <system.web>
      <compilation debug="true" />
    </system.web>
     <!-- When deploying the service library project, the content of the config file    must be added to the host's 
          app.config file. System.Configuration does not support config files for libraries. -->
     <system.serviceModel>
       <bindings>
        <netTcpBinding>
          <binding name="netTcp_EcuWebServiceEndpoint" />
        </netTcpBinding>
       </bindings>
     <client>
      <!--<endpoint address="net.tcp://localhost:5555/EcuWebService/service"
       binding="netTcpBinding" bindingConfiguration="netTcp_EcuWebServiceEndpoint"
       contract="EcuWebService.IEcuWebServiceMain" name="netTcp_EcuWebServiceEndpoint">
        <identity>
         <dns value="localhost" />
        </identity>
       </endpoint>-->
         <endpoint address="net.tcp://localhost/EcuWebService/service"
            binding="netTcpBinding" bindingConfiguration="netTcp_EcuWebServiceEndpoint"
            contract="EcuWebService.IEcuWebServiceMain"    name="netTcp_EcuWebServiceEndpoint">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
</client>
<services>
  <service name="Ecu.Service.Contracts.EcuServiceMain">
    <endpoint address="service" binding="netNamedPipeBinding" bindingConfiguration=""
      name="netNamedPipe_EcuClientEndpoint" contract="Ecu.Service.Contracts.IEcuServiceMain">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexNamedPipeBinding" bindingConfiguration=""
      name="mexNamedPipe_EcuClientEndpoint" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.pipe://localhost/EcuServiceClient" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
   <serviceBehaviors>
     <behavior name="">
       <serviceMetadata httpGetEnabled="false" />
         <serviceDebug includeExceptionDetailInFaults="true" />
     </behavior>
   </serviceBehaviors>
 </behaviors>

好吧,我終於明白了。

首先,我必須添加:

<host>
 <baseAddresses>
  <add baseAddress="net.tcp://localhost:5555/EcuWebService" />
  <add baseAddress="http://localhost/EcuWebService" />
 </baseAddresses>
</host>

然后對於我剛剛使用的端點:

<service name="EcuWeb.ServiceLib.Contracts.EcuWebServiceMain">
<endpoint address="service" binding="netTcpBinding" bindingConfiguration=""
 name="netTcp_EcuWebServiceEndpoint" contract="EcuWeb.ServiceLib.Contracts.IEcuWebServiceMain">
 <identity>
  <dns value="localhost" />
 </identity>
</endpoint>

然后在客戶端中,我必須使用:

<endpoint address="net.tcp://localhost/EcuWebService/Service.svc/service"
    binding="netTcpBinding" bindingConfiguration="netTcp_EcuWebServiceEndpoint"
    contract="EcuWebService.IEcuWebServiceMain" name="netTcp_EcuWebServiceEndpoint">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>

當我添加端口時,它不起作用,但是一旦刪除它,它就沒有問題。 我也懷疑基址是必需的,因為IIS無論如何都給出了該地址。

怎么了? 你有例外嗎? 您可以在IIS中瀏覽它嗎?

您的服務有:

endpoint address="net.tcp://localhost:808/EcuWebService/mex"

和客戶:

endpoint address="net.tcp://localhost/EcuWebService/service"

我認為您需要提供更多詳細信息才能獲得良好的答案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM