When trying to call out to a WCF service, I was receiving the error: The remote server returned an unexpected response: (400) Bad Request. If you’re seeing the same thing, I might be able to help.
Are you attempting to send any sizable amount of data across the wire to the service? If yes, then the likely problem is that the remote service’s config needs to be updated to accept larger requests. Update your service’s binding in the
[...] <system.serviceModel> <bindings> <wsHttpBinding> <binding name="wsHttp" maxReceivedMessageSize="50000000" maxBufferPoolSize="50000000" messageEncoding="Mtom" > <readerQuotas maxDepth="500000000" maxStringContentLength="500000000" maxArrayLength="500000000" maxBytesPerRead="500000000" maxNameTableCharCount="500000000" /> <security mode="None"></security> </binding> </wsHttpBinding> </bindings> [...]
By default, the max size for most of the binding properties are around 64KB. If you think your request is larger, try debugging to find out.
Note: Make sure you actually change the config in the remote location (not just the one in your calling assembly).