这是我到目前为止的代码(不是我没有写完所有我自己从网上获取帮助)但我无法理解为什么我会收到此错误
Imports CookComputing.XmlRpc
Public Structure blogInfo
Public title As String
Public description As String
End Structure
<XmlRpcUrl("http://127.0.0.1/wordpress/xmlrpc.php")> _
Class MsnSpacesMetaWeblog
Inherits XmlRpcClientProtocol
<XmlRpcMethod("metaWeblog.newPost")> _
Function NewPage(ByVal blogID As Integer, ByVal strUserName As String, ByVal strPassword As String, ByVal content As blogInfo, ByVal publish As Integer) As String
Return CStr(Me.Invoke("newPost", New Object() {blogID, strUserName, strPassword, content, publish}))
End Function
End Class
Public Class Form1
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mw As MsnSpacesMetaWeblog = New MsnSpacesMetaWeblog
Dim newBlogPost As blogInfo
newBlogPost.title = TextBox1.Text
newBlogPost.description = TextBox2.Text
Try
Dim id As String = mw.NewPage(1, "******", "******", newBlogPost, 1)
MsgBox("Posted to Blog successfullly! Post ID : " + id)
TextBox1.Text = ""
TextBox2.Text = ""
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
我得到的错误是“调用不存在或非公共代理方法”
如果有人能解释我做错了什么,我真的很感激
Thnaks
答案 0 :(得分:0)
Imports CookComputing.XmlRpcde
Public Class frmMain 'Form name/class Form1 is the default.
Public Structure category
Public categoryId As Object
Public parentId As Object
Public description As Object
Public categoryName As Object
Public htmlUrl As Object
Public rssUrl As Object
End Structure
<XmlRpcUrl("http://somesite.info/xmlrpc.php")> _
Public Interface IWP
Inherits IXmlRpcProxy
<XmlRpcMethod("wp.getCategories")> _
Function getCategories(ByVal args() As String) As category()
End Interface
Public Structure blogInfo
Public title As String
Public description As String
End Structure
Public Interface IgetCatList
<CookComputing.XmlRpc.XmlRpcMethod("metaWeblog.newPost")> _
Function NewPage(ByVal blogId As Integer, ByVal strUserName As String, ByVal strPassword As String, ByVal content As blogInfo, ByVal publish As Integer) As String
End Interface
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim proxy As IWP = XmlRpcProxyGen.Create(Of IWP)()
Dim args() As String = {"http://somesite.info", _
"AdminUserName", "Password"}
Dim categories() As category
categories = proxy.getCategories(args)
For Each category In categories
Debug.Print(category.categoryId)
Debug.Print(category.categoryName)
Debug.Print(category.description)
Debug.Print(category.htmlUrl)
Debug.Print(category.rssUrl)
Next
End Sub
Private Sub btnPost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPost.Click
Dim newBlogPost As blogInfo = Nothing
newBlogPost.title = "The Title"
newBlogPost.description = "The Post Body Text"
Dim categories = CType(XmlRpcProxyGen.Create(GetType(IgetCatList)), IgetCatList)
Dim clientProtocol = CType(categories, XmlRpcClientProtocol)
clientProtocol.Url = "http://yoursite.com/xmlrpc.php"
Dim result As String = Nothing
result = ""
Try
result = categories.NewPage(1, "AdminUserName", "password", newBlogPost, 1)
MessageBox.Show("Posted to Blog successfullly! Post ID : " & result)
txtpost.Text = ""
txtTitle.Text = ""
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class