无法配置端点

时间:2014-04-23 13:10:23

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

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

  1. 无法建立连接,因为目标计算机主动拒绝了它127.0.0.1:1295
  2. 未配置端点
  3. 端点没有收听
  4. 找不到端点""并且在服务模型客户端配置中签订合同。
  5. 远程服务器返回500(内部错误)
  6. 请帮忙

       [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 个答案:

答案 0 :(得分:0)

配置文件中没有基地址:

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