关于Soap的问题,在线等,解决立刻给分
此程序当服务器和客户端的程序都在我的机子上运行时没问题。
当在别的机子上运行客户端程序访问我的服务器时,出错。
服务器端的程序为:
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.