我想调用C#做的WebService.但是我不知道怎么添加C#的WebService.我在File->New->WebService->WSDL Module里面输入C# webService的URL但是找不到.能不能给的详细的例子.谢谢.
解决方案 »
- [散分]自己找了个好点的部门,可是领导不放,郁闷死了
- 谁会写这种高难度的循环???
- RadioGroup中的Radio通过Items输入,好像Radio只能竖的排列?
- 如何控制往Word属性中的摘要中写作者名,和标题!
- 大家来抢分啊@@@@,知道的人马上拿分类
- 奇怪呀,请教大虾们!
- DEPHI5在连接数据库时(用ODBC连接)有会出现EOF,BOF的问题,送60分
- 请教如何调试一个SERVICE。NT4+DELPHI5+BOUNK CHECK6.5
- 两个应用程序间数据传递,有哪些方法
- 怎么样得到文件的大小?(DELPHI)
- delphi 调用C# WebService的问题.
- 怎么关闭application 下所有对象 占用的内存呢?
如果你看不见他的WSDL,那么他给你的不是WSDL的URL,而是接口访问的URL。
这两个URL是不同的。
namespace WebService1{ public class Service1 : System.Web.Services.WebService { public Service1() { //CODEGEN: 该调用是 ASP.NET Web 服务设计器所必需的 InitializeComponent(); }
#region 组件设计器生成的代码 //Web 服务设计器所必需的 private IContainer components = null; /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if(disposing && components != null) { components.Dispose(); } base.Dispose(disposing); } #endregion [WebMethod] public string HelloWorld() { return "Hello World 用.NET写的web服务!!^_^"; } [WebMethod] public string datetostr(DateTime dt)//将时间转换为字符 { return dt.ToUniversalTime().ToString(); } }}2.编译调试:
我们的webservices已经可以用了;
下面在打开delphi 7新建一个应用程序:拖两个button两个edit 和一个HTTPRIO(在webservices页上)到窗体上;
3.接下来:File->new->other->webservices->WSDL importer
点击next 导入 保存unit Service14.在unit1(form1 的单元文件)中引用Service1, XSBuiltIns5. HTTPRIO1的WSDLLocation 属性设置为'http://localhost/WebService1/Service1.asmx?WSDL'6.添加form1 的代码如下:unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, InvokeRegistry, Rio, SOAPHTTPClient;
type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Edit1: TEdit; Edit2: TEdit; HTTPRIO1: THTTPRIO; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementationuses XSBuiltIns, Service1;{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);var dtm:TXSDateTime;begin dtm:=TXSDateTime.Create; dtm:=DateTimeToXSDateTime(now); Edit1.Text:=(HTTPRIO1 as Service1Soap).datetostr(dtm); dtm.free;end;
procedure TForm1.Button2Click(Sender: TObject);begin Edit2.Text:=(HTTPRIO1 as Service1Soap).HelloWorld;end;
end.7.编译运行
希望本文能起到抛砖引玉的作用^_^
http://localhost/WebService1/Service1.asmx?WSDL
这样添加试试看