C# 将WCF Web服务从文件系统部署到IIS
如果要在IIS中部署此服务,我需要执行任何特殊操作,现在我将从visual studio将站点发布到文件系统,然后在IIS中创建应用程序 我可以在web浏览器中浏览到.svc文件,但我无法调用任何操作 这是Web.configC# 将WCF Web服务从文件系统部署到IIS,c#,web-services,wcf,iis,C#,Web Services,Wcf,Iis,如果要在IIS中部署此服务,我需要执行任何特殊操作,现在我将从visual studio将站点发布到文件系统,然后在IIS中创建应用程序 我可以在web浏览器中浏览到.svc文件,但我无法调用任何操作 这是Web.config <?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> &l
<?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>
这就是我的缺点
[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文件。提前感谢您的帮助。有时,您需要调整已部署网站的应用程序池,以查看正确的框架。在我的例子中,它几乎总是V2,而我需要将其更改为V4。您没有编写如何尝试访问该服务。您是否使用WCF测试客户端?如果是这样,那么当您添加服务url时,它应该会起作用。测试客户端将向您显示wsHttpBinding公开的所有方法 但是,如果您试图对服务进行http REST调用,则没有端点侦听。 您还应该公开webHttpBinding端点。我还没有测试过,但这应该可以
<endpoint address="rest" binding="webHttpBinding" bindingNamespace="http://SingleWSDL/MGWS" bindingConfiguration="" name="restHttp" contract="MerlonWebServiceAPI.IService" />
然后您可以通过键入http://{serviceurl}/rest/来访问它。
希望有帮助。谢谢您的建议,但我已经将应用程序池设置为V4。您如何尝试呼叫该服务?我不是想侮辱你,但是有时候当你创建了一个错误的Web服务和一个错误的服务时,你得到了这个服务,但是它不起作用。你到底收到了什么消息?我正试图通过我的web浏览器调用该服务,但到目前为止还无法执行,svc文件宿主正常,但我无法通过浏览器调用任何方法,Mex工作正常,我可以从WCF测试客户端调用方法,但您是否尝试过其他一些显而易见的方法,如从服务器上/从服务器上检查、检查防火墙是否阻止了某些内容、关闭远程自定义错误-请参阅:、设置为安全浏览器列表等。发布您的解决方案并提供链接!如果我使用WCF测试客户端,它可以正常工作,但我的目标是能够从浏览器和测试客户端调用该方法。这是可行的,但我还必须向端点添加resfulBehavior