Extending SoapHttpClientProtocol to correct faulty server Content-Length

965 views Asked by At

Recently I got the need to access a web service created using SOAP::Lite. It's really messy to use since there's no WSDL, it doesn't return reasonable datatypes etc. so I started out using the provided sample code.

Right from the start I got problems, requests were timing out. Sometimes often, sometimes more seldom but never entirely without problem. After using Fiddler to sniff the traffic and searching it seems like there is/was a bug with SOAP::Lite that messed up the header Content-Length when dealing with UTF-8 encoded data. This seems reasonable since my analysis points to the timeouts being caused by the client waiting for more data (Content-Length) while the server said it was done (real data).

So now I need a way to counter this erroneous header field and either:

  1. Provide the correct Content-Length or
  2. Pad the payload to match the Content-Length

Problem is, I never get the chance to use a SoapExtension or any other modification since Invoke() eventually throws an IoException or WebException before parsing commences. Also, the WS is not mine and pretty unchangable, I presume.

I also tried overriding the SoapHttpClientProtocol.GetWebResponse() to do an async request but that didn't help either since I couldn't get hold of the ResponseStream before calling HttpWebRequest.EndGetResponse() and that one always threw an exception.

Does anyone have an idea how I could approach this?

UPDATE: by now I've also tried WCF and came across this post at MSDN - the answer is not very uplifting. Basically, this happens far too deep in the plumbing to be accesible by user code. My best bet now seems to be to use a Fiddler script to correct the Content-Length header, perhaps not trivial since this WS is only available by HTTPS.

/Dan

0

There are 0 answers