|
CODE:
*****************************************************************
'該類是由 Microsoft Office 2003 Web Services Toolkit 創(chuàng)建的。
'
'創(chuàng)建時(shí)間: 10/5/2007 12:41:01 AM
'
'說明:
'該類是 Web 服務(wù)
' 的 Visual Basic for Applications 類表示形式,這是由 http://smsinter.sina.com.cn/ws/smswebservice0101.wsdl 定義的。
'
'使用:
'將變量聲明為新的 clsws_SMSWS,然后編寫代碼以
'使用該類所提供的方法。
'示例:
' Dim ExampleVar as New clsws_SMSWS
' debug.print ExampleVar.wsm_sendXml(“示例輸入”)
'
'有關(guān)更多信息,請參閱 Microsoft Office 2003
'Web Services Toolkit 幫助中的“復(fù)雜類型”。
'
'對此類中的代碼所做的更改可能導(dǎo)致錯誤的行為。
'
'*****************************************************************
'聲明專用類變量。
Private sc_SMSWS As SoapClient30
Private Const c_WSDL_URL As String = "http://smsinter.sina.com.cn/ws/smswebservice0101.wsdl"
Private Const c_SERVICE As String = "SMSWS"
Private Const c_PORT As String = "SMSWebServiceSoapPort"
Private Const c_SERVICE_NAMESPACE As String = "http://outlook.microsoft.com/add-ins/SMS/wsdl/"
Private Sub Class_Initialize()
'*****************************************************************
'每次實(shí)例化該類時(shí)都將調(diào)用此子例程。
'將 sc_ComplexTypes 創(chuàng)建為新的 SoapClient30,然后
'用在
'http://smsinter.sina.com.cn/ws/smswebservice0101.wsdl 中找到的 WSDL 文件實(shí)例化 sc_ComplexTypes.mssoapinit2。
'*****************************************************************
Dim str_WSML As String
str_WSML = ""
Set sc_SMSWS = New SoapClient30
sc_SMSWS.MSSoapInit2 c_WSDL_URL, str_WSML, c_SERVICE, c_PORT, c_SERVICE_NAMESPACE
'使用 Internet Explorer 的 LAN 設(shè)置中定義的代理服務(wù)器,方法是
'將 ProxyServer 設(shè)置為
sc_SMSWS.ConnectorProperty("roxyServer") = ""
'如果 Internet Explorer 被設(shè)置為自動檢測,則自動檢測代理設(shè)置,
'方法是將 EnableAutoProxy 設(shè)置為真
sc_SMSWS.ConnectorProperty("EnableAutoProxy") = True
End Sub
Private Sub Class_Terminate()
'*****************************************************************
'將在每次析構(gòu)該類時(shí)調(diào)用此子例程。
'將 sc_ComplexTypes 設(shè)置為 Nothing。
'*****************************************************************
'錯誤捕獲
On Error GoTo Class_TerminateTrap
Set sc_SMSWS = Nothing
Exit Sub
Class_TerminateTrap:
SMSWSErrorHandler ("Class_Terminate")
End Sub
Private Sub SMSWSErrorHandler(str_Function As String)
'*****************************************************************
'此子例程是類錯誤處理程序。當(dāng)任何類子例程或函數(shù)
'遇到錯誤時(shí),都可以從該子例程或函數(shù)調(diào)用此子例程。然后,它將引發(fā)錯誤并提供
'調(diào)用子例程或函數(shù)的名稱。
'*****************************************************************
'SOAP 錯誤
If sc_SMSWS.FaultCode <> "" Then
Err.Raise vbObjectError, str_Function, sc_SMSWS.FaultString
'非 SOAP 錯誤
Else
Err.Raise Err.Number, str_Function, Err.Description
End If
End Sub
Public Function wsm_sendXml(ByVal str_Carrier As String, ByVal str_Id As String, ByVal str_Password As String, ByVal str_ToMobile As String, ByVal str_Message As String, ByVal str_MsgType As String) As String
'*****************************************************************
'從 http://smsinter.sina.com.cn/ws/smswebservice0101.wsdl 創(chuàng)建的代理函數(shù)。
'*****************************************************************
'錯誤捕獲
On Error GoTo wsm_sendXmlTrap
wsm_sendXml = sc_SMSWS.sendXml(str_Carrier, str_Id, str_Password, str_ToMobile, str_Message, str_MsgType)
Exit Function
wsm_sendXmlTrap:
SMSWSErrorHandler "wsm_sendXml"
End Function
從代碼可以看出類模塊提供了一個公共方法wsm_sendXml,這就是我們需要的。|站長郵箱|小黑屋|手機(jī)版|Office中國/Access中國 ( 粵ICP備10043721號-1 )
GMT+8, 2024-10-23 10:27 , Processed in 0.059517 second(s), 14 queries .
Powered by Discuz! X3.3
© 2001-2017 Comsenz Inc.