发送大字节数组时出错

Tah*_*aha 5 silverlight wcf

我有WCF服务,通过它我在DB中添加数据.它工作正常,但当我尝试发送大字节[]时,它返回"远程服务器返回错误:NotFound".

web.config中

    <?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="JabsBaseConnectionString" connectionString="Data Source=TAHASAGHIR-PC\SQLEXPRESS;Initial Catalog=JabsBase;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      </assemblies>
    </compilation>
    <httpRuntime maxRequestLength="2097151" useFullyQualifiedRedirectUrl="true"/>
  </system.web>
  <system.serviceModel>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
    <bindings>
      <basicHttpBinding>
        <binding name="SendLargeChat"
                 allowCookies="false"
                 bypassProxyOnLocal="false" 
                 maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 maxBufferSize="2147483647"
                 closeTimeout="10:00:00"
                 openTimeout="10:00:00"
                 receiveTimeout="10:00:00"
                 sendTimeout="10:00:00"
                 transferMode="Streamed">
          <readerQuotas 
            maxArrayLength="2147483647"
            maxBytesPerRead="2147483647"
            maxDepth="2147483647"
            maxNameTableCharCount="2147483647"
            maxStringContentLength="2147483647" />
        </binding>
      </basicHttpBinding>      
    </bindings>
    <services>
      <service name="Prototype.SendChatService" behaviorConfiguration="Prototype.SendChatServiceBehavior">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="SendLargeChat" contract="Prototype.SendChatService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>      
    </services>    
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="Prototype.SendChatServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

ServiceReferences.ClientConfig

<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>        
        <binding name="BasicHttpBinding_ISendChatService" maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <security mode="None" />
        </binding>
      </basicHttpBinding>      
    </bindings>
    <client>      
      <endpoint address="http://localhost:53756/PrototypeSite/SendChatService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISendChatService"
        contract="SendChatService.ISendChatService" name="BasicHttpBinding_ISendChatService" />
    </client>
  </system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)

请求 POST http:// localhost:53756/PrototypeSite/SendChatService.svc HTTP/1.1主机:localhost:53756连接:keep-alive参考:http:// localhost:53756/PrototypeSite/ClientBin/Prototype.xap 内容长度:1348176 soapaction:"http://tempuri.org/ISendChatService/addMsg"content-type:text/xml; charset = utf-8接受:/ User-Agent:Mozilla/5.0(Windows NT 6.1)AppleWebKit/534.24(KHTML,如Gecko)Chrome/11.0.696.68 Safari/534.24 Accept-Encoding:gzip,deflate,sdch Accept-Language: en-US,en; q = 0.8 Accept-Charset:ISO-8859-1,utf-8; q = 0.7,*; q = 0.3

响应 HTTP/1.1 400错误请求服务器:ASP.NET开发服务器/ 10.0.0.0日期:2011年5月26日星期四17:48:00 GMT X-AspNet-版本:4.0.30319缓存控制:私有内容长度:0连接:关闭

Ali*_*tad 0

抱歉我的答案是错误的!!忽略它

几个小时后我会删除它,只允许有评论的人看到它。

不要在 SOAP 中发送字节数组。

每个字节将被传输为<byte>128</byte>或类似,这意味着平均需要 10 倍以上的时间。

请改用base64字符串 - 因此将您的属性定义为字符串并将其填充为 base64 字符串。