Trying to use xmlhttp

Hi everyone I am trying to use xmlrpc in an Access database,  But I am getting the error "The Parameter Is Incorrect" on line
xh.Send

Any ideas ?
Function xmlTest()

Dim xh As Object
Dim strMeth As String
Const c_url = "http://www.someurl.org/admin/xmlrpc.php"


strMeth = "<methodcall>"
strMeth = strMeth & "<methodname>"
strMeth = strMeth & "ses.getNewEnrolmentCount"
strMeth = strMeth & "</methodname>"
strMeth = strMeth & "</methodcall>"



Set xh = CreateObject("Microsoft.xmlhttp")
xh.Open "GET", c_url, False, "someuid", "somepwd"
xh.setRequestHeader "Content-Type", "text/xml"
xh.send strMeth
MsgBox xh.responseBody


End Function

Open in new window

LVL 17
NatchiketAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Here's a blog posting that uses ServerXMLHTTP to work with a remote xmlrpc.php service:

http://www.juust.org/index.php/wordpress-xmlrpc-and-microsoft-access-vba/2009/10/

You might get better results using that method rather than xmlhttp. It's difficult to work with web services from Access, so be prepared for an uphill battle!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NatchiketAuthor Commented:
As usual I end up posting my own solution in there circumstances :)
I am awarding you the full points, LSMConsulting, as I know you need them ::: grin :::
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'clsXMLRPC
'
'This class is purely for retrieving the data from the remote server via xmlrpc
'it takes the place of vbXML and vbXMLRPC dlls which were used hitherto
'
'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Dim moXH As Object               'xmlhttp object
Dim mdb As DAO.Database       '
Dim mstrURL As String           'remote server
Dim mstrUID As String
Dim mstrPWD As String
Dim mstrMode As String
Dim mdicD As New Dictionary


Private Sub Class_Initialize()

Dim rst As DAO.Recordset
Dim strSQL As String

On Error GoTo proc_err

'Set moXH = CreateObject("msxml2.xmlhttp")
'Set moDD = CreateObject("MSXML2.DOMDocument")
Set mdb = CurrentDb

strSQL = "SELECT sysHostName,sysHostURI,sysHostUID,sysHostPWD,sysHostMode FROM tblSysInfo"
Set rst = mdb.OpenRecordset(strSQL, dbOpenSnapshot)

mstrURL = rst!sysHostName & rst!sysHostURI
mstrUID = Nz(rst!sysHostUID, vbNullString)
mstrPWD = Nz(rst!sysHostPWD, vbNullString)
mstrMode = rst!sysHostMode


proc_exit_true:


proc_exit:
Exit Sub

proc_exit_false:
GoTo proc_exit

proc_err:

Select Case ErrHand()
Case ErrAbort
    Resume proc_exit
Case ErrRetry
    Resume
Case ErrIgnore
    Resume Next
End Select




End Sub

Private Function OpenConnection() As Boolean

On Error GoTo proc_err

If moXH Is Nothing Then
    Set moXH = CreateObject("msxml2.xmlhttp")
End If
    

If IsBlank(mstrUID) And IsBlank(mstrPWD) Then
    moXH.Open "post", mstrURL, False
Else
    moXH.Open "post", mstrURL, False, mstrUID, mstrPWD
End If

proc_exit_true:
OpenConnection = True


proc_exit:
Exit Function

proc_exit_false:
MsgBox "Could not connect to " & mstrURL & " failed.", vbExclamation
GoTo proc_exit

proc_err:

Select Case ErrHand()
Case ErrAbort
    Resume proc_exit
Case ErrRetry
    Resume
Case ErrIgnore
    Resume Next
End Select


End Function


Private Function PackageMethod(strMeth As String, Optional varArg = Null) As String
'-------------------------------------------------------------------------------------------------------------------------------------------------------
'Packages up a remote method to send to the server
'
'strMeth   'method name
'varArg    'Argument
'
'-------------------------------------------------------------------------------------------------------------------------------------------------------

Dim strXML As String


strXML = "<methodCall><methodName>" & strMeth & "</methodName>"

If Not IsBlank(varArg) Then
    strXML = strXML & "<params><param><value>"
    
    If IsNumeric(varArg) Then
    
        strXML = strXML & "<int>" & varArg & "</int>"
        
    Else
    
        strXML = strXML & "<string> " & varArg & "</string>"
        
    End If
    
    strXML = strXML & "</value></param></params>"
    
End If

strXML = strXML & "</methodCall>"

PackageMethod = strXML


End Function

Function getNewEnrolmentCount() As Long
'------------------------------------------------------------------------------------------------------------------------------------
'Returns a long integer showing the number of pending enrolments
'Returns -1 if there was an error
'-------------------------------------------------------------------------------------------------------------------------------------

Dim oDD As Object
Dim strXML As String          'XML
Dim oRoot As Object
Dim oNodes As Object
Dim oNode As Object
Dim lngNEC As Long

On Error GoTo proc_err

Set oDD = CreateObject("MSXML2.DOMDocument")

oDD.LoadXML (PackageMethod("ses.getNewEnrolmentCount", mstrMode))

OpenConnection
moXH.Send oDD.xml

strXML = moXH.ResponseText

oDD.LoadXML (strXML)
Set oNodes = oDD.GetElementsByTagName("int")
For Each oNode In oNodes
     lngNEC = CLng(oNode.NodeTypedValue)
Next

getNewEnrolmentCount = lngNEC

proc_exit_true:


proc_exit:
Exit Function

proc_exit_false:
getNewEnrolmentCount = -1
GoTo proc_exit

proc_err:

Select Case ErrHand()
Case ErrAbort
    Resume proc_exit
Case ErrRetry
    Resume
Case ErrIgnore
    Resume Next
End Select


End Function

Function getNewEnrolmentRefs() As String
'--------------------------------------------------------------------------------------------------------------------------------
'returns a comma separated string containing the IDs of the records to be downloaded
'
'retrurns vbNullString if there was an error
'---------------------------------------------------------------------------------------------------------------------------------

Dim oDD As Object
Dim strXML As String          'XML
Dim oRoot As Object
Dim oNodes As Object
Dim oNode As Object
Dim strGER As String

On Error GoTo proc_err

Set oDD = CreateObject("MSXML2.DOMDocument")

oDD.LoadXML (PackageMethod("ses.getNewEnrolmentRefs", mstrMode))

OpenConnection
moXH.Send oDD.xml

strXML = moXH.ResponseText

oDD.LoadXML (strXML)

Set oNodes = oDD.GetElementsByTagName("string")
For Each oNode In oNodes
      strGER = strGER & oNode.NodeTypedValue & ","
Next

getNewEnrolmentRefs = Left(strGER, Len(strGER) - 1)

proc_exit_true:


proc_exit:
Exit Function

proc_exit_false:
getNewEnrolmentRefs = vbNullString
GoTo proc_exit

proc_err:

Select Case ErrHand()
Case ErrAbort
    Resume proc_exit
Case ErrRetry
    Resume
Case ErrIgnore
    Resume Next
End Select


End Function

Function getEnrolment(lngEN As Long) As Boolean
'---------------------------------------------------------------------------------------------------------------------------------------------------------
'Gets the enrolement details for a particular enrolment number
'The details are placed into module variables, accessible through properties
'Returns TRUE if the details were retreieved, otherwise FALSE
'-----------------------------------------------------------------------------------------------------------------------------------------------------------

Dim oDD As Object
Dim strX As String
Dim strXML As String          'XML
Dim oRoot As Object
Dim oNodes As Object
Dim oNode As Object
Dim oCN As Object        'Child Node
Dim strName As String
Dim varValue As Variant
Dim blnN As Boolean         'Field name flag



On Error GoTo proc_err

Set oDD = CreateObject("MSXML2.DOMDocument")

strX = PackageMethod("ses.getEnrolment", lngEN)
oDD.LoadXML (strX)

OpenConnection
moXH.Send oDD.xml

strXML = moXH.ResponseText

oDD.LoadXML (strXML)

'Debug.Print strXML
blnN = True

Set oNodes = oDD.GetElementsByTagName("member")
For Each oNode In oNodes
    For Each oCN In oNode.ChildNodes
        'Debug.Print oCN.NodeTypedValue & ","
        If blnN Then
            strName = oCN.NodeTypedValue
            blnN = False
        Else
            mdicD.Add strName, oCN.NodeTypedValue
            blnN = True
        End If
     Next
Next



proc_exit_true:
getEnrolment = True

proc_exit:
Exit Function

proc_exit_false:
getEnrolment = False
GoTo proc_exit

proc_err:

Select Case ErrHand()
Case ErrAbort
    Resume proc_exit
Case ErrRetry
    Resume
Case ErrIgnore
    Resume Next
End Select

End Function

Function GEV(strMem) As Variant
'-----------------------------------------------------------------------------------------------
'GEV ... get enrolment value
'Retrieves a value from the enrolment dictionary
'Argument strMem -- member name
'-------------------------------------------------------------------------------------------------
GEV = mdicD.Item(strMem)
End Function

Function setSynchronised(lngEN) As Boolean
'--------------------------------------------------------------------------------------------------------------------------------------------
'Sets the synchronisation flag for a MySQL record
'-----------------------------------------------------------------------------------------------------------------------------------------------

On Error GoTo proc_err

Dim oDD As Object
Dim strX As String
Dim strXML As String          'XML
Dim strName As String
Dim varValue As Variant
Dim blnN As Boolean         'Field name flag



On Error GoTo proc_err

Set oDD = CreateObject("MSXML2.DOMDocument")

strX = PackageMethod("ses.setSynchronised", lngEN)
oDD.LoadXML (strX)

OpenConnection
moXH.Send oDD.xml

strXML = moXH.ResponseText


proc_exit_true:
setSynchronised = True

proc_exit:
Exit Function

proc_exit_false:
setSynchronised = False
GoTo proc_exit

proc_err:

Select Case ErrHand()
Case ErrAbort
    Resume proc_exit
Case ErrRetry
    Resume
Case ErrIgnore
    Resume Next
End Select
End Function

Function TestLibraries() As Boolean
'Checks to see if the libraries for XMLRPC can instantiate
Dim lngErr As Long

On Error Resume Next

Dim oXH As Object
Dim oDD As Object

Set oXH = CreateObject("msxml2.xmlhttp")
lngErr = Err.Number

Set oDD = CreateObject("MSXML2.DOMDocument")
lngErr = lngErr + Err.Number

Set oXH = Nothing
Set oDD = Nothing

TestLibraries = (lngErr = 0)

End Function

Open in new window

0
NatchiketAuthor Commented:
I'm talking about my solution!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.