Organizational Research By

Surprising Reserch Topic

dealing with incorrect http header body size values

dealing with incorrect http header body size values  using -'c#,web-services,magento,http-headers'

Using C# ASP.NET MVC, when calling a webservice on a Magento site:

Sometimes a Magento site will send wrong HTTP headers, specifically the body-size header saying that the body is bigger than it really is.  For example it might say body-size=1000, but the body only consists of 999 bytes.  Despite the header being incorrect, the body is correct so I would still like to be able to process it.

Now when I try to read that response in C#

var invoiceInfo = _magentoService.salesOrderInvoiceInfo(sessionId, invoiceId);

It throws an exception:

Connection closed by remote host

Which makes sense kindof, because its trying to read the 1000th byte but its not there.  And to make it worse, the code that reads the body is buried deep within the .NET framework, so I cant change it:

[System.Web.Services.Protocols.SoapRpcMethodAttribute("urn:Mage_Api_Model_Server_V2_HandlerAction", RequestNamespace="urn:Magento", ResponseNamespace="urn:Magento")]
[return: System.Xml.Serialization.SoapElementAttribute("result")]
public salesOrderInvoiceEntity salesOrderInvoiceInfo(string sessionId, string invoiceIncrementId) {
    object[] results = this.Invoke("salesOrderInvoiceInfo", new object[] {
                invoiceIncrementId}); // exception thrown here
    return ((salesOrderInvoiceEntity)(results[0]));

I can't change the Magento site, or fix whatever problem is causing this (its a 3rd parties webserver).

Is there anything I can do to change the behavior of my own C# code?  I would like to be able to somehow force it to stop when it reaches the end of the body and ignore this exception if this case arises

asked Oct 11, 2015 by sandeep bhadauria
0 votes

Related Hot Questions

1 Answer

0 votes
answered Oct 11, 2015 by bhavin