关于Soap的问题,在线等,解决立刻给分

zhangnan623 2004-02-18 04:10:20
此程序当服务器和客户端的程序都在我的机子上运行时没问题。
当在别的机子上运行客户端程序访问我的服务器时,出错。

服务器端的程序为:
unit MainWM;

interface

uses
SysUtils, Classes, HTTPApp, InvokeRegistry, WSDLIntf, TypInfo,
WebServExp, WSDLBind, XMLSchema, WSDLPub, SOAPPasInv, SOAPHTTPPasInv,
SOAPHTTPDisp, WebBrokerSOAP;

type
TWebModule1 = class(TWebModule)
HTTPSoapDispatcher1: THTTPSoapDispatcher;
HTTPSoapPascalInvoker1: THTTPSoapPascalInvoker;
WSDLHTMLPublish1: TWSDLHTMLPublish;
procedure WebModule1DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;

ISoapHello=interface(IInvokable)
['{AF4E4CC3-6F31-450E-8475-582F7578BA8D}']
function Gethello(aID:Integer):WideString;StdCall;
end;
TSoapHello=class(TInvokableClass,ISoapHello)
protected
function Gethello(aID:Integer):WideString;StdCall;
end;
var
WebModule1: TWebModule1;

implementation

{$R *.dfm}

procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
WSDLHTMLPublish1.ServiceInfo(Sender, Request, Response, Handled);
end;

{ TSoapHello }

function TSoapHello.Gethello(aID: Integer): WideString;
begin
if (aID=1) then
Result:='Hello'
else
Result:='error';
end;

initialization
InvRegistry.RegisterInterface(TypeInfo(ISoapHello));
InvRegistry.RegisterInvokableClass(TSoapHello);
end.

客户端程序为:
unit ClnMain;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,Soapintf, InvokeRegistry, Rio, SOAPHTTPClient;

type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
HTTPRIO1: THTTPRIO;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
p:IsoapHello;
begin
p:=HTTPRIO1 as Isoaphello;
edit2.Text:=p.Gethello(strtoint(edit1.Text));
end;

end.
...全文
43 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复

5,930

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧