K
kgen
Unregistered / Unconfirmed
GUEST, unregistred user!
C#写的Web Service服务器端
Delphi客户端调用,代码如下:
使用中文的时候,一调用就会出现这个错误:
Exception class EDOMParseError with message 'End tag 'ValidateUser'do
es not match the start tag 'strRegName'.
Line: 2
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http:'. Process TestWS.exe (3144)
但是如果把上面的用户名改成英文的,比如aabb就不会出错了。
[blue]而且服务端下断点,英文的时候会发现跟踪到了,但是使用中文的时候,根本没跟踪到,说明客户端在封包的时候就出错了。[/blue]
工具版本如下:
C# 2003 @ Windows 2000
Delphi 2006 @ Windows XP
请熟悉这方面的高手帮忙
Delphi客户端调用,代码如下:
代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, InvokeRegistry, Rio, SOAPHTTPClient, WSCADB, StdCtrls;
type
TForm1 = class(TForm)
HTTPRIO: THTTPRIO;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
IWS: WSCADBSoap;
begin
HTTPRIO.HTTPWebNode.UseUTF8InHeader := True;
IWS := HTTPRIO as WSCADBSoap;
ShowMessage(IntToStr(IWS.ValidateUser('用户一号', '1')));
end;
end.
这个是接口文件:
unit WSCADB;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
type
WSCADBSoap = interface(IInvokable)
['{59350E49-A8BA-30DC-6695-B9B1E330B759}']
function ValidateUser(const strRegName: WideString;
const strPwd: WideString): Integer;
stdcall;
end;
function GetWSCADBSoap(UseWSDL: Boolean=System.False;
Addr: string='';
HTTPRIO: THTTPRIO = nil): WSCADBSoap;
implementation
function GetWSCADBSoap(UseWSDL: Boolean;
Addr: string;
HTTPRIO: THTTPRIO): WSCADBSoap;
const
defWSDL = 'http://p4pe/WSCADB/WSCADB.asmx?wsdl';
defURL = 'http://p4pe/WSCADB/WSCADB.asmx';
defSvc = 'WSCADB';
defPrt = 'WSCADBSoap';
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;
RIO.HTTPWebNode.UseUTF8InHeader := True;
try
Result := (RIO as WSCADBSoap);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;
initialization
InvRegistry.RegisterInterface(TypeInfo(WSCADBSoap), 'http://p4pe/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(WSCADBSoap), 'http://p4pe/ValidateUser');
InvRegistry.RegisterInvokeOptions(TypeInfo(WSCADBSoap), ioDocument);
end.
Exception class EDOMParseError with message 'End tag 'ValidateUser'do
es not match the start tag 'strRegName'.
Line: 2
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http:'. Process TestWS.exe (3144)
但是如果把上面的用户名改成英文的,比如aabb就不会出错了。
[blue]而且服务端下断点,英文的时候会发现跟踪到了,但是使用中文的时候,根本没跟踪到,说明客户端在封包的时候就出错了。[/blue]
工具版本如下:
C# 2003 @ Windows 2000
Delphi 2006 @ Windows XP
请熟悉这方面的高手帮忙