2014-05-12 31 views
0

我試圖使用IIS發佈我的Web服務,並且似乎存在與我的web.config有關的問題。我想最終將我的Web服務發佈到我擁有的Web主機上。我已經嘗試發佈正常的文件系統,並上傳thos文件到網絡主機,但我似乎無法讓我的service.svc迴應。我想這是因爲我的web.config這裏是代碼。如果您需要我的其他代碼,請詢問:D。就像一張紙條。當我使用Visual Studio 2012運行它們時,這些服務工作得很好。此外,我也是第一次嘗試這樣做。 :d嘗試發佈我的WCF服務以便與其他人一起使用

的Web.config

<configuration> 
    <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="HotelLock.Service1"> 
     <endpoint binding="webHttpBinding" contract="HotelLock.IService1" behaviorConfiguration="web"> 
     </endpoint> 
     </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> 
     <endpointBehaviors> 
     <behavior name="web"> 
      <webHttp/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <protocolMapping> 
     <add binding="basicHttpsBinding" scheme="https" /> 
    </protocolMapping>  
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" > 
    </serviceHostingEnvironment> 
    </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> 

我上傳的SVC,在web.config並與DLL到主機我有bin和我得到的,當我打電話的SVC是

ServiceHost Language="C#" Debug="true" Service="HotelLock.Service1" CodeBehind="Service1.svc.cs"

我似乎無法打電話給任何其他的網址。

當我試圖使用IIS作爲本地主機使用我的服務時,頁面無法加載。我已經給了iis使用webconfig的許可。但我似乎不能得到一個正常的錯誤。我只是不能加載任何東西。

+0

你的問題似乎有問題 - 是否打算在底部發布錯誤消息?因爲你應該。 – AFischbein

+0

當我將文件上傳到我擁有的主機並在任何其他控制檯上調用服務時,都會出現404錯誤。但是,如果我打電話給Service1.svc它顯示我是這樣的: <%@ ServiceHost Language =「C#」Debug =「true」Service =「HotelLock.Service1」CodeBehind =「Service1.svc.cs」%> –

回答

0

配置文件看起來OK。也許你應該檢查你通過瀏覽器調用的鏈接。鏈接應該像下面這樣:

http://www.yourdomain.com/ServiceName.ClassName.svc/UriTemplate 

對於您的項目,我認爲服務名稱是HotelLock,類名是Service1。我不知道你的代碼的UriTemplate,但你的接口(可能IService.cs)應該有這些信息(例如[WebGet(UriTemplate =「ListData」)])最後,你的鏈接看起來像http://www.yourdomain.com/HotelLock.Service1.svc/ListData

我希望它作品。

相關問題