Delphi中调用.net的Web Service时,传入字符串编码的问题(100分)

A

AiBoo

Unregistered / Unconfirmed
GUEST, unregistred user!
我在Delphi中用import wdsl的方法调用.net的Web Service,当Delphi程序在调用该Web Service的web方法时,将一个中文字符串作为参数传入到该方法中,在调试中发现在Web Service中执行该方法是传入的中文都变成了问号。请问如何解决该问题
 
.net用的是UTF8编码,导入wdsl以后,在自动产生的代码里面添加RIO.HTTPWebNode.UseUTF8InHeader := True;
//解决中文乱码问题
,如下面例子所示:
function GetNotifySoap(UseWSDL: Boolean;
Addr: string;
HTTPRIO: THTTPRIO): NotifySoap;
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as NotifySoap);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
RIO.HTTPWebNode.UseUTF8InHeader := True;
//解决中文乱码问题
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;
 
顶部