2013-02-12 46 views
0

你好我有一个WCF服务库项目,我已经创建了一个WPF应用程序来承载它进行测试,并且工作得很好,但我也创建了一个Web应用程序来托管它在IIS用于制作,当我试图连接到II时,我永远都不会。IIS托管WCF图书馆不从客户端连接

我正在使用net.tcp bininding,并且我进入了IIS并将net.tcp biniding添加到了web应用程序和网站。

基本上这是一种双工服务,标记为单向的方法。当我在客户端调用该方法时,回调永远不会被调用,最终我会在关闭应用程序之前等待几分钟。当我自己托管服务时,我几乎立即在回调中收到回复。

此外我已经尝试使用localhost:808和localhost。如果我使用svcutil生成配置,它会将该端口留在地址之外。我没有得到任何我知道的错误,但我真的不知道如何判断我是否从IIS中得到任何错误。

此外,如果我去http://localhost:9595/EcuWebService/Service.svc我得到的页面告诉我使用svcutil来生成我的客户端代理。

由于Jocke建议下面我附加了一个调试器,并收到此错误:服务'/ EcuWebService /服务'不存在。

而且,这里是我的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> 

这是CONF ig为客户端应用程序。注释掉的端点是我不使用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> 

回答

1

好吧,我终于明白了这一点。

首先,我不得不补充:

<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都在给这个地址。

0

会发生什么?你有例外吗?你可以在IIS中浏览它吗?

您的服务有:

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

和客户端:

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

我认为你需要提供更多的细节得到一个很好的答案。

+0

我添加了更多信息,但是我没有在客户端发生任何错误,是的,我可以在浏览器中浏览http地址,没有任何问题,但是我没有为通信定义任何http端点。 – twreid 2013-02-12 22:01:09

+0

尝试在IIS/WAS中启用调试,并查看是否可以获取更多信息,是否查看了计算机上的事件日志? – Jocke 2013-02-13 08:50:58

+0

好吧,我附加了一个调试器,并得到服务'/ EcuWebService /服务'不存在。 – twreid 2013-02-13 14:02:31