locked
Does HttpTransportBindingElement support chunked transfer encoding? RRS feed

  • Question

  • I'm developing an application in .Net Compact Framework that uses WCF to communicate with a Web Service that runs in Java with the Glassfish application server. I've created a CustomBinding with only a HttpTransportBindingElement. The request is sent correctly, and the WS receives the object without any problem, but the client can't receive the response, throwing an exception when tries to deserialize the SOAP message. The exception message says that the XML is not well formed, because a declaration is needed when the encoding is not UTF-8. Of course, the problem is that the chunking encoding adds a few bytes before the SOAP Envelope. My question is that if HttpTransportBindingElement supports http chunking, and if not, what can I do?

    Here is the conversation between WS and client:

    POST /OTWSServer/objectTransporterWSDLService HTTP/1.1
    Content-Type: application/soap+xml; charset=utf-8
    Content-Length: 835
    Connection: Keep-Alive
    Expect: 100-continue
    Host: xxx.xxx.xxx.xxx:YYYY

    <s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><a:Action s:mustUnderstand="1">Send</a:Action><service xmlns="http://gsi.dec.usc.es/pmic/objectTransporterWSDL">medim</service><a:To s:mustUnderstand="1">http://193.144.84.126:13611/OTWSServer/objectTransporterWSDLService</a:To></s:Header><s:Body xsi:type="servicemodel.binaryData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><binaryData xmlns:xsd="http://www.w3.org/2001/XMLSchema"><data>ARf+</data><fecha>2008-10-28T09:31:07Z</fecha><listasAsistentes><asistentes><apelidos>Teijeiro Campo</apelidos><direccion>Mudia, 8, Bazar, Castro de Rei, Lugo</direccion><idade>21</idade><nome>Tom..s</nome></asistentes><procedencia>Pobra do broll..n</procedencia></listasAsistentes></binaryData></s:Body></s:Envelope>


    HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    Accept: application/soap+xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Content-Type: application/soap+xml;charset=utf-8
    Transfer-Encoding: chunked
    Date: Tue, 28 Oct 2008 09:31:15 GMT

    f6
    <?xml version="1.0" ?><env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Header><pns:service xmlns:pns="http://gsi.dec.usc.es/pmic/objectTransporterWSDL">medim</pns:service></env:Header><env:Body>true</env:Body></env:Envelope>
    0


    Thank you very much!
    Tuesday, October 28, 2008 9:54 AM

Answers

  • Finally, the problem is not with HTTP chunking. The problem is that the XML declaration has no charset attribute, and then an exception is thrown. The solution I've adopted is to create a custom MessageEncodingBindingElement that decorates standard TextEncodingBindingElement, and before call the ReadMessage of the standard encoder, I skip the xml declaration. Is not very much elegant, but it works!

    Thanks for the reply
    • Marked as answer by Nicholas Allen Tuesday, November 4, 2008 12:45 AM
    Thursday, October 30, 2008 12:03 PM

All replies

  • As far as I know this works on the regular .NET Framework... So this may be specific to the Compact Framework - you will probably have better luck with your question on a forum dedicated to NetCF.


    Eugene Osovetsky, Program Manager, XML Messaging / Serialization, Microsoft Corp.
    • Proposed as answer by Eugene Osovetsky Wednesday, October 29, 2008 11:04 PM
    • Unproposed as answer by Nicholas Allen Tuesday, November 4, 2008 12:45 AM
    Wednesday, October 29, 2008 11:03 PM
  • Finally, the problem is not with HTTP chunking. The problem is that the XML declaration has no charset attribute, and then an exception is thrown. The solution I've adopted is to create a custom MessageEncodingBindingElement that decorates standard TextEncodingBindingElement, and before call the ReadMessage of the standard encoder, I skip the xml declaration. Is not very much elegant, but it works!

    Thanks for the reply
    • Marked as answer by Nicholas Allen Tuesday, November 4, 2008 12:45 AM
    Thursday, October 30, 2008 12:03 PM