Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net Delphi7中的Soap信封头不包括utf-8编码。如何修改它?_.net_Delphi_Unicode_Soap_Encoding - Fatal编程技术网

.net Delphi7中的Soap信封头不包括utf-8编码。如何修改它?

.net Delphi7中的Soap信封头不包括utf-8编码。如何修改它?,.net,delphi,unicode,soap,encoding,.net,Delphi,Unicode,Soap,Encoding,我在接收来自Delphi 7客户端的无效非ascii字符时遇到问题,该客户端将utf-8编码的XML发送到字符串参数中的C#WebService。对于.Net客户端,接收字符时不会出现问题。我尝试了很多东西,但似乎都不管用,所以我决定追踪与Wireshark的SOAP对话。对于.Net客户端,SOAP信封的XML是utf-8编码的,如下所示: POST //TesteService/ServicoAgente.asmx HTTP/1.1 User-Agent: Mozilla/4.0 (comp

我在接收来自Delphi 7客户端的无效非ascii字符时遇到问题,该客户端将utf-8编码的XML发送到字符串参数中的C#WebService。对于.Net客户端,接收字符时不会出现问题。我尝试了很多东西,但似乎都不管用,所以我决定追踪与Wireshark的SOAP对话。对于.Net客户端,SOAP信封的XML是utf-8编码的,如下所示:

POST //TesteService/ServicoAgente.asmx HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.3615)
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://example.com/ValidarTransacao"
Host: 192.168.254.2
Content-Length: 1530
Expect: 100-continue
Connection: Keep-Alive

HTTP/1.1 100 Continue

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body> .....
POST /TesteService/ServicoAgente.asmx HTTP/1.1
SOAPAction: "http://example.com/ValidarTransacao"
Content-Type: text/xml
User-Agent: Borland SOAP 1.2
Host: 192.168.254.1
Content-Length: 1548
Connection: Keep-Alive
Cache-Control: no-cache

<?xml version="1.0"?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body> .....
如何更改SOAP信封的XML编码?你知道还有什么不对劲吗?在我看来,如果SOAP信封的XML没有正确编码为utf-8,那么该XML中的XML将无法正确读取

非常感谢您的时间

如果我理解正确,您正在尝试找出如何将字符串utf-8添加到SOAP信封中?恐怕我不认为这很简单(但可以肯定的是,您可以更改soapxml流并对其进行测试)

Delphi 2009之前的Delphi不兼容Unicode,因此不会将项目编码为UTF-8,因为Delphi本身不兼容。一些欧洲字符在delphi中可以很好地表示出来,但在外部它是任意人猜测的


您最好的选择是更新到符合Unicode的Delphi版本,或者如果不可能,请使用Delphi Unicode库,例如

如果您使用HTTPRio/HTTPWebNode,这可能会有帮助:

  • 将HTTPRIO.Converter.Options.soUTF8InHeader设置为True
  • 将HTTPWebNode.UseUTF8InHeader设置为True

(已找到)

Toby,即使我只使用WideString进行字符串操作?Delphi 6(甚至5)有一个Utf8Encode函数。旧的Delphi版本并没有那么糟糕:)如果它通过一个非unicode Delphi函数,你将丢失所有信息,这是可能的,但有点危险。你太棒了!我到处找!太多了
initialization
  InvRegistry.RegisterInterface(TypeInfo(TesteAgentSoap), 'http://example.com/', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(TesteAgentSoap), 'http://example.com/%operationName%');
  InvRegistry.RegisterInvokeOptions(TypeInfo(TesteAgentSoap), [ioDefault, ioDocument, ioHasReturnParamNames, ioHasNamespace]);

end.