设计WCF服务以使用字节数组推送数据参数?

时间:2012-02-01 10:58:34

标签: sql-server database wcf wcf-client

我设计了WCF服务,其操作合同可以将数据存储在SQL Server数据库中。操作契约采用dataID,dataDescrip。,dataType和(byte array)数据内容等参数。字节数组最初是一个必须存储在数据库中的文件。

我在Web表单客户端应用程序(引用WCF服务)中使用WCF服务来发送数据,但是当我将文件> 40 kb作为带有其他参数的字节数组发送时,它返回错误的请求400错误。当我发送小于30KB左右的文件时,数据成功存储在DB中,不会返回错误。

我认为这与大数据流有关,并且在web.config中将大小更改为更大的数字。我试图改变客户端应用程序Web配置中的大小,但没有运气。还将编码标记更改为返回不匹配客户端和服务绑定的MTOM。我正在使用wsHttpBinding。

不确定问题是什么。 我看过:http://msdn.microsoft.com/en-us/library/ms733742.aspx 但是如何在保存数据到数据库的同时更改当前的wcf服务?

我的服务器配置文件,来自服务库的App.config是:

 <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <compilation debug="true" />

  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="IncidentServiceLibrary.IncDataService">
        <endpoint address="" binding="wsHttpBinding" contract="IncidentServiceLibrary.IIncDataService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/IncidentServiceLibrary/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="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="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <connectionStrings>
  .....
  </connectionStrings>
</configuration>

客户端配置文件,客户端中的Web.config我从以下地址调用我的服务:

...
  <system.webServer>
     <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IIncDataService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2000000" maxNameTableCharCount="2000000" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8732/Design_Time_Addresses/IncidentServiceLibrary/Service1/" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IIncDataService" contract="IncServiceReference1.IIncDataService" name="WSHttpBinding_IIncDataService">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /></system.serviceModel>
</configuration>

0 个答案:

没有答案