Delphi6利用WebService 编写 SendEMail程序

 到http://www.xmethods.com

就会看到一个Delphi做的服务器程序. Send an EMail

 


 

有如下描述:

我们下载程序接口:

点WSDL URL连接

另存为名为IEmailService.wsdl到你的程序相同目录.

导入程序接口:

然后会生成Unit2单元.

Unit Unit2;

interface

uses Types, XSBuiltIns;
type

  IEmailService = interface(IInvokable)
    ['{839561DB-8AFE-43B8-81EB-5505C873EC8F}']
    function SendMail(const ToAddress: WideString; const FromAddress: WideString; const ASubject: WideString; const MsgBody: WideString): Integer;  stdcall;
  end;


implementation

uses InvokeRegistry;

initialization
  InvRegistry.RegisterInterface(TypeInfo(IEmailService), '', '');

end.

 

 

选择刚才保存的wsdl文件给HTTPRIO1.WSDLLaction属性

在Unit1中运行编程

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,  Rio, SoapHTTPClient, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    HTTPRIO1: THTTPRIO;
    LabeledEdit1: TLabeledEdit;
    LabeledEdit2: TLabeledEdit;
    LabeledEdit3: TLabeledEdit;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;  /

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  if (HTTPRIO1 as IEmailService).SendMail
    (LabeledEdit1.Text,
     LabeledEdit2.Text,
     LabeledEdit3.Text,
     Memo1.Text
    ) = 0 then
    ShowMessage('Send Success!');
end;

end.

可以发邮件了,很方便也很简单.

阅读终点,创作起航,您可以撰写心得或摘录文章要点写篇博文。去创作
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
以下是一个简单的 Java 调用 WebService 接口的示例: 1. 首先,需要生成客户端代码来调用 WebService。可以使用 Java 提供的 wsimport 工具,例如: ``` wsimport -keep -verbose http://localhost:8080/your_webservice_url?wsdl ``` 这个命令会根据 WSDL 文件生成客户端代码,并将生成的代码保存在当前目录下的 `your_webservice_url` 目录中。 2. 在代码中创建 WebService 客户端对象。例如: ```java YourWebService service = new YourWebService(); YourWebServicePortType port = service.getYourWebServicePort(); ``` 注意,`YourWebService` 和 `YourWebServicePortType` 分别对应于生成的客户端代码中的服务类和端口类。 3. 调用 WebService 方法。例如: ```java String result = port.yourWebServiceMethod(param1, param2); ``` 其中,`yourWebServiceMethod` 是 WebService 中定义的方法名,`param1` 和 `param2` 是方法的参数。 完整的代码示例: ```java import your.webservice.package.YourWebService; import your.webservice.package.YourWebServicePortType; public class MyWebServiceClient { public static void main(String[] args) { try { // 创建 WebService 客户端对象 YourWebService service = new YourWebService(); YourWebServicePortType port = service.getYourWebServicePort(); // 调用 WebService 方法 String result = port.yourWebServiceMethod(param1, param2); // 处理返回结果 System.out.println(result); } catch (Exception e) { e.printStackTrace(); } } } ``` 其中,`your.webservice.package` 对应于生成的客户端代码中的包名。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

gaochunguang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值