Calling a service link results in an error "The remote server responded with an error: (400)" Bad request "

edit3: I added webconfig from server

edit2: I started the log and this error message:

Exceeded maximum message size quota for incoming messages (65536). To increase the quota, use the MaxReceivedMessageSize property in the corresponding binding element.

Since he does this only for the 2000 record test, but not for the 200 test, I decided to change the application settings, assuming that he passed the standard limit of 65535. Unfortunately, this did not help and did not look, I found that where there are two others The type of origin for this problem is the settings of the service itself and one at the endpoint.

The developer of the service says that his side is in order and that the problem is simply the setting on my side that he once made himself, but could not remember.

I added end-user application configuration data, which said that if the endpoint does not match, a default endpoint will be created using the default settings and thus using the 65K limit. if this is a problem, how to solve this problem?

If you need any additional code or information, let me know.

edit: I added changes to the application configuration as suggested

<behaviors> <endpointBehaviors> <behavior name="MetadataBehavior"> <dataContractSerializer maxItemsInObjectGraph="2147483647"/> </behavior> </endpointBehaviors> </behaviors> <binding name="BasicHttpBinding_IMailSortService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> <security mode="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> <endpoint behaviorConfiguration="MetadataBehavior" address="http://remote-access/MailSort/MailSortService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMailSortService" contract="MailSortServiceReference.IMailSortService" name="BasicHttpBinding_IMailSortService" /> 

webconfig on server

 <?xml version="1.0"?> <configuration> <appSettings> <add key="FilePath" value="\\162.27.51.43\DOWNLOAD\RPA\Mailsort\Auto" /> </appSettings> <system.web> <compilation debug="true" targetFramework="4.0" /> <httpRuntime maxRequestLength="2147483647" /> </system.web> <system.diagnostics> <sources> <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true"> <listeners> <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData= "c:\logs\Traces.svclog" /> </listeners> </source> </sources> </system.diagnostics> <system.serviceModel> <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"/> <dataContractSerializer maxItemsInObjectGraph="2147483647"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration> 
+4
source share
3 answers

The solution was the application configuration parameter below.

When sending large messages through WCF, the following code must be added to both web.config on the server and app.config in the local application. After that, server and local configurations will use custom message sizes.

Include inside the section.

 <protocolMapping> <remove scheme="http" /> <add scheme="http" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMailSortService" /> </protocolMapping> 
0
source

Comments got too big, passing in the answer:

Did you point your endpoint to the behavior?

 <endpoint address="http:blah/MyService.svc" behaviorConfiguration="MyServiceBehavior". 

Current configuration works 200, but not 2000? If so, do you try to change your binding to the maximum, as shown below, and see if it helps (you will also reflect the same attributes at the end of the service)?

 <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> 
+1
source

I do not see comments for this post.

Instead of commenting, I give an answer.

According to the message below, make sure that you are using the full domain space for the service contract.

http://forums.silverlight.net/forums/p/191589/442378.aspx

 <endpoint behaviorConfiguration="MetadataBehavior" address="http://remote-access/MailSort/MailSortService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMailSortService" contract="FullyQualifiedNamespace.IMailSortService" name="BasicHttpBinding_IMailSortService" /> 
0
source

Source: https://habr.com/ru/post/1345548/


All Articles