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> .....
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> .....
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.
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