2015-08-26 152 views
1

我們有設計AJAX - 爲我們的移動應用程序啓用WCF Web服務。 Web服務方法以JSON格式返回數據。我們正在觀察延遲調用Web服務並將其綁定到移動小部件。數據大小約爲50K。提高WCF性能

根據Code Project,我們已經對WCF Web服務的web.config文件進行了更改。

同樣,在下面的一個計算器question之後,我們試圖增加消息大小。現在,問題在於我們應如何將更改應用到我們當前的web.config文件中,以便增加郵件大小。我們正在使用默認的NET 4.0設置。另外,我們是否需要在我們的客戶端web.config文件中定義終點?有人可以提供客戶端的web.config?

我們目前的服務器web.config設置爲:

<?xml version="1.0" encoding="utf-8"?> 

<configuration> 
<system.web> 
<compilation debug="true" targetFramework="4.0" /> 
<identity impersonate="false" /> 
<webServices> 
    <protocols> 
    <add name="HttpGet"/> 
    <add name="HttpPost"/> 
    </protocols> 
</webServices> 
</system.web> 

<system.serviceModel> 
<diagnostics performanceCounters="All"></diagnostics> 
<behaviors> 

    <serviceBehaviors> 
    <behavior name="ServiceBehavior"> 

     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 

     <!--Increase WCF Performance--> 
     <serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100"/>  

    </behavior> 
    </serviceBehaviors> 

    <endpointBehaviors> 
    <behavior name="MobileService.webHttpBehavior"> 
     <enableWebScript />   
    </behavior>   
    </endpointBehaviors> 
</behaviors> 

<!--Increase WCF Performance--> 
<bindings> 
    <basicHttpBinding> 
    <binding name="basicHttp" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"> 
     <readerQuotas maxDepth="32" maxArrayLength="20000000" maxStringContentLength="20000000"/>    
    </binding>   
    </basicHttpBinding> 
</bindings> 

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 

<services> 
    <service name="MobileWCFService.Service1" behaviorConfiguration="ServiceBehavior"> 
    <endpoint address="" binding="webHttpBinding" contract="MobileWCFService.Service1" behaviorConfiguration="MobileService.webHttpBehavior" />   
    </service> 
</services> 

</system.serviceModel> 

</configuration> 
+0

爲什麼你有'basicHttpBinding'的定義?除非您公開SOAP端點,否則它將不會被使用(並且您指定的設置將不會被使用,因爲它不會被設置爲默認綁定,也不會被分配給特定的端點)。如果您需要增加「webHttpBinding」的最大消息大小,請爲該方案創建一個默認綁定,或者定義一個綁定並通過'bindingConfiguration'屬性將其分配給端點。 – Tim

+0

@Tim請您提供您的解釋代碼。另外,我是否也需要在客戶端應用類似的web.config。感謝您的答覆。 – Programmer

+0

@Tim你能迴應你的評論嗎? – Programmer

回答

1

任何人都可以證實,如果我申請的變化是有效還是無效,並標記有確認的答案?

<system.serviceModel> 
<diagnostics performanceCounters="All"></diagnostics> 
<behaviors> 

    <endpointBehaviors> 
    <behavior name="MobileService.webHttpBehavior"> 
     <enableWebScript /> 
    </behavior> 
    </endpointBehaviors> 

    <serviceBehaviors> 
    <behavior name="ServiceBehavior"> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 

     <!--Increase WCF Performance--> 
     <serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100"/>  

    </behavior> 
</serviceBehaviors>  
</behaviors> 

<!--Increase WCF Performance--> 
<bindings> 
    <webHttpBinding> 
    <binding name="webHttp" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"> 
     <readerQuotas maxDepth="32" maxArrayLength="20000000" maxStringContentLength="20000000"/> 
    </binding> 
    </webHttpBinding> 
</bindings> 

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 

<services> 
    <service name="MobileWCFService.Service1" behaviorConfiguration="ServiceBehavior"> 
    <endpoint address="" binding="webHttpBinding" contract="MobileWCFService.Service1" behaviorConfiguration="MobileService.webHttpBehavior" bindingConfiguration="webHttp" />   
    </service> 
</services>