2013-10-23 56 views
0

我是WCF新手,請耐心等待。Wcf端點和配置挑戰,請幫助WCF新手

我有StudentData.svc.vb來自同一IStudentData.vb實現2個接口

的2個接口是IStudentData和IHeartbeat 心跳是1路業務合同_

我使用IIS 7.5舉辦這次服務 web.config中被

<?xml version="1.0"?> 
<configuration> 

    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5"/> 
    </system.web> 
    <system.serviceModel> 
    <bindings /> 
    <client /> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <protocolMapping> 
     <add binding="basicHttpsBinding" scheme="https" /> 
     <add binding="basicHttpBinding" scheme="http" /> 
    </protocolMapping>  
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    <!-- 
     To browse web app root directory during debugging, set the value below to true. 
     Set to false before deployment to avoid disclosing web app folder information. 
     --> 
    <directoryBrowse enabled="true"/> 
    </system.webServer> 

</ 

創建服務引用後我的app.config是

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <startup> 
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> 
    </startup> 
    <system.serviceModel> 
     <bindings> 
      <basicHttpBinding> 
       <binding name="BasicHttpBinding_IStudentData" maxReceivedMessageSize="2147483647" /> 
       <binding name="BasicHttpBinding_IHeartbeat" maxReceivedMessageSize="2147483647" /> 
      </basicHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://www.ortho-sync.com:8080/StudentData.svc" 
       binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IStudentData" 
       contract="oStudentData.IStudentData" name="BasicHttpBinding_IStudentData" /> 
      <endpoint address="http://www.ortho-sync.com:8080/StudentData.svc" 
       binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IHeartbeat" 
       contract="oStudentData.IHeartbeat" name="BasicHttpBinding_IHeartbeat" /> 
     </client> 
    </system.serviceModel> 
</configuration> 

IStudentData有一個包含我用來傳輸圖像的字節數組數據庫的類。 如果我用一個小文件,它轉移,一切工作 如果我使用一個1兆的圖像,我得到(413)請求實體過大

我與綁定點和結束點起到直到我臉色發青, 任何人都請幫忙。

回答

1

由於您尚未指定自己的默認值basicHttpBinding或創建了引用您自己的basicHttpBinding的端點(在服務中),因此您的服務正在爲綁定提取默認值。

你可以做一個綁定配置爲通過省略name屬性,像這樣綁定默認配置:

<basicHttpBinding> 
    <binding maxReceivedMessageSize="2147483647" /> 

或者,你可以明確地創建一個端點,並通過使用設置綁定配置端點所述bindingConfiguration屬性:

<endpoint address="" 
      binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_IStudentData" 
      contract="oStudentData.IStudentData" 
      name="BasicHttpBinding_IStudentData" /> 

第二個例子假定與BasicHttpBinding_IStudentData一個name定義的結合結構。

您可以在您的服務配置文件中使用其中的任意一種。

+0

確定,所以我嘗試了第一個選項amd它與文件1-10梅格在65兆文件上工作我得到以下錯誤--------------------- ------ WCFService_Tester --------------------------- 沒有端點在http://www.ortho -sync.com:8080/StudentData.svc可以接受消息。這通常是由不正確的地址或SOAP操作引起的。有關更多詳細信息,請參閱InnerException(如果存在)。 --------------------------- OK ------------------- --------所以你認爲選項2會解決這個問題,而不是選項1? –

+0

我爲綁定配置做了什麼 –

+0

我建議您將大文件分解爲塊。不要試圖在一次通話中下載65MB! – Steve