错误:响应包含struct期望的整数值

时间:2014-10-11 21:27:57

标签: xml-rpc

我正在使用xml-rpc协议连接到网站:

按钮代码:

Dim proxy As ISapeXmlRpc = XmlRpcProxyGen.Create(Of ISapeXmlRpc)()
Dim userId As Integer = proxy.SapeLogin(formMain.txtUser.Text.Trim(), formMain.txtPass.Text.Trim())
If (userId > 0) Then
    Try
        '// sape.get_project_sites returns array of sites IDs, 
        '// You need to declare SapeGetProjectSites as returns XmlRpcStruct()
        Dim projectSites As XmlRpcStruct() = proxy.SapeGetProjectSites(Convert.ToInt32(gbAnalysis.Text))

        For Each struct As XmlRpcStruct In projectSites
            For Each s As String In struct.Keys
                MessageBox.Show("Key: " + s + " Value: " + struct.Item(s).ToString())
            Next
        Next

    Catch ex As Exception
        formMain.returnMessage("XML-RPC ERROR!" & vbCrLf & vbCrLf & ex.ToString)
    End Try
End If

班级档案:

Imports CookComputing.XmlRpc

<XmlRpcUrl("http://api.site.ru/xmlrpc/")>
Public Interface ISapeXmlRpc
Inherits IXmlRpcProxy

<XmlRpcMethod("sape.login", Description:="Login to sape.ru")>
Function SapeLogin(ByVal login As String, ByVal password As String, Optional ByVal md5 As Boolean = False) As Integer

<XmlRpcMethod("sape.get_user", Description:="Get user info")>
Function SapeGetUser() As UserInfo

<XmlRpcMethod("sape.get_balance_locks", Description:="Get balance locks")>
Function SapeGetRealBalance() As XmlRpcStruct

<XmlRpcMethod("sape.get_sites", Description:="Get sites")>
Function SapeGetSites() As XmlRpcStruct

<XmlRpcMethod("sape.get_project", Description:="Get project")>
Function SapeGetProject(ByVal project_id As Integer) As SapeGetProject

<XmlRpcMethod("sape.get_project_sites", Description:="Get project sites")>
Function SapeGetProjectSites(ByVal project_id As Integer) As XmlRpcStruct()

<XmlRpcMethod("sape.project_update", Description:="Project update")>
Function SapeUpdateProject(ByVal project_id As Integer, ByVal project_params As SapeProjectUpdateStruct) As Boolean
End Interface

我可以通过提琴手看到正在发送请求并收到响应:

<? xml version="1.0" encoding="UTF-8" ?>
<methodResponse>
<params>
<param>
<value>
<array>
<data>
 <value>
  <int>1432907</int>
 </value>
</data>
</array>
</value>
</param>
</params>

错误是:response contains integer value where struct expected [response : array mapped to type XmlRpcStruct[] : element 0]" on this line: "Dim projectSites As XmlRpcStruct() = proxy.SapeGetProjectSites(Convert.ToInt32(gbAnalysis.Text))

我在函数中将其声明为XmlRpcStruct(),我做错了吗?这个协议的信息非常少,因为它不受欢迎。

任何帮助将不胜感激!

0 个答案:

没有答案