views:

26

answers:

1

We are receiving a message from a WCF call as GZip data, but the code is expecting XML.

I am working on a PDA that communicates with a WCF web service. The response from the service is SOAP format compressed using gzip.

Because we're working in CF3.5 we're having to generate the service client proxy using the NetCFSvcUtil.exe utility program.

This is the part of the generated code in CFClientBase where the error is raised.

Private Function getReply(ByVal msg As System.ServiceModel.Channels.Message) As System.ServiceModel.Channels.Message
    If (Me.RequestChannelFactory Is Nothing) Then
        'transport doesn't support requests
        Throw New System.NotSupportedException
    End If
    Dim requestChannel As System.ServiceModel.Channels.IRequestChannel
    System.Threading.Monitor.Enter(Me.RequestChannelFactory)
    Try 
        requestChannel = Me.RequestChannelFactory.CreateChannel(Me.remoteAddress)
    Finally
        System.Threading.Monitor.Exit(Me.RequestChannelFactory)
    End Try
    requestChannel.Open
    Try 
        Return requestChannel.Request(msg)  
    Finally
        If (requestChannel.State = System.ServiceModel.CommunicationState.Opened) Then
            requestChannel.Close
        End If
    End Try
End Function

On the line requestChannel.Request(msg) the response is gzipped, but it throws an exception because it is expecting xml.

It's falling over with the message: "There is a problem with the XML that was received from the network. See inner exception for more details."
Inner Exception: "'', hexadecimal value 0x1F, is an invalid character. Line 1, position 1."

I've run out of ideas on this, any help/advice would be very welcome.

UPDATE:
I gave up trying to do it this way - ran out of time.
In the end I changed my bindings to basicHTTPBinding, added a web reference via Visual Studio, then did it the way GôTô suggested. Trying to do anything beyond the most basic things between WCF and compact framework is such a pain.

A: 

Have you tried this solution:

On the client side, you can hook on the DataServiceContext.SendingRequest event to enable AutoDecompress on the request

((System.Net.HttpWebRequest)e.Request).AutomaticDecompression = (System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate);

GôTô
Thanks for the suggestion. I've had a go but I don't know how I can, the auto-generated code is using System.ServiceModel.Channels.Message rather than System.Data.Services.Client.HttpWebRequest?
Martin