我正在开发一个项目,其中一个团队创建了wcf服务,我们MVC团队必须使用该服务并将参数传递给该服务。在使用不同的方式调用服务时,由于以下错误,我们无法调用该服务:
请帮忙
[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="data source=183.82.48.194;initial catalog=TnT;persist security info=True;user id=dev;password=dev;MultipleActiveResultSets=True;App=EntityFramework"" 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>
答案 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>