简体   繁体   English

IIS Hosting中的WCF库未从客户端连接

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

Hello I have a WCF service library project and I have created a WPF app to host it for testing and that works just fine, but I also created a web app to host it in IIS for production and when I try to connect to the IIs one I never can. 您好,我有一个WCF服务库项目,并且我已经创建了一个WPF应用程序来承载它进行测试,并且效果很好,但是我还创建了一个Web应用程序来承载它在IIS中进行生产,以及尝试连接到IIs时我永远做不到

I am using a net.tcp bininding and I have gone in to IIS and added the net.tcp biniding to the web app and the web site. 我正在使用net.tcp bininding,并且已经进入IIS,并将net.tcp biniding添加到Web应用程序和网站中。

Basically this is a duplex service with the methods marked as one way. 基本上,这是一种双工服务,其方法标记为一种方法。 When I call the method in the client the callback never gets called and I end up just sitting there waiting for several minutes before I close the application. 当我在客户端中调用该方法时,永远不会调用该回调,而最终我只是坐在那里等待了几分钟,然后关闭了应用程序。 When I self host the service I get a response almost immediately on the callback. 当我自托管服务时,几乎立即在回调上得到响应。

Also I have tried using localhost:808 and just localhost. 我也尝试使用localhost:808和localhost。 If I use svcutil to generate the config it leaves the port off of the address. 如果我使用svcutil生成配置,它将使端口脱离地址。 I don't get any errors that I am aware of, but I honestly don't really know how to tell if I get any errors it throws from IIS. 我没有发现任何错误,但是老实说我真的不知道如何判断是否从IIS抛出了任何错误。

Also if I go to http://localhost:9595/EcuWebService/Service.svc I get the page that tells me to use svcutil to generate my client proxy. 另外,如果我转到http://localhost:9595/EcuWebService/Service.svc看到告诉我使用svcutil生成客户端代理的页面。

As Jocke suggested below I attached a debugger and received this error: The service '/EcuWebService/service' does not exist. 正如Jocke在下面建议的那样,我连接了调试器并收到此错误:服务'/ EcuWebService / service'不存在。

Also here is the contents of my svc file: 这也是我的svc文件的内容:

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

below is my Web.config: 下面是我的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>

This is the config for the client app. 这是客户端应用程序的配置。 The commented out endpoint is the endpoint that I use when not hosting in IIS and it works. 注释掉的终结点是我不在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>

Ok I finally got this figured out. 好吧,我终于明白了。

First I had to add: 首先,我必须添加:

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

Then for the endpoint I just used: 然后对于我刚刚使用的端点:

<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>

Then in the client I had to use: 然后在客户端中,我必须使用:

<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>

When I added the port it didn't work, but once I removed it it worked no problem. 当我添加端口时,它不起作用,但是一旦删除它,它就没有问题。 Also I doubt the base address is required as IIS is giving the address anyway. 我也怀疑基址是必需的,因为IIS无论如何都给出了该地址。

What happens? 怎么了? Do you get an exception? 你有例外吗? Can you browse it in the IIS? 您可以在IIS中浏览它吗?

Your service has: 您的服务有:

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

and the client: 和客户:

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

I think you need provide more details to get a good answer. 我认为您需要提供更多详细信息才能获得良好的答案。

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

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