I try to connect to the NetSuite OpenAir API from a .NET console application using a WCF client. I generated the proxy by adding a service connection and using the following WSDL: http://sandbox.openair.com/wsdl.pl?wsdl&style=document
Logging in and reading data works fine as long as the HTTP response does not exceed a specific size. When that happens a System.IO.InvalidDataException occurs. The exception message is "Block length does not match with its complement".
These are the exception details:
System.IO.InvalidDataException
HResult=0x80131501
Message=Block length does not match with its complement.
Source=mscorlib
StackTrace:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at TestService.OASandbox.OAirServiceHandler.read(readRequest1 request)
at TestService.OASandbox.OAirServiceHandlerClient.TestService.OASandbox.OAirServiceHandler.read(readRequest1 request) in TestService\Connected Services\OASandbox\Reference.cs:line 43089
at TestService.OASandbox.OAirServiceHandlerClient.read(SessionHeader SessionHeader, ReadRequest[] method) in TestService\Connected Services\OASandbox\Reference.cs:line 43096
at TestService.Program.Main() in TestService\Program.cs:line 105
I used Fiddler to find out what the turning point is. It appears that the exception is raised when the Content-Length of the HTTP response is larger than 10000 bytes. The response itself is completely intact: when I analyze it using Fiddler it can be deciphered (as it is a SSL connection) and the full XML which is sent back by OpenAir is revealed. So it has to be a problem with the .NET code.
The WCF bindings are defined in my app.config as follows:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="OAirServiceSoapBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<security mode="Transport" />
<readerQuotas maxDepth="200" maxStringContentLength="83886089" maxArrayLength="163841" maxBytesPerRead="2147483647" maxNameTableCharCount="16384"/>
</binding>
<binding name="OAirServiceSoapBinding1" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxDepth="200" maxStringContentLength="83886089" maxArrayLength="163841" maxBytesPerRead="2147483647" maxNameTableCharCount="16384"/>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://sandbox.openair.com/soapdoc" binding="basicHttpBinding"
bindingConfiguration="OAirServiceSoapBinding" contract="OASandbox.OAirServiceHandler"
name="OAirService" />
</client>
</system.serviceModel>
Looking at the exception it appears that it has something to do with the DEFLATE decompression algorithm, which is internally being called by WCF. It seems like some buffer overflow occurs. I could define a custom binding and disable compression, but I would like to keep that as a last resort.
Any clues how to troubleshoot this issue? Any help is highly appreciated!
I am using the NetSuite SuiteTalk WSDL. I add this as a web reference and it is then added as a setting to "applicationSettings" in my config file:
I think the problem is that your binding to the SOAP service only allows for a certain size of data to be returned. If the WSDL is added as a web reference, this restriction should not apply. I added mine as follows:
1) Right click on "References" in your WCF service and select "Add Service Reference".
4) Paste your WSDL reference and click on the arrow next to the text field. Wait for the WSDL to appear in the text block and click "add reference".:
I hope this helps!
User contributions licensed under CC BY-SA 3.0