SoapHttpClientProtocol extension to fix a failed Content-Length server

Recently, I needed access to a web service created using SOAP :: Lite. This is really messy to use, since there is no WSDL, it does not return reasonable data types, etc., so I started using the provided code example.

From the very beginning, I had problems, requests were delayed. Sometimes often, sometimes more rarely, but not always without problems. After using Fiddler to sniff traffic and search, it seems that there is / was an error with SOAP :: Lite that messed up the Content-Length header when working with UTF-8 encoded data. This seems reasonable, as my analysis indicates that the wait time is due to the client waiting for more data (Content-Length) while the server said it was done (real data).

So now I need a way to meet this error header field and either:

  • Specify the correct content length or
  • Configure the payload to match Content-Length

The problem is that I never get the opportunity to use SoapExtension or any other modification, since Invoke () ultimately throws an IoException or WebException before starting the analysis. I believe that WS is not mine and is pretty unchangeable.

I also tried to override SoapHttpClientProtocol.GetWebResponse () to make an asynchronous request, but that did not help, since I could not get a ResponseStream before calling HttpWebRequest.EndGetResponse () and that it always threw an exception.

Does anyone have an idea how I could approach this?

UPDATE: now I also tried WCF and came across this post on MSDN - the answer is not very uplifting. Basically, this happens too deep in the plumbing to be accessible by user code. Now, it’s best to use a Fiddler script to fix the Content-Length header, which may not be trivial, since this WS is only available for HTTPS.

/ Dan

+4
source share

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


All Articles