我已經在這裏搜索了所有可用的問題,我不知道問題是特定於我的配置還是我錯過了一些東西。Windows服務調用WCF服務(網頁http配置)
背景:
我使用HTTPS綁定託管在IIS 7的WCF服務。該服務用於發送/接收大型對象。一個Windows服務使用這個WCF服務將這些大對象發送給它,但是我得到了400錯誤請求錯誤。我在服務中啓用了跟蹤,錯誤是「傳入郵件的最大郵件大小限額(65536)已被超出」。以下是WCF和Windows服務配置以及如何使用wcf服務。
WCF服務配置。
<system.web>
<httpRuntime maxRequestLength="2147483647" />
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="basicWebHttp" allowCookies="true" closeTimeout="00:59:59" receiveTimeout="00:59:59"
sendTimeout="00:59:59"
maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None"></transport>
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="basicWebHttpBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="" behaviorConfiguration="basicWebHttpBehaviour"
binding="webHttpBinding" bindingConfiguration="basicWebHttp"
contract="labis.IVisService" name="BasicHttpBinding_IVisService" />
</client>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
該服務被稱爲像這樣:
<system.web>
<compilation debug="true" targetFramework="4.0" />
<globalization culture="mk-MK" fileEncoding="windows-1251" />
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="basicWebHttp" allowCookies="true" closeTimeout="00:59:59" receiveTimeout="00:59:59"
sendTimeout="00:59:59" maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security>
<transport clientCredentialType="None" realm="" proxyCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceTimeouts transactionTimeout="00:10:00"/>
<serviceThrottling maxConcurrentCalls="20" maxConcurrentSessions="20" maxConcurrentInstances="20" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WebHttp">
<webHttp automaticFormatSelectionEnabled="true" faultExceptionEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="" binding="webHttpBinding" bindingConfiguration="basicWebHttp"
contract="Classes.IVisService" name="BasicHttpBinding_IVisService" behaviorConfiguration="WebHttp" />
</client>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<defaultDocument>
<files>
<remove value="default.aspx" />
<remove value="iisstart.htm" />
<remove value="index.html" />
<remove value="index.htm" />
<remove value="Default.asp" />
<remove value="Default.htm" />
<remove value="Default.html" />
<add value="VisService.svc" />
</files>
</defaultDocument>
<urlCompression doDynamicCompression="false" />
</system.webServer>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing, Error"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\log\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
的服務是通過Windows服務誰具有以下配置消耗
System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => { return true; };
WebChannelFactory<IVisService> factory = new WebChannelFactory<IVisService>(
"BasicHttpBinding_IVisService",
new Uri("https://some_ip/service.svc"));
IVisService service = factory.CreateChannel();
service.PostData(large_object);
我已經啓用跟蹤,並從日誌我可以看到服務器拋出異常: 傳入消息的最大消息大小配額(65536)已被超出
我想我已經設置了這個工作所需的所有屬性,但沒有運氣。 另外在IIS配置編輯器中,我已經將system.webServer/security/requestFiltering - requestLimits屬性設置爲最大值
任何幫助?
謝謝:)
編輯1
我貼錯了端點配置元素。原來缺乏behaviorConfiguration =「WebHttp」部分,但我已經測試它包含此屬性。
我粘貼錯誤的配置。在我的配置中添加了這部分,並且錯誤仍然存在。 –
你試過里程嗎? 添加到web.config: <的httpRuntime的maxRequestLength = 「2147483647」/> –
我嘗試了,沒有幫助。這是我嘗試過的第一件事之一 –