• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Delphi通过Soaptoolkit3.0调用webservice

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

用Delphi 通过 Soap toolkit 3.0调用webservice

先安装MS Soap toolkit 3.0

 

unit CallWebServiceByComObject;

 

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  vWSObj: OleVariant;
begin
  vWSObj := CreateOleObject('MSSOAP.SoapClient30');
  vWSObj.clientproperty('ServerHTTPRequest') := true; //可以使用IE的代理服务器,如果使用了浏览器代理注释次行会报错
  vWSObj.mssoapinit(trim(Edit1.Text));//Edit1.Text:='http://10.35.8.179/test/WSAutoUpgrade.asmx?wsdl'; 传入参数
  ShowMessage(vWSObj.HelloWorld());
end;

end.

 

 

{关于MsSoapInit 在MSDN的详细解释

mssoapinit

This method initializes the object implementing the ISoapClient interface using the Web Services Description Language (WSDL) file as input. All the operations in the identified service are bound to the ISoapClient object during initialization. Thus, you can call the operations defined in the service using the ISoapClient object.

HRESULT mssoapinit( 
BSTR bstrWSDLFile,
BSTR bstrServiceName,
BSTR bstrPort,
BSTR bstrWSMLFile
);

Parameters

bstrWSDLFile
[in] URL of the WSDL file that describes the services offered by the server.
bstrServiceName
[in] Optional. Default value is "". The service in the WSDL file that contains the operation specified in the SOAP request. If this parameter is missing, is null, or is an empty string, the mssoapinit method uses the first service in the specified WSDL file when initializing the ISoapClient implementation.
bstrPort
[in] Optional. Default value is "". The name of the port in the WSDL file that contains the operation specified in the SOAP request. If this parameter is missing, is null, or is an empty string, the mssoapinit method uses the first port in the specified service when initializing the ISoapClient implementation.
bstrWSMLFile
[in] Optional. Default value is "". The URL of the Web Services Meta Language (WSML) file. This is a required parameter only when using custom type mappers, as described in Handling Complex Types.

Return Values

The following table describes the common return values.

Value Description
S_OK Success.
E_NOTIMPL The function contains no implementation.
E_OUTOFMEMORY Out of memory.

Remarks

The mssoapinit method is part of the high-level API on the client side. To use this method, first you simply create an SoapClient object on the client. The SoapClient object implements the ISoapClient interface. Then, you call the mssoapinit method using the WSDL file name, service name, and port name as parameters. Now, the client can call any operations defined in the WSDL file for the requested service or port.

Requirements

OS Versions: Windows CE .NET 4.0 and later.
Header: Mssoap.h.
Link Library: Uuid.lib.

See Also

A Quick Introduction to WSDL | A Quick Introduction to WSML | ISoapClient

}

 

下面是从网上摘录,未验证

附:

一、用javascript调用

//使用具体的地址
var WSDL_URL = "http://10.20.10.220/zjdxgc/Service.asmx?wsdl"
WScript.echo("Connecting: " + WSDL_URL)
var soapclient= WScript.CreateObject("MSSOAP.SoapClient30")
soapclient.mssoapinit(WSDL_URL, "", "", "")
var res,username,password
//使用具体的用户名和密码
username="0410307444"
password="00000"
res = soapclient.XSCheckPassword(username,password)
WScript.Echo("返回值:" + res )

二、用vb后台写的asp调用


<HTML>
<HEAD>
<TITLE>webservie演示</TITLE>
</HEAD>
<BODY>
<%
Dim soapclient
'使用具体的地址
Const WSDL_URL = "http://10.20.10.220/zjdxgc/Service.asmx?wsdl"
set soapclient = CreateObject("MSSOAP.SoapClient30")
soapclient.ClientProperty("ServerHTTPRequest") = True
Call soapclient.mssoapinit(WSDL_URL, "", "", "")
Dim res,username,password
'使用具体的用户名和密码
username="0410307444"
password="00000"
res = soapclient.XSCheckPassword(username,password)
res = soapclient.zfcwjk("","","","","")

%>
<h1>webservie演示</h1>
<B>返回结果:</B><%=res%> <P><P>
</BODY>
</HTML>


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
MATLAB的简单动画制作发布时间:2022-07-18
下一篇:
MATLAB命令发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap