调webservice问题

虎滴小猪猪 2013-08-08 10:36:10
我是用delphi 调用以下地址,由于没做过,遇到些问题,谁能帮我写个例子?
http://www.nnzbzh.cn:6000/ZBXZXService?wsdl
这是地址,
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://www.nnzbzh.cn:6000/ZBXZXService?wsdl
// Encoding : utf-8
// Version : 1.0
// (2013-8-1 10:24:52 - 1.33.2.5)
// ************************************************************************ //

unit uZBXZXService;

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.
// ************************************************************************ //
// !:GetMes - "http://tempuri.org/"
// !:GetMesResponse - "http://tempuri.org/"
// !:GetMesLeng - "http://tempuri.org/"
// !:GetMesLengResponse - "http://tempuri.org/"
// !:inqTranFlow - "http://tempuri.org/"
// !:inqTranFlowResponse - "http://tempuri.org/"
// !:GetHBMD - "http://tempuri.org/"
// !:GetHBMDResponse - "http://tempuri.org/"
// !:GetAllMes - "http://tempuri.org/"
// !:GetAllMesResponse - "http://tempuri.org/"
// !:GetXZXMES - "http://tempuri.org/"
// !:GetXZXMESResponse - "http://tempuri.org/"
// !:GetHBMDSNUM - "http://tempuri.org/"
// !:GetHBMDSNUMResponse - "http://tempuri.org/"
//以下是我自己加的+++
GetHBMD = Class;
GetHBMDResponse = Class;
GetHBMDSNUM = Class;
GetHBMDSNUMResponse = Class;

GetHBMD = class(TSOAPHeader)
private
Fid: WideString;
Fcount: WideString;
FYZM: WideString;
public
published
property id: WideString read Fid write Fid;
property count: WideString read Fcount write Fcount;
property YZM: WideString read FYZM write FYZM;
end;

GetHBMDResponse = class(TSOAPHeader)
private
Freturn: WideString;
public
published
property return: WideString read Freturn write Freturn;
end;

GetHBMDSNUM = class(TSOAPHeader)
private
public
published
end;

GetHBMDSNUMResponse = class(TSOAPHeader)
private
Freturn: WideString;
public
published
property return: WideString read Freturn write Freturn;
end;
//以上是我自己加的———
// ************************************************************************ //
// Namespace : http://tempuri.org/
// soapAction: http://tempuri.org/IService/%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// binding : BasicHttpBinding_IService
// service : Service
// port : BasicHttpBinding_IService
// URL : http://www.nnzbzh.cn:6000/ZBXZXService
// ************************************************************************ //
IService = interface(IInvokable)
['{98ED6C0B-93D7-7F02-40EA-9A0E061E5A66}']
//function GetMes(const parameters: GetMes): GetMesResponse; stdcall;
//function GetMesLeng(const parameters: GetMesLeng): GetMesLengResponse; stdcall;
//function inqTranFlow(const parameters: inqTranFlow): inqTranFlowResponse; stdcall;
function GetHBMD(const parameters: GetHBMD): GetHBMDResponse; stdcall;
//function GetAllMes(const parameters: GetAllMes): GetAllMesResponse; stdcall;
//function GetXZXMES(const parameters: GetXZXMES): GetXZXMESResponse; stdcall;
function GetHBMDSNUM(const parameters: GetHBMDSNUM): GetHBMDSNUMResponse; stdcall;
end;

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


implementation

function GetIService(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): IService;
const
defWSDL = 'http://www.nnzbzh.cn:6000/ZBXZXService?wsdl';
defURL = 'http://www.nnzbzh.cn:6000/ZBXZXService';
defSvc = 'Service';
defPrt = 'BasicHttpBinding_IService';
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 IService);
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(IService), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(IService), 'http://tempuri.org/IService/%operationName%');
InvRegistry.RegisterInvokeOptions(TypeInfo(IService), ioLiteral);
end.


我想调用GetHBMD和GetHBMDSUN函数,并且能在程序里改wsdl的地址,谁帮我写一个调用的代码,谢谢。
...全文
347 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
虎滴小猪猪 2013-08-28
  • 打赏
  • 举报
回复

这个是我加入到delphi后,编译时的报错。
虎滴小猪猪 2013-08-28
  • 打赏
  • 举报
回复
啊?那能把你调用的测试程序发给我吗?我试试。谢谢。
Andy__Huang 2013-08-28
  • 打赏
  • 举报
回复
我现在都可以调用,说明没问题,
虎滴小猪猪 2013-08-28
  • 打赏
  • 举报
回复
http://www.nnzbzh.cn:6000/ZBXZXService?wsdl 这个在delphi加入后,编译有问题。
tcmakebest 2013-08-10
  • 打赏
  • 举报
回复
这样不行吗? GetIService(true,'http://...',nil).GetHBMD(...)
likofans 2013-08-08
  • 打赏
  • 举报
回复
看看这个吧:http://blog.csdn.net/beyondqd/article/details/6730448
机器人 2013-08-08
  • 打赏
  • 举报
回复
工程右键 > 添加服务引用 > 输入wsdl > 生成客户端代理。 客户端代理使用: var client = new ServiceReference1.xxxClient(); client.GetHBMD(...); 然后在 app.config 就能看到调用地址,按照实际修改地址即可。

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧