2014-04-30 65 views
0

在IIS中部署此服務有什麼特別的要求,現在我將該網站從Visual Studio發佈到文件系統,然後在IIS中創建應用程序。從文件系統部署WCF Web服務到IIS

我可以瀏覽到我的Web瀏覽器中的.svc文件,但我無法調用任何操作。

這是在Web.config

<?xml version="1.0"?> 
<configuration> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <bindings>  
     <wsHttpBinding> 
     <binding name="wsHttpBinding" openTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00" 
      maxBufferPoolSize="9223372036854775807" maxReceivedMessageSize="9223372036854775807"> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
      <security mode="None" /> 
      <reliableSession enabled="true" /> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="ServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
      <dataContractSerializer /> 
     </behavior> 
     </serviceBehaviors> 
     <endpointBehaviors > 
     <behavior> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <services> 
     <service behaviorConfiguration="ServiceBehavior" name="MerlonWebServiceAPI.MGWS"> 
     <endpoint address="" behaviorConfiguration="" binding="wsHttpBinding" bindingNamespace="http://SingleWSDL/MGWS" 
      bindingConfiguration="" name="wsHttp" contract="MerlonWebServiceAPI.IService" > 
      <identity> 
      <dns value="localhost"/> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />  
     </service> 
    </services> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
</configuration> 

這是IService

[ServiceContract(Namespace = "http://SingleWSDL/MGWS")] 
public interface IService 
{ 
    [OperationContract] 
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "ActiveCalls")] 
    List<ActiveCall> GetActiveCalls(); 

    [OperationContract] 
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "PointStatus")] 
    List<PointStatus> GetPointStatus(); 

    [OperationContract] 
    bool Validate(string username, string password); 
} 

我可以轉儲如果需要感謝的完整WSDL文件事先的任何援助

+0

發佈您的解決方案,並給予鏈接! – Sajeetharan

回答

0

有時你需要只需調整您已部署的「網站」的應用程序池即可查看正確的框架。在我的情況下,它幾乎總是V2,而我需要將其更改爲V4。

+0

感謝您的建議,但我已經將應用程序池設置爲V4 – Paperwaste

+0

您打算如何致電該服務?我並不是要侮辱,但有時當你創建引用錯誤(Web服務與服務),你得到的服務,但它不起作用。你準確得到什麼信息? –

+0

我想通過我的網頁瀏覽器調用服務,但到目前爲止還沒有能夠得到它執行,svc文件主機沒關係,但我無法通過瀏覽器調用任何方法,Mex工作正常,我可以調用方法從WCF測試客戶端 – Paperwaste

0

你沒有寫你如何嘗試訪問該服務。你使用WCF Test Client嗎?如果是這樣,那麼它應該在你添加服務url時工作。測試客戶端將顯示wsHttpBinding公開的所有方法。

但是,如果您嘗試對服務進行HTTP REST調用,則沒有端點偵聽。 您還應該公開webHttpBinding端點。我沒有測試它,但這應該做

<endpoint address="rest" binding="webHttpBinding" bindingNamespace="http://SingleWSDL/MGWS" bindingConfiguration="" name="restHttp" contract="MerlonWebServiceAPI.IService" /> 

然後,你可以訪問它打字http://{serviceurl}/rest/。 希望它有幫助。

+0

如果我使用WCF測試客戶端,它工作正常,但我的目標是能夠從瀏覽器和測試客戶端調用該方法。 – Paperwaste

+0

然後爲webHttpBinding添加端點,正如我所提到的。 – pepo

+0

這工作,但我也不得不將resfulbehaviour添加到端點 – Paperwaste