0

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.

Cortright
  • 1,164
  • 6
  • 19
  • Web references aren't "conventional" - they're obsolete. Why not simply try "Add Service Reference" - just to see what happens in this one case. – John Saunders Jun 11 '15 at 20:18
  • [WSCF](http://www.thinktecture.com/resourcearchive/tools-and-software/wscf) latest version ***0.7*** is from ***2007***. 'nuff said. – John Saunders Jun 11 '15 at 20:20
  • I hear ya! But we're in a situation here where "it is what it is" - if I could get a project funded to rip the whole app apart and redesign it to modern standards, that would be great but I'm sure you know how that goes. – Cortright Jun 11 '15 at 20:21
  • And to your point, the upstream web service does pull the Unicode values out of another service just fine, using a Service Ref. This piece is just the old man on the block. Unicode characters were pretty well established in 2007, it seems like this shouldn't be a stretch. – Cortright Jun 11 '15 at 20:22
  • Like I said: create a test application to call this one service with "Add Service Reference" - just to see if it works. – John Saunders Jun 11 '15 at 20:23
  • I should have mentioned this in the original post, but 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, so be it - but I'm hoping we don't have to do that. – Cortright Jun 11 '15 at 20:32
  • Please update your question with that last information. It's important that a Service Reference returns the data correctly, but that WSCF does not. Possibly due to being from 2007 and still not yet verson 1. – John Saunders Jun 11 '15 at 20:40

0 Answers0