2012-04-14 4 views
1

나는이 오류를 일주일 동안 사용해 왔지만 검색 한 후에도이를 해결할 수 없습니다. 오류이다Set MaxReceivedMessageSize (원격 서버에서 예기치 않은 응답을 보냈습니다 : (400) Bad Request.) web.config가 작동하지 않습니다.

원격 서버에서 예기치 않은 응답을 반환 (400) 나쁜 요청.

Windows 전화 앱에서 WCF를 통해 이미지를 저장하려고합니다. 기본값보다 높은 MaxReceivedMessageSize을 설정해야합니다. 나는 운을 제외한 모든 것을 시도했다!

web.config 파일 (WCF 서비스) 내 Windows 전화 응용 프로그램에

<configuration> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IService1" 
       maxReceivedMessageSize="2147483647" 
       maxBufferSize="2147483647" 
       maxBufferPoolSize="2147483647" 
       hostNameComparisonMode="StrongWildcard" 
       receiveTimeout="00:10:10" 
       sendTimeout="00:10:00" 
       openTimeout="00:10:00" 
       closeTimeout="00:10:00" 
       transferMode="Buffered" 
       messageEncoding="Text" 
       textEncoding="utf-8" 
       bypassProxyOnLocal="false" 
       useDefaultWebProxy="true" > 
      <readerQuotas 
      maxDepth="2147483647" 
      maxStringContentLength="2147483646" 
      maxArrayLength="2147483647" 
      maxBytesPerRead="2147483647" 
      maxNameTableCharCount="2147483647"/> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <services> 
    <service name="Service1" behaviorConfiguration="Service1Behavior"> 
     <endpoint 
      address="" 
     binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_IService1" 
      contract="IService1" /> 
     <endpoint 
      address="mex" 
      binding="mexHttpBinding" 
      contract="IMetadataExchange" 
     /> 
    </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="Service1Behavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     <behavior> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
</configuration> 

에만있는 ServiceReferences.ClientConfig

<configuration> 
    <system.serviceModel> 
     <bindings> 
     <basicHttpBinding> 
      <binding name="BasicHttpBinding_IService1" maxBufferSize="2147483647" 
        maxReceivedMessageSize="2147483647"> 
       <security mode="None" /> 
      </binding> 
     </basicHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://localhost:1772/Service1.svc" 
       binding="basicHttpBinding" 
       bindingConfiguration="BasicHttpBinding_IService1" 
       contract="ServiceReference1.IService1" 
       name="BasicHttpBinding_IService1" /> 
     </client> 
    </system.serviceModel> 
</configuration> 

나는 또한 코드에서 바인딩을 설정하려고 :

BasicHttpBinding binding = new BasicHttpBinding(); 
binding.MaxReceivedMessageSize = 2147483647; 
binding.MaxBufferSize = 2147483647; 

EndpointAddress endpointAddress = new EndpointAddress("http://localhost:1772/Service1.svc"); 

Service1Client proxy = new Service1Client(binding, endpointAddress); 

나는 이것을 고치는 법을 정말로 모른다. .. 그것은 서버 d와 같이 보인다. 내 web.config 파일을 idn't 사용 ??? 이 경우 어떻게 업데이트합니까?

답변

0

정말 문제인지 확인해야합니다. 시작하려면 서버 (http://blogs.msdn.com/b/madhuponduru/archive/2006/05/18/601458.aspx)의 WCF 추적을 켜고 오류가 있는지 확인하십시오.

+0

작은 이미지 (65kb 미만)를 업로드 할 수 있습니다. –

+0

많은 할당량 설정이 있습니다. 서버 추적 기능을 켜면 정확히 어느 것이 옳은지 알 수 있습니다. –

0

모든 것은 첫눈에 OK 보인다 - 나는 당신의 서비스 이름은 홀수 ....

때문에 직감이 어쩌면 서비스 설정이 포착되지 않는 한 제외하고 당신이 가지고 :

<service name="Service1" > 

귀하의 서비스 클래스 (서비스 계약을 구현하는 서비스 클래스)는 실제로 Service1이라고 불리며 어떤 네임 스페이스에도 존재하지 않습니다 ??

<service> 노드 name= 속성의 값은해야 정확히 서비스 클래스의 종류의 완전한 이름은 - 그래서 대부분,이 같은 것입니다 :

<service name="MyNamespace.Service1" > 

이든 .NET 네임 스페이스

그 이름이 일치하지 않는 경우, WCF 런타임 것에서 당신의 Service1 수준의 삶은 서비스 설정을 사용하지 않고 WCF 기본값으로 되돌려 놓습니다. 그러면 작은 파일에서는 왜 작동하는지 설명하지만 큰 파일에서는 실패합니다.

+0

이름은 Service1입니다. 내 프로젝트 이름 (네임 스페이스)은 InstantMessengerWebService입니다.

+0

@TuanPham : ' ...'로 변경하면 어떻게됩니까? 오류가 발생합니까 ?? 그렇다면 : ** 무엇 ** 오류 ??? –

관련 문제