WCF和自定义文本编码 - 凌乱的业务
我在这里有一个很奇怪的WCF问题...
I have a really weird WCF problem here...
我们连接到一个肮脏的第三方Web服务;它是一个噩梦,甚至得到它,我们不得不创建一个自定义的WCF绑定,因为那些家伙决定使用ISO-8859-1作为他们的文本编码(而不是像其他人在网络上的UTF-8),和其他设置也很乱,当然没有记录在任何地方...
We're connecting to a crappy third-party web service; it was a nightmare to even get it going, we had to create a custom WCF binding since those guys decided to use "ISO-8859-1" as their text encoding (instead of UTF-8 like everyone else on the web), and the other settings were messy, too - and not documented anywhere, of course...
它已经工作好了一会儿,但突然,我们的一些数据回到了破烂。我们期望收回地方的名称,并在瑞士,其中一些有德国乌姆勒。但是过去两三个月,我们突然回来了。
It's been working ok for a while now, but suddenly, some of our data coming back in mangled up. We expect to get back names of places, and being in Switzerland, some of those have German umlauts in them. But for the past two or three months, we suddenly get back
Hünibach
而不是正确的
Hünibach
因此ü(u umlaut)被破坏。
So the ü (u umlaut) is mangled.
没有问题,我想他们最终切换到UTF-8,我改变了我的自定义绑定使用UTF-8作为其文本编码器,而不是ISO-8859-1 - 但没有运气 - 我得到:
No problem, I figured they finally switched to UTF-8, and I changed my custom binding to use UTF-8 as its text encoder instead of ISO-8859-1 - but no luck - no I'm getting:
EXCEPTION:System.ServiceModel.Security.MessageSecurityException
HTTP请求已被客户端认证方案'Basic'禁止。
EXCEPTION: System.ServiceModel.Security.MessageSecurityException
The HTTP request was forbidden with client authentication scheme 'Basic'.
什么是f该服务受到我们使用WCF的 ClientCredentials
传递的用户名/密码的保护。似乎改变文本编码不知何故弄乱了凭证! Weird .....
What the f????? The service is protected by a username/password which we pass in using the ClientCredentials
of WCF. Seems that changing the text encoding somehow messes up the credentials !?!?! Weird.....
OK - 回到ISO-8859-1,我只是试图将响应负载解释为UTF-8 - 再没有运气: (尝试使用UTF-16,UTF-32,UTF-7 even,Unicode,BigEndianUnicode - 所有无法使用。
OK - back to ISO-8859-1, and I just tried to interpret the response payload as UTF-8 - again no luck :-( Tried with UTF-16, UTF-32, UTF-7 even, Unicode, BigEndianUnicode - all to no avail.
umlauts,仍然能够调用那血腥的服务...工作正常在SoapUI,btw .....
So how on earth do I get back my proper umlauts, and still be able to call that bloody service... works just fine in SoapUI, btw.....
任何想法我绝望地抓住