正在将WCF Web服务从文件系统部署到IIS
本文关键字:文件系统 部署 IIS 服务 WCF Web | 更新日期: 2023-09-27 18:00:57
在IIS中部署此服务需要做什么特别的事情吗?现在我从visual studio将网站发布到文件系统,然后在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>
这是I服务
[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公开的所有方法。
但是,如果您试图对服务进行httpREST调用,则没有端点侦听。您还应该公开webHttpBinding端点。我还没有测试它,但这应该做
<endpoint address="rest" binding="webHttpBinding" bindingNamespace="http://SingleWSDL/MGWS" bindingConfiguration="" name="restHttp" contract="MerlonWebServiceAPI.IService" />
然后您可以键入http://{serviceurl}/rest/
来访问它。希望能有所帮助。