找了一个转换汇率的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
...全文
147 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
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


1,488

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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