2011-11-27 18 views
0

我有一個在C#中製作的Web服務,我想知道如何在IIS中註冊以供其他應用程序使用。我知道如何從相同的解決方案中使用它,但情況並非如此。搜索互聯網,我只找到了如何註冊一個應用程序。如何在iis註冊一個web服務?

+0

你能發佈什麼是你的錯誤。當您在IIS上發佈Web服務時,您可以使用IE瀏覽Web服務。你可以給你一些示例代碼,瞭解你的Web服務的外觀,即它是WCF服務或舊的Web服務(asmx)或REST服務 – Rajesh

回答

1

Web服務與IIS中的任何其他網站一樣被對待。只需將網站轉換爲應用程序並選擇合適的.Net框架版本即可。

+0

是的,我做了,但沒有工作:s – BlaShadow

+0

@BlaShadow - 這是正確的答案。您的網站設置正確嗎?您的網絡服務旁邊是否還有其他html/aspx文件? –

+0

@BlaShadow當它「無效」時會發生什麼事情,是否會拋出異常,返回404響應還是服務器在巨大的蘑菇雲中爆炸? –

0

爲web服務設置網站後,您需要在web.config中進行一些設置。我猜你可能會丟失他們

添加服務到web.config像下面

<services> 
    <service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour"> 
    <endpoint address="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web">   
    </endpoint> 
    </service> 
</services> 

同時添加服務行爲和終結點行爲

<serviceBehaviors> 
    <behavior name="ServiceBehaviour"> 
     <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
     <serviceMetadata httpGetEnabled="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>