2014-04-30 67 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