[英]Visual Studio 2012 + IIS 8.0 = how to deploy WCF service on localhost?
I have a Wcf Service Application
project that is referenced by and used in different projects. 我有一个Wcf Service Application
项目,该项目被不同的项目引用和使用。 Everything works fine when started Visual Studio 2012 - IIS Express is launched, hosted on localhost. 启动Visual Studio 2012-IIS Express启动并在本地主机上托管时,一切正常。
I tried to use Publish
option in right-click menu of my Wcf Service Application
. 我试图在Wcf Service Application
的右键菜单中使用Publish
选项。 I created a new profile for publishing: 我创建了一个用于发布的新配置文件:
Hitting Publish
works. 点击Publish
作品。 I can access it through internet browser through http://localhost
. 我可以通过Internet浏览器通过http://localhost
访问它。 However, when I launch my application normally, through the executable in bin/Debug - it doesn't work (app crashes). 但是,当我正常启动应用程序时,通过bin / Debug中的可执行文件-它不起作用(应用程序崩溃)。 What should I do? 我该怎么办? Can I upload it and configure it easily with IIS Manager (tried it, but get some access errors)? 我可以上载它并使用IIS管理器轻松配置它(尝试过,但出现一些访问错误)吗? I would need that in my virtual machine which doesn't have any VS installed. 我在没有安装VS的虚拟机中需要它。
What's troubling me is that in my Wcf Service Application
project's Web.config
file I have base addresses specified like this: http://localhost:8733/WcfServiceLibrary/MailingListService/
and in clients App.config
I have endpoints with addresses like this: http://localhost/MailingListService.svc
. 令我困扰的是,在Wcf Service Application
项目的Web.config
文件中,我指定的基地址是这样的: http://localhost:8733/WcfServiceLibrary/MailingListService/
在客户端App.config
我的终结点的地址是这样的: http://localhost/MailingListService.svc
。 Is it ok to have different ports and addresses (one is in root, the other in WcfServiceLibrary
)? 是否可以使用不同的端口和地址(一个在根目录中,另一个在WcfServiceLibrary
)? It works fine when run in Visual Studio. 在Visual Studio中运行时,它可以正常工作。
Web.config
: 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
: 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>
dont bother anything. 不要打扰任何事情。 just do the following: 1) enter localhost in service url field. 只需执行以下操作:1)在服务URL字段中输入localhost。 2) The name of the website you have added inside the inetmgr in the site field. 2)您在inetmgr中的site字段中添加的网站的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.