找了一个转换汇率的WSDL,但调试了大半天也没成功,请诸位帮忙看看。

global_boy 2005-06-15 02:40:35
WSDL描述http://www.xmethods.net/sd/CurrencyExchangeService.wsdl

以下是获取汇率的函数。

Public Function GetXchangeRate(ByVal strCountry1, _
ByVal strCountry2) ' As String
On Error Resume Next
' SOAP Function
Dim WSDL_URL 'As String
WSDL_URL = "http://www.xmethods.net/sd/CurrencyExchangeService.wsdl"
Dim objSOAPClient
Dim strResult 'As String
Set objSOAPClient = CreateObject("MSSOAP.SoapClient")
objSOAPClient.ClientProperty("ServerHTTPRequest") = True

objSOAPClient.mssoapinit WSDL_URL


strResult = objSOAPClient.GetRate(CStr(strCountry1), _
CStr(strCountry2)) ' As String

If Err <> 0 Then
GetXchangeRate = "ERROR: Could Not Get Exchange Rate (Error # " & CStr(Err.Number) & " " & Err.Description & " in " & Err.Source & ")"
'GetXchangeRate = "ERROR"
Set objSOAPClient = Nothing
Err.Clear
Exit Function
End If

Set objSOAPClient = Nothing
GetXchangeRate = strResult
End Function
...全文
80 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
global_boy 2005-06-15
我当然装了MS-SOAP,可能是我的VS6有点问题。
:)
回复
TechnoFantasy 2005-06-15
下面是这个方法支持的国家:

afghanistan
albania
algeria
andorra
andorra
angola
argentina
aruba
australia
austria
bahrain
bangladesh
barbados
belgium
belize
bermuda
bhutan
bolivian
botswana
brazil
england
united kingdom
uk
great britain
brunei
burundi
cambodia
canada
cape verde
cayman islands
chile
china
colombia
comoros
costa rica
croatia
cuba
cyprus
czech republic
denmark
dijibouti
dominican republic
netherlands
east caribbean
ecuador
egypt
el salvador
estonia
ethiopia
euro
falkland islands
fiji
finland
france
gambia
germany
ghana
gibraltar
greece
guatemala
guinea
guyana
haiti
honduras
hong kong
hungary
iceland
india
indonesia
iraq
ireland
israel
italy
jamaica
japan
jordan
kazakhstan
kenya
korea
kuwait
laos
latvia
lebanon
lesotho
liberia
libya
lithuania
luxembourg
macau
macedonia
malaga
malawi kwacha
malaysia
maldives
malta
mauritania
mauritius
mexico
moldova
mongolia
morocco
mozambique
myanmar
namibia
nepal
new Zealand
nicaragua
nigeria
north korea
norway
oman
pakistan
panama
papua new guinea
paraguay
peru
philippines
poland
portugal
qatar
romania
russia
samoa
sao tome
saudi arabia
seychelles
sierra leone
singapore
slovakia
slovenia
solomon islands
somalia
south africa
spain
sri lanka
st helena
sudan
suriname
swaziland
sweden
switzerland
syria
taiwan
tanzania
thailand
tonga
trinidad
tunisia
turkey
united states
us
usa
uae
united arib emirates
uganda
ukraine
uzbekistan
vanuatu
venezuela
vietnam
yemen
yugoslavua
zambia
zimbabwe

GetXchangeRate的参数只能是这些字符串。
回复
TechnoFantasy 2005-06-15
代码我修改了一下,需要首先引用Microsoft SOAP TypeLibrary 3.0(如果你安装了SOAP Toolkit 3.0的话):

Public Function GetXchangeRate(strCountry1, _
strCountry2) As String



'On Error Resume Next
' SOAP Function
Dim WSDL_URL As String
Dim objSOAPClient As SoapClient30
Dim strResult 'As String
Dim a1, a2

a1 = strCountry1
a2 = strCountry2

WSDL_URL = "http://www.xmethods.net/sd/CurrencyExchangeService.wsdl"
Set objSOAPClient = New SoapClient30

objSOAPClient.ClientProperty("ServerHTTPRequest") = True

objSOAPClient.mssoapinit WSDL_URL


strResult = objSOAPClient.GetRate(a1, a2) ' As String

If Err <> 0 Then
GetXchangeRate = "ERROR: Could Not Get Exchange Rate (Error # " & CStr(Err.Number) & " " & Err.Description & " in " & Err.Source & ")"
'GetXchangeRate = "ERROR"
Set objSOAPClient = Nothing
Err.Clear
Exit Function
End If

Set objSOAPClient = Nothing
GetXchangeRate = strResult
End Function


回复
TechnoFantasy 2005-06-15
每法创建对象,你的机器上面安装了Microsoft Soap Toolkit吗?
http://www.microsoft.com/downloads/details.aspx?familyid=c943c0dd-ceec-4088-9753-86f052ec8450&displaylang=en
回复
doface 2005-06-15
在工程中引用,Microsoft Soap Type Library v3.0
回复
doface 2005-06-15
Private Sub Form_Load()
MsgBox GetXchangeRate("usa", "china")
End Sub
Public Function GetXchangeRate(ByVal strCountry1, _
ByVal strCountry2) ' As String
'On Error Resume Next
' SOAP Function
Dim WSDL_URL 'As String
WSDL_URL = "http://www.xmethods.net/sd/CurrencyExchangeService.wsdl"
Dim objSOAPClient As New MSSOAPLib30.SoapClient30
Dim strResult 'As String
'Set objSOAPClient = CreateObject("MSSOAP.SoapClient")

objSOAPClient.ClientProperty("ServerHTTPRequest") = True

objSOAPClient.MSSoapInit WSDL_URL


strResult = objSOAPClient.GetRate(CStr(strCountry1), _
CStr(strCountry2)) ' As String

If Err <> 0 Then
GetXchangeRate = "ERROR: Could Not Get Exchange Rate (Error # " & CStr(Err.Number) & " " & Err.Description & " in " & Err.Source & ")"
'GetXchangeRate = "ERROR"
Set objSOAPClient = Nothing
Err.Clear
Exit Function
End If

Set objSOAPClient = Nothing
GetXchangeRate = strResult
End Function


回复
发帖
API
创建于2007-09-28

1461

社区成员

VB API
申请成为版主
帖子事件
创建了帖子
2005-06-15 02:40
社区公告
暂无公告