【问题标题】:Unable to configure endpoints无法配置端点
【发布时间】:2014-06-08 08:23:35
【问题描述】:

我正在从事一个项目,其中一个团队创建了 wcf 服务,而我们的 MVC 团队必须使用该服务并将参数传递给该服务。由于以下错误,我们无法以不同的方式调用该服务:

  1. 无法建立连接,因为目标机器主动拒绝了它 127.0.0.1:1295
  2. 未配置端点
  3. 端点没有监听
  4. 在服务模型客户端配置中找不到端点“”和合同。
  5. 远程服务器返回 500(内部错误)

请帮忙

   [ServiceContract]
    public interface ITnTService
    {

        [OperationContract]      
        List<GetCity_Result> Getcity();

        [OperationContract]
        bool PContact(Person item);
}

Web.config

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>

    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.serviceModel>
<behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
      <service name="TnT.Services.TnTService">
        <endpoint address="basic1" binding="basicHttpBinding" contract="TnT.Services.ITnTService"/>
      </service>
    </services>

  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
 <directoryBrowse enabled="true" />
  </system.webServer>
  <connectionStrings>
    <add name="TnTEntities" connectionString="metadata=res://*/TnT_Model.csdl|res://*/TnT_Model.ssdl|res://*/TnT_Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=183.82.48.194;initial catalog=TnT;persist security info=True;user id=dev;password=dev;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

【问题讨论】:

  • 请问:1) 共享服务合同。 2) 网络配置
  • 端口是否开放?如果您将服务的完整 URL 放在浏览器窗口中,您应该会看到一个带有服务的 WSDL 的屏幕(假设他们打开了 mex)。试试看,看看你会得到什么。如果您什么也得不到,则可能是网络或防火墙问题。
  • @Legart,我添加了合约和配置。
  • 能否请您共享客户端代码以连接到该服务。并共享您在客户端使用的 Uri 以连接到服务。

标签: asp.net-mvc wcf asp.net-mvc-4 restful-authentication


【解决方案1】:

您的配置文件中没有基地址:

<services>
  <service name="TnT.Services.TnTService">
    <endpoint address="basic1" binding="basicHttpBinding" contract="TnT.Services.ITnTService"/>

    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:1295"/>
      </baseAddresses>
    </host>
  </service>
</services>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-26
    • 1970-01-01
    • 2013-05-29
    • 2020-07-26
    • 2020-07-08
    • 1970-01-01
    相关资源
    最近更新 更多