If you need to interact with Websrices from within Microsoft Office there are at leat two options:
1. Use the Microsoft Webservices Toolkits --
For Access XP (2002) http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=15036
For Access 2003 -- http://www.microsoft.com/download/en/details.aspx?id=2224
For Access 2007 or 2010 - There is no toolkit. Use VSTO -- http://msdn.microsoft.com/en-us/office/hh133430
2. Use your own code - OK for simple messages
Private Function PostToWeb(ByVal strURL As String, ByVal strData As String) As String
Dim objXmlHttp As MSXML2.XMLHTTP
Dim strRet As String
Const FUNC_NAME = MOD_NAME & "PostToWeb"
10 On Error GoTo func_err
Dim b As Boolean
Dim objDom As MSXML2.DOMDocument
Dim objNode As MSXML2.IXMLDOMNode
20 strData = IIf(LenB(strData) > 0, strData & "&", "") & "osekMorshe=" & m_osekMorshe & "&installationID=" & m_installationID & "&nvcPassword=" & m_nvcPassword
' Create objects to DOMDocument and XMLHTTP
30 Set objXmlHttp = CreateObject("MSXML2.XMLHTTP")
' Open the webservice
40 objXmlHttp.Open "POST", strURL, False
' Create headings
50 objXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
60 objXmlHttp.setRequestHeader "Content-Length", Len(strData)
' Send XML command
70 objXmlHttp.send strData
' Get all response text from webservice
80 strRet = objXmlHttp.responseText
' Close object
90 Set objXmlHttp = Nothing
100 Set objDom = CreateObject("MSXML2.DOMDocument")
110 b = objDom.loadXML(strRet)
120 If Not b Then Err.Raise 7999, "", strRet
150 GetNextChangeID = strRet
170 PostToWeb = strRet
180 Exit Function
func_err:
190 Err.Raise Err.Number, FUNC_NAME & "[" & Erl & "]" & "\" & Err.Source, Err.Description & vbCrLf & "ëúåáú äùøú: " & strURL
End Function
1. Use the Microsoft Webservices Toolkits --
For Access XP (2002) http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=15036
For Access 2003 -- http://www.microsoft.com/download/en/details.aspx?id=2224
For Access 2007 or 2010 - There is no toolkit. Use VSTO -- http://msdn.microsoft.com/en-us/office/hh133430
2. Use your own code - OK for simple messages
Private Function PostToWeb(ByVal strURL As String, ByVal strData As String) As String
Dim objXmlHttp As MSXML2.XMLHTTP
Dim strRet As String
Const FUNC_NAME = MOD_NAME & "PostToWeb"
10 On Error GoTo func_err
Dim b As Boolean
Dim objDom As MSXML2.DOMDocument
Dim objNode As MSXML2.IXMLDOMNode
20 strData = IIf(LenB(strData) > 0, strData & "&", "") & "osekMorshe=" & m_osekMorshe & "&installationID=" & m_installationID & "&nvcPassword=" & m_nvcPassword
' Create objects to DOMDocument and XMLHTTP
30 Set objXmlHttp = CreateObject("MSXML2.XMLHTTP")
' Open the webservice
40 objXmlHttp.Open "POST", strURL, False
' Create headings
50 objXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
60 objXmlHttp.setRequestHeader "Content-Length", Len(strData)
' Send XML command
70 objXmlHttp.send strData
' Get all response text from webservice
80 strRet = objXmlHttp.responseText
' Close object
90 Set objXmlHttp = Nothing
100 Set objDom = CreateObject("MSXML2.DOMDocument")
110 b = objDom.loadXML(strRet)
120 If Not b Then Err.Raise 7999, "", strRet
150 GetNextChangeID = strRet
170 PostToWeb = strRet
180 Exit Function
func_err:
190 Err.Raise Err.Number, FUNC_NAME & "[" & Erl & "]" & "\" & Err.Source, Err.Description & vbCrLf & "ëúåáú äùøú: " & strURL
End Function
אין תגובות:
הוסף רשומת תגובה