We use WSCF (Web Services Contract First) to create client proxies to consume another web service that we own. The web service is returning "special" characters such as ® in some of the fields. We are seeing these characters as "??" (it is actually two question mark characters, not a rendering issue) when the web service response is deserialized to an object. This deserialization seems to be done under the hood with WSCF.
In a conventional "web reference" - I've found a few posts on the net that say you can simply add this method to your Reference.vb file to alleviate this problem.
Protected Overrides Function GetWebResponse(request As System.Net.WebRequest) As System.Net.WebResponse
Dim res As System.Net.WebResponse = MyBase.GetWebResponse(request)
res.Headers.Set("Content-Type", "text-xml; charset=UTF-8")
Return res
End Function
The proxy class that WSCF generates with method stubs inherits from System.Web.Services.Protocols.SoapHttpClientProtocol so I am able to put this same method in there. I had high hopes that this would resolve our problem, but in debugging through the web service call, the GetWebResponse function is never called.
The "closest" I can get to getting the response in code is as follows (this is generated code). Arg is the response and the deserialization has already botched the "special" characters.
Private Sub Onv2_0OperationCompleted(ByVal arg As Object)
If (Not (Me.v2_0CompletedEvent) Is Nothing) Then
Dim invokeArgs As System.Web.Services.Protocols.InvokeCompletedEventArgs = CType(arg, System.Web.Services.Protocols.InvokeCompletedEventArgs)
RaiseEvent v2_0Completed(Me, New v2_0CompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState))
End If
End Sub
Short of ripping out WSCF (which would be a pretty huge effort for this application) - does anyone have any suggestions for how to fix this?
I've verified the web service we're consuming is returning the characters correctly, using Fiddler. I also just created a service reference to it in a test harness and it works fine. If I have to go back to management and say we need to update our web references to be modern service references, so be it - but I'm hoping we don't have to do that.