次のような ASP.NET WebService があります。
[WebMethod]
public static void DoSomethingWithStrings(string stringA, string stringB)
{
// and so on
}
サードパーティ アプリケーションは、この Web サービスを呼び出す必要があります。ただし、このアプリケーションは文字列を UTF-8 としてエンコードし、すべてのウムラウトは「??」に置き換えられます。呼び出しを表示でき、特殊文字は適切にフォーマットされています。
<?xml version="1.0" encoding="utf-8" ?>
<!-- ... -->
<SoapCall>
<DoSomethingWithStrings>
<stringA>Ä - Ö - Ü</stringA>
<stringB>This is a test</stringB>
</DoSomethingWithStrings>
</SoapCall>
これにより、webservice メソッド内の文字列を単純に出力すると、次の出力が生成されます。
?? - ?? - ??
これはテストです
UTF-8 でエンコードされた文字列を受け入れるように WebService を構成するにはどうすればよいですか?
アップデート
Fiddler は、http 要求の content-type charset が UTF-8 であることも教えてくれます。
更新 2
global.asax
デバッグ目的で次のコードを追加しようとしました:
public void Application_BeginRequest(object sender, EventArgs e)
{
using (var reader = new System.IO.StreamReader(Request.InputStream))
{
string str = reader.ReadToEnd();
}
}
これにより、実際の SOAP 呼び出しが読み取られます。StreamReader
s エンコーディングは UTF-8 に設定されています。SOAP 呼び出しは正しいようです。
<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<DoSomethingWithStrings xmlns="http://www.tempuri.org/">
<stringA>Ä - Ö - Ü</stringA>
<stringB>This is a test!</stringB>
</DoSomethingWithStrings>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
web.config
ファイルでは、グローバリゼーション設定が正しく設定されています。
<globalization requestEncoding="UTF-8" responseEncoding="UTF-8" culture="de-DE" uiCulture="de-DE" />
そのため、SOAP メッセージをデシリアライズするものは UTF-8 ではなく ASCII エンコーディングを使用しているようです。