我用delphi7做下个测试应用,调用webservices ,代码如下:
unit main;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, InvokeRegistry, Rio, SOAPHTTPClient,PublicInterface2;type
TForm1 = class(TForm)
Memo2: TMemo;
Memo1: TMemo;
HTTPRIO1: THTTPRIO;
Edit1: TEdit;
Button1: TButton;
Edit2: TEdit;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;////以下是按钮下的代码
procedure TForm1.Button1Click(Sender: TObject);
Var
p : PublicInterface ;
begin
try
webser := edit1.Text;
HTTPRIO1.WSDLLocation := webser;
ininfo := memo2.Text;
p := HTTPRIO1 As PublicInterface ;
outinfo:= p.outCalculate(ininfo);
p:=nil;
memo1.Text := outinfo;
except
showmessage('webservice 地址可能不正确!或者服务就没有启动!');
end;
end;
这上边是一个按钮下的代码。测试正常。
现在要用delphi 做一个 DLL 给 PB 调用。 不用 窗口了,也就是没有 Form 了,该怎么弄,我该怎么创建 HTTPRIO1 这个对象,代码该怎么写,写在哪里。这两天刚学 delphi 大家指点一下。
unit main;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, InvokeRegistry, Rio, SOAPHTTPClient,PublicInterface2;type
TForm1 = class(TForm)
Memo2: TMemo;
Memo1: TMemo;
HTTPRIO1: THTTPRIO;
Edit1: TEdit;
Button1: TButton;
Edit2: TEdit;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;////以下是按钮下的代码
procedure TForm1.Button1Click(Sender: TObject);
Var
p : PublicInterface ;
begin
try
webser := edit1.Text;
HTTPRIO1.WSDLLocation := webser;
ininfo := memo2.Text;
p := HTTPRIO1 As PublicInterface ;
outinfo:= p.outCalculate(ininfo);
p:=nil;
memo1.Text := outinfo;
except
showmessage('webservice 地址可能不正确!或者服务就没有启动!');
end;
end;
这上边是一个按钮下的代码。测试正常。
现在要用delphi 做一个 DLL 给 PB 调用。 不用 窗口了,也就是没有 Form 了,该怎么弄,我该怎么创建 HTTPRIO1 这个对象,代码该怎么写,写在哪里。这两天刚学 delphi 大家指点一下。
解决方案 »
- Delphi7调用C#写的Web service报错?
- 请大侠们看看为什么我这个代码有什么问题吗?
- 怎样用tadocommand来插入图像数据?
- 在ADOCOMMAND中,如何用update更改一个日期字段
- 各位大虾..怎么为按钮设置快捷键??问题解绝马上洒分结贴!!
- DBGrid的一个小问题!!要分的要快!!!
- 急!急!FASTREPORT报表制作的问题!
- win98下Delphi开发的应用程序,linux下能正常运行么?
- 在dbgrid中如何显示备注型字段的内容?
- 前天程序编译运行都好的,今天却出现exception eAccessViolation的错误,请高手帮忙,50分奉送。
- DELPHI设置打印机的纸张与横向打印问题.
- dxdbtreeview 怎么实现多层
SoapConnection lsc_conn
soapservice lproxy_obj
String ls_proxy_name = "soapservice"//生成的代理对象名称
String ls_url = "http://localhost:8080/axis/services/SoapService"//web service url
//
lsc_conn = Create SoapConnection
lsc_conn.SetOptions("SoapLog=~"soaplog.txt~"")
int li_ret, i
li_ret = lsc_conn.Createinstance( lproxy_obj, ls_proxy_name, ls_url)
If li_ret <> 0 Then
MessageBox("错误", "调用失败,错误号码:" + String(li_ret))
Return
End If
tns1__requestcontent lst_request
lst_request.arg1 = 5
lst_request.arg2 = "test"
tns1__returnresult lst_result
lst_result = lproxy_obj.GetResult(lst_request)
MessageBox(String(lst_result.result), "code:" + lst_result.reason.code + "~nmessage:" + &
lst_result.reason.message + "~ndesc:" + lst_result.reason.desc )
注意pb调用webservice只能返回简单的int string类型,复杂的结构会出错
简单..........