나는이 오류를 찾지 만 지금까지는 행운을 찾지 못했습니다.WCF REST 서비스에 큰 xml 업로드 -> 400 잘못된 요청
그래서 나는이 Web.config의
<system.serviceModel>
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://www.mywebsite.com/"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<services>
<service behaviorConfiguration="ServiceBehavior" name="UploadService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
contract="IUploadService">
<identity>
<dns value="http://www.mywebsites.com/" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior" maxReceivedMessageSize="4194304">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
내 클라이언트에 서비스를 클라이언트에 나는이 구성을
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IUploadService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:30:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="4194304"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:30:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://www.mywebsite.com/UploadService.svc"
binding="basicHttpBinding" bindingConfiguration="" contract="IUploadService"
name="WSHttpBinding_IUploadService">
<identity>
<dns value="http://www.mywebsite.com/" />
</identity>
</endpoint>
</client>
을 가지고 있고 나는 다음과 같이 파일을 업로드하십시오. -
using (Stream stream = new FileStream(strFilePath, FileMode.Open, FileAccess.Read))
{
try
{
using (UploadServiceClient upc = new UploadServiceClient())
{
upc.UploadFile(stream);
}
}
catch (Exception exc)
{
}
}
작은 파일의 경우 잘 작동하지만 큰 XML 파일의 경우 400 개의 잘못된 요청으로 실패합니다. 이 설정을 변경하여 전송할 큰 XML 파일을 얻으려면 어떻게해야합니까? 여러분의 도움과 시간에 대한
감사
업데이트] 클라이언트의 app.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding_IUploadService" receiveTimeout="00:20:00"
bypassProxyOnLocal="true" maxBufferSize="4194304" maxReceivedMessageSize="4194304"
messageEncoding="Mtom" transferMode="Streamed">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security>
<transport>
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://www.mywebsite.com/UploadService.svc"
binding="basicHttpBinding" bindingConfiguration="" contract="IUploadService"
name="basicHttpBinding_IUploadService">
<identity>
<dns value="http://www.mywebsite.com/" />
</identity>
</endpoint>
</client>
예 둘 다 4194K이고 메시지가 4G보다 작습니다. – Johann
클라이언트 측의 app.config 파일을 변경하고 basicHTTPBinding을 추가했지만 여전히 동일한 오류가 발생합니다. – Johann
basicHttpBinding 요소를 교체하십시오. 하나는 위의 업데이트에서 클라이언트 구성 파일에 사용 된 web.config 서비스와 일치해야합니다. 그것이 작동하든 그렇지 않든, 우리는 클라이언트와 서비스가 동일한 구성을 사용하고 있음을 알게 될 것입니다. 현재 web.config에 basicHttpBinding 요소가 없으면이 변경으로 문제가 해결됩니다. –