gpt4 book ai didi

.net - Delphi 7 中的 Soap Envelope Header 不包括 utf-8 编码。我该如何修改它?

转载 作者:行者123 更新时间:2023-12-03 18:34:08 25 4
gpt4 key购买 nike

我在接收来自 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> .....

但是,对于 Delphi 7 SOAP header ,不包括编码 header ,如下所示:
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 是否带有一些显示为 ??在我从 Delphi 客户端收到方法后,在 C# Web 服务内部,这在我看来是唯一合乎逻辑的解释。当我在发送之前在 Delphi 中检查 XML 时,它被完美编码,但是在接收端,我得到 ??.
在使用 WSDL 导入器导入的单元上,它指定了 utf-8,如下所示:
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.

如何更改 SOAP 信封的 XML 编码?任何想法还有什么可能是错的?我对我来说似乎合乎逻辑,如果 SOAP 信封的 XML 没有正确编码为 utf-8,那么我在这个 XML 中的 XML 将不会被正确读取
非常适合您的时间

最佳答案

如果您使用 HTTPRio/HTTPWebNode 也许这会有所帮助:

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

  • (找到 here )

    关于.net - Delphi 7 中的 Soap Envelope Header 不包括 utf-8 编码。我该如何修改它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3902259/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com