2012-12-09 78 views
1

我有一個Wcf Service Application項目被引用並在不同的項目中使用。啓動時一切正常Visual Studio 2012 - 在本地主機上啓動IIS Express。Visual Studio 2012 + IIS 8.0 =如何在本地主機上部署WCF服務?

我試圖在我的Wcf Service Application的右鍵菜單中使用Publish選項。我創建了一個新的配置文件進行發佈:

Connection settings Settings

擊中Publish作品。我可以通過互聯網瀏覽器通過http://localhost訪問它。但是,當我正常啓動我的應用程序時,通過bin/Debug中的可執行文件 - 它不起作用(應用程序崩潰)。我該怎麼辦?我可以上傳它並使用IIS管理器輕鬆配置它(嘗試它,但遇到一些訪問錯誤)?我需要在我的虛擬機中沒有安裝任何VS。

什麼是困擾我的是,在我的Wcf Service Application項目的Web.config文件我有這樣的指定基地址:http://localhost:8733/WcfServiceLibrary/MailingListService/和客戶App.config我有端點與這樣的地址:http://localhost/MailingListService.svc。有沒有不同的端口和地址(一個在根目錄中,另一個在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=&quot;Data Source=(local)\SQLEXPRESS;Initial Catalog=Newsletter;Integrated Security=True;Pooling=False;MultipleActiveResultSets=True&quot;" 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> 
+1

我忘了細節,所以只有一個評論。您需要讓客戶端指向IIS並更新端點。 – Paparazzi

+0

我這樣做了,但現在我在嘗試調用WCF服務調用時遇到'FaultException'。 '<端點地址=:當前'App.config'的端點的 實施例的 「http://localhost/MessageService.svc」 結合= 「basicHttpBinding的」 bindingConfiguration = 「BasicHttpBinding_IMessageService」 合同= 「MessageServiceReference.IMessageService」 name =「BasicHttpBinding_IMessageService」/>' – pmichna

+0

我想你需要爲mex添加一個行爲 – Paparazzi

回答

1

不打擾任何東西。只需執行以下操作: 1)在服務url字段中輸入localhost。 2)您在網站字段中的inetmgr內添加的網站的名稱。

相關問題