在delphi7里如何调用webservice服务,在线等待..急

yangzong19 yangzong19 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我用WSDL生成了一个单元然后uses到from1里了,但我调用里面的GetServerTime和UpBroke函数的时候总是出错,麻烦各位大哥帮小弟看看,小弟万分感谢!


这是用WSDL生成的SOAP但源代码

// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://127.0.0.1:9000/SOAP?service=nnmzd_Service
// Encoding : UTF-8
// Version : 1.0
// (2011-3-31 10:55:22 - 1.33.2.5)
// ************************************************************************ //

unit SOAP;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

type

// ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Borland types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:int - "http://www.w3.org/2001/XMLSchema"
// !:dateTime - "http://www.w3.org/2001/XMLSchema"
// !:base64Binary - "http://www.w3.org/2001/XMLSchema"



// ************************************************************************ //
// Namespace : http://tempuri.org/
// soapAction: urn:nnmzd_Library-nnmzd_Service#%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// binding : nnmzd_ServiceBinding
// service : nnmzd_Service
// port : nnmzd_ServicePort
// URL : http://127.0.0.1:9000/SOAP?service=nnmzd_Service
// ************************************************************************ //
nnmzd_Service = interface(IInvokable)
['{984A1501-F6A3-D06A-AAE3-F01206265B3C}']
function Sum(const A: Integer; const B: Integer): Integer; stdcall;
function GetServerTime: TXSDateTime; stdcall;
function UpBroke(const Data: TByteDynArray): Integer; stdcall;
end;

function Getnnmzd_Service(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): nnmzd_Service;


implementation

function Getnnmzd_Service(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): nnmzd_Service;
const
defWSDL = 'http://127.0.0.1:9000/SOAP?service=nnmzd_Service';
defURL = 'http://127.0.0.1:9000/SOAP?service=nnmzd_Service';
defSvc = 'nnmzd_Service';
defPrt = 'nnmzd_ServicePort';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as nnmzd_Service);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;


initialization
InvRegistry.RegisterInterface(TypeInfo(nnmzd_Service), 'http://tempuri.org/', 'UTF-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(nnmzd_Service), 'urn:nnmzd_Library-nnmzd_Service#%operationName%');

end.





这是from1代码

unit Unit1;

interface

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

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

var
Form1: TForm1;

implementation

uses SOAP;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
server1:nnmzd_Service;
aa:string;
begin
aa:=datetostr(server1.GetServerTime); //在这里我想调用 function GetServerTime: TXSDateTime; stdcall;这个函数

//在这里我想掉用function UpBroke(const Data: TByteDynArray): Integer; stdcall; 这个函数
end;

end.


麻烦大哥们帮小弟看看,小弟跪谢了
...全文

相关推荐

Delphi调用Webservice一个完整的例子

Delphi调用C#开发Webservice服务

jinshigu

Delphi7调用Java AXIS写的WebService

因目前公司客户端采用delphi7开发,与服务器交换数据用的webservice也用delphi开发 本人是做java开发,所以想研究一下怎么用java开发webservice供delphi7调用 javaserver 是WebService 服务端,采用AXIS 1.4 为什么采用AXIS1.4? 因为经过我测试,Delphi7版本太老了,不兼容JAX-WS和AXIS2 另外我觉得AXIS1.4配置也是最简单的。 本例采用Dynamic Proxy方式,WSDD方式 delphiclient 是用delphi7写的WebService客户端 里面的地址请根据实际情况调整 效果很简单,点一下访问Webservice弹出一个对话框

tenkin

WebService获得天气预报demo Delphi7

利用WebService接口获得http://www.webxml.com.cn/WebServices/WeatherWebService.asmx上面的天气预报 Delphi源码

__lhy

Delphi 调用WebService 出错

Delphi 调用WebService 出错 1.新建一个App, 放上一个button, listbox, HTTPRIO 2.新建webservices -$amp;>amp;$nbsp;wsdlInmporter 导入你这个网站的Wsdl 让程序知道调用规则 不出意外会生成个WeatherWebService.pas ,主窗体引用它 3.设置HTTPRIO的 port, service, wsdlLocation 会下拉出来 4.写点代码吧 //得到支持的地区 procedure TForm1.Button1Click(Sender: TObject); var AOS,ss: ArrayOfString; I: Integer; begin AOS := (HTTPRIO1 as WeatherWebServiceSoap).getSupportProvince; for I := Low(AOS) to High(AOS) do Listbox1.Items.Add(AOS[I]); -- 可以把所有省份列出来 但是使用下面代码,出现错误: -- 取省份下的城市 ss := (HTTPRIO1 as WeatherWebServiceSoap).getSupportCity('广西') -- 取城市的天气 ss := (HTTPRIO1 as WeatherWebServiceSoap).getWeatherbyCityName('深圳'); ---- 错误信息为: Project Project1.exe raised exception class ERemotableException with message '服务器无法处理请求。 ---$amp;>amp;$nbsp;未将对象引用设置到对象的实例。'. Process stopped. Use Step or Run to continue. InvRegistry.RegisterInvokeOptions(TypeInfo(WeatherWebServiceSoap), ioDocument); 把这句加上2005前的版本不加这个就出错,我也是找了很久才发现的 而且要加到initialization 最后一行,我加到initialization 之后紧接着第一行,就一直报错。

ningaijunsinacom

delphi XE5 ANDROID平台 调用 webservice并访问操作MSSQL数据库

delphi XE5 ANDROID平台 调用 webservice并访问操作MSSQL数据库

hdhuichen
评论 7
收藏 已收藏
分享
返回顶部
yangzong19
Delphi 5,944 成员 262,941 内容