我正在尝试使用 PHP 中的 Curl 调用 .net 网络服务。每次我尝试这样做时,都会收到编码错误。它说不支持 utf...8。当我检查 tcpdump (PacketPeeper) 时,我看到由于某种原因 curl 正在将字符串“utf-8”转换为“utf...8”。实际上,它将所有“-”转换为“...”。
知道为什么吗?
$req = "<?xml version=\"1.0\" encoding=\"utf‐8\"?>
<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema‐instance\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">
<soap:Body>
<GenerateLink>
..............
</GenerateLink>
</soap:Body>
</soap:Envelope>";
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, "http://www.myurl.com/serv.asmx" );
curl_setopt($soap_do, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $req);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset: utf-8' ,'SOAPAction: "http://www.myurl.com/serv.asmx"', 'Content-Length: '.strlen($req) ));
$response = curl_exec($soap_do);