[英]Deploying WCF Web Service from File System to IIS
在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>
這是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文件,在此先感謝您的幫助
有時,您只需要針對已部署的“網站”調整應用程序池即可查看正確的框架。 就我而言,幾乎總是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/
來訪問它。 希望能幫助到你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.