SOAP信封头在Delphi 7不包括UTF-8编码。如何修改呢? [英] Soap Envelope Header in Delphi 7 not including utf-8 encoding. How can I modify it?
问题描述
我有问题获得错误的非ASCII字符从一个Delphi 7客户端进来一个字符串参数发送一个UTF-8 EN codeD XML到C#的WebService。用.Net客户端,字符被接收没有问题。我已经尝试了很多东西,并没有什么似乎工作,所以我决定跟踪使用Wireshark的SOAP谈话。与.NET客户端,XML的SOAP信封是utf-8的连接codeD,如下:
I'm having problems receiving invalid non-ascii characters coming from a Delphi 7 client sending a utf-8 encoded XML to a C# WebService in a String parameter. With a .Net client, the characters are received without a problem. I've tried a lot of stuff, and nothing seemed to work, so I decided to trace the SOAP conversation with Wireshark. With the .Net client, the XML for the SOAP envelope is utf-8 encoded, as follows:
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头部,编码头不包括,如下:
However, with the Delphi 7 SOAP header, the encoding head is not included, as follows:
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有一些出现非ASCII字符? C#中的Web Service中后,我收到来自德尔福的客户端的方法,这在我看来是唯一合乎逻辑的解释。当我检查了XML德尔福之前,我把它,它是完全连接codeD,但是,在接收端,我得到??
在使用WSDL进口商进口的设备,它指定UTF-8,你可以看到如下:
Included as a parameter, inside the SOAP Body, is my XML with some non-ascii characters that appears as ?? inside the C# Web Service after I receive the method from the Delphi client, and this seems to me the only logical explanation. When I check the XML in Delphi right before I send it, it's perfectly encoded but, on the receiving end, I get ??.
On the unit imported using WSDL importer, it specifies utf-8, as you can see below:
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.
我能做些什么来改变XML的SOAP信封的编码?任何想法什么可能是错的?我似乎是合乎逻辑,我认为,如果XML的SOAP信封没有正确连接codeD为UTF-8,那么我的XML这个XML内将无法正确读取
TKS这么多的时间
What can I do to change the encoding of the XML for the SOAP envelope? Any ideas what else could be wrong? I seems logical to me that, if the XML for the SOAP envelope is not correctly encoded as utf-8, then my XML inside this XML won't be correctly read
Tks so much for your time
推荐答案
如果您使用HTTPRio / HTTPWebNode也许这会有所帮助:
If you use HTTPRio / HTTPWebNode maybe this helps:
- 设置HTTPRIO.Converter.Options.soUTF8InHeader为True
- 设置HTTPWebNode.UseUTF8InHeader为True
(发现这里)
这篇关于SOAP信封头在Delphi 7不包括UTF-8编码。如何修改呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!