2010-05-23 3 views
1

스트리밍에 문제가 있습니다. 내가 1킬로바이트처럼 작은 파일을 보낼 때 모든 것이 괜찮이 txt,하지만 난 1백킬로바이트의 JPG 또는 기가 바이트의 PSD와 같은 큰 파일을 보낼 때 내가 얻을 :원격 서버에서 예기치 않은 응답을 반환했습니다. (400) 스트리밍 중 잘못된 요청

The remote server returned an unexpected response: (400) Bad Request. 

내가 사용 윈도우 7, 2010 VS와 .NET 3.5 및 WCF 서비스 라이브러리

나는 이것에 내 모든 주말을 잃고 난 아직이 오류를 참조하십시오

var client = new WpfApplication1.ServiceReference1.Service1Client("WSHttpBinding_IService1"); 

     client.GetString("test"); 
     string filename = @"d:\test.jpg"; 
     FileStream fs = new FileStream(filename, FileMode.Open); 
     try 
     { 
      client.ProcessStreamFromClient(fs); 
     } 
     catch (Exception exception) 
     { 
      Console.WriteLine(exception); 
     } 

의 app.config :

/나에게

클라이언트를 도와주세요

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="StreamedHttp" closeTimeout="10:01:00" openTimeout="10:01:00" 
      receiveTimeout="10:10:00" sendTimeout="10:01:00" allowCookies="false" 
      bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferSize="65536000" maxBufferPoolSize="524288000" maxReceivedMessageSize="65536000" 
      messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed" 
      useDefaultWebProxy="true"> 

      <readerQuotas maxDepth="0" maxStringContentLength="0" maxArrayLength="0" 
      maxBytesPerRead="0" maxNameTableCharCount="0" /> 
      <security mode="None"> 
      <transport clientCredentialType="None" proxyCredentialType="None" 
      realm="" /> 
      <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary2/Service1/" 
     binding="basicHttpBinding" bindingConfiguration="StreamedHttp" 
     contract="ServiceReference1.IService1" name="WSHttpBinding_IService1" /> 
    </client> 
    </system.serviceModel> 
</configuration> 

그리고 WCF의 ServiceLibrary :

public void ProcessStreamFromClient(Stream str) 
     { 

//error occuring even this method is empty 
      using (var outStream = new FileStream(@"e:\test.jpg", FileMode.Create)) 
      { 
       var buffer = new byte[4096]; 
       int count; 
       while ((count = str.Read(buffer, 0, buffer.Length)) > 0) 
       { 
        outStream.Write(buffer, 0, count); 
       } 
      } 
     } 

의 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> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="Binding1" 
       hostNameComparisonMode="StrongWildcard" 


       maxBufferSize="65536000" 

       transferMode="Streamed" 

       bypassProxyOnLocal="false" 

       closeTimeout="10:01:00" 

openTimeout="10:01:00" receiveTimeout="10:10:00" sendTimeout="10:01:00" 

maxBufferPoolSize="524288000" maxReceivedMessageSize="65536000" messageEncoding="Text" 
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 
      <security mode="None" /> 
     </binding> 
     </basicHttpBinding> 

    </bindings> 
    <client /> 
    <services> 
     <service name="WcfServiceLibrary2.Service1"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary2/Service1/" /> 
      </baseAddresses> 
     </host> 
     <!-- Service Endpoints --> 
     <!-- Unless fully qualified, address is relative to base address supplied above --> 
     <endpoint address="" binding="basicHttpBinding" contract="WcfServiceLibrary2.IService1"> 
      <!-- 
       Upon deployment, the following identity element should be removed or replaced to reflect the 
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
       automatically. 
      --> 
      <identity> 
      <dns value="localhost"/> 
      </identity> 
     </endpoint> 
     <!-- Metadata Endpoints --> 
     <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
     <!-- This endpoint does not use a secure binding and should be secured or removed before deployment --> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
     </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 --> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
      <!-- 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> 
    </system.serviceModel> 

</configuration> 

답변

1

시도 설정 :

<serviceDebug includeExceptionDetailInFaults="true" /> 

그것은 문제가 해결되지 않습니다,하지만 당신이 오류가 발생할 수 있습니다 문제가 무엇인지 알려주는 메시지.

+0

여기에 오류가 있습니다 : public void ProcessStreamFromClient (System.IO.Stream stream) { base.Channel.ProcessStreamFromClient (stream); 그리고 만약 내 webmethod가 비어 있으면 오류가 발생합니다. – user278618

+0

작은 파일을 보내고 여전히 작동하는지 확인한 다음 파일 크기를 점차적으로 늘려 한계가있는 위치를 찾으십시오. –

+7

이것은 답변으로 표시되어 있지만 실제 해결 방법에 대한 설명은 없습니다. – jpierson

관련 문제