如何使用 SoapClient 发送 ISO-8859-1 XML 文件?

how can I send ISO-8859-1 XML file using SoapClient?

我正在使用一种 SOAP 方法,该方法需要 XML 具有 ISO-8859-1 编码的内容。我尝试将其直接添加为方法参数,但 SoapClient returns 编码错误:

SOAP-ERROR: Encoding: string '<?xml version="1.0" encoding="ISO-8859-1"?>(...)' is not a valid utf-8 string

如果我将 XML 内容转换为 UTF-8,SOAP 服务器无法识别 XML 内容。

任何使用 SoapClient 的解决方案? 使用 cURL 的任何替代方法?

正如 Constantin GALBENU 所指出的,使用 SoapClient 无法做到这一点。 我不得不改用 cURL,在 content-type header:

发送字符集
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Content-type: text/xml;charset=iso-8859-1",
    "Accept: text/xml",
    "Cache-Control: no-cache",
    "Pragma: no-cache",
));
$result = curl_exec($ch);
curl_close($ch);