【发布时间】:2010-10-14 11:57:05
【问题描述】:
我们正在接收来自 WCF 调用的 GZip 数据消息,但代码需要 XML。
我正在开发与 WCF Web 服务通信的 PDA。来自服务的响应是使用 gzip 压缩的 SOAP 格式。
因为我们在 CF3.5 中工作,我们必须使用 NetCFSvcUtil.exe 实用程序生成服务客户端代理。
这是 CFClientBase 中生成的代码中引发错误的部分。
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
在 requestChannel.Request(msg) 行上,响应被压缩,但它抛出异常,因为它需要 xml。
出现以下消息:“从网络接收的 XML 存在问题。有关详细信息,请参阅内部异常。”
内部异常:“'',十六进制值 0x1F,是无效字符。第 1 行,位置 1。”
我已经没有这方面的想法了,非常欢迎任何帮助/建议。
更新:
我放弃了尝试以这种方式进行 - 没时间了。
最后,我将绑定更改为 basicHTTPBinding,通过 Visual Studio 添加了 Web 引用,然后按照 GôTô 建议的方式进行操作。尝试在 WCF 和紧凑框架之间做任何超出最基本的事情的事情真是太痛苦了。
【问题讨论】:
标签: wcf compact-framework gzip