首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

调webservice,该怎么处理

2014-01-17 
调webservicehttp://www.nnzbzh.cn:6000/ZBXZXService?wsdl这是地址,// ********************************

调webservice
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的地址,谁帮我写一个调用的代码,谢谢。
[解决办法]
procedure yourProcedure;
var
  yourGetHBMDResponse: GetHBMDResponse;
  YourNewWDSLAddr: string;
begin
  YourNewWDSLAddr := 'http://xxx?wsdl';
  yourGetHBMDResponse := GetIService(True, YourNewWDSLAddr).GetHBMD(YourParameters);
end;

[解决办法]
引用:
我按照三楼的调用,然后报错。


贴你的源代码和报错截图。
[解决办法]
是不是你的sGhbmdSun根本没create??

热点排行