我有一个Wcf Service Application
项目,该项目在不同的项目中被引用和使用。启动Visual Studio 2012时,一切正常 - 启动IIS Express,托管在localhost上。
我尝试在Publish
的右键菜单中使用Wcf Service Application
选项。我创建了一个新的发布配置文件:
点击Publish
有效。我可以通过互联网浏览器通过http://localhost
访问它。但是,当我正常启动我的应用程序时,通过bin / Debug中的可执行文件 - 它不起作用(应用程序崩溃)。我该怎么办?我可以上传它并使用IIS管理器轻松配置(尝试过,但会出现一些访问错误)?我需要在没有安装任何VS的虚拟机中使用它。
令我感到不安的是,在我的Wcf Service Application
项目的Web.config
文件中,我的基本地址如下所示:http://localhost:8733/WcfServiceLibrary/MailingListService/
和客户端App.config
我的端点包含这样的地址:http://localhost/MailingListService.svc
。是否可以使用不同的端口和地址(一个在root中,另一个在WcfServiceLibrary
中)?它在Visual Studio中运行时工作正常。
Web.config
:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="NewsletterEntities" connectionString="metadata=res://*/NewsletterDAL_EF.csdl|res://*/NewsletterDAL_EF.ssdl|res://*/NewsletterDAL_EF.msl;provider=System.Data.SqlClient;provider connection string="Data Source=(local)\SQLEXPRESS;Initial Catalog=Newsletter;Integrated Security=True;Pooling=False;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="WCFHost.MessageService">
<endpoint address="" binding="basicHttpBinding" contract="WCFHost.IMessageService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/WcfServiceLibrary/MessageService/" />
</baseAddresses>
</host>
</service>
<service name="WCFHost.MailingListService">
<endpoint address="" binding="basicHttpBinding" contract="WCFHost.IMailingListService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/WcfServiceLibrary/MailingListService/" />
</baseAddresses>
</host>
</service>
<service name="WCFHost.RecipientService">
<endpoint address="" binding="basicHttpBinding" contract="WCFHost.IRecipientService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/WcfServiceLibrary/RecipientService/" />
</baseAddresses>
</host>
</service>
<service name="WCFHost.SenderService">
<endpoint address="" binding="basicHttpBinding" contract="WCFHost.ISenderService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/WcfServiceLibrary/SenderService/" />
</baseAddresses>
</host>
</service>
</services>
<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" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
App.config
:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMessageService" />
<binding name="BasicHttpBinding_IRecipientService" />
<binding name="BasicHttpBinding_IMailingListService" />
<binding name="BasicHttpBinding_ISenderService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:2433/MessageService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMessageService"
contract="MessageServiceReference.IMessageService" name="BasicHttpBinding_IMessageService" />
<endpoint address="http://localhost/RecipientService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRecipientService"
contract="RecipientServiceReference.IRecipientService" name="BasicHttpBinding_IRecipientService" />
<endpoint address="http://localhost/MailingListService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMailingListService"
contract="MailingListServiceReference.IMailingListService"
name="BasicHttpBinding_IMailingListService" />
<endpoint address="http://localhost/SenderService.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ISenderService" contract="SenderServiceReference.ISenderService"
name="BasicHttpBinding_ISenderService" />
</client>
</system.serviceModel>
</configuration>
答案 0 :(得分:1)
不要打扰任何事情。只需执行以下操作: 1)在服务url字段中输入localhost。 2)您在站点字段中的inetmgr内添加的网站名称。