All,
I am trying to build an XML-RPC client in VB.NET and I want to know
how it is possible to connect to a stand-alone server. By stand-alone
server I mean a server not hosted on a web server. In fact the
XML-RPC server is a Perl script running under Linux (see
http://radio.weblogs.com/0111823/categories/mySoftware/2002/09/09.html#a47).
When I set the URI property (proxy.Url = "192.168.0.51:1234"), which
is not an URL, of the proxy, then run the program I get this error
message: "XML-RPC server exception: Invalid URI: The URI scheme is
not valid".
How should I set this property?
Here is the relevant snippet of code:
Imports CookComputing.XmlRpc
Imports System.Net
Public Class Form1
Inherits System.Windows.Forms.Form
Dim XmlRpcClient As CookComputing.XmlRpc.XmlRpcClientProtocol
Public Class GetPostProxy
Inherits XmlRpcClientProtocol
Public Function getpost(ByVal
NNTPServer As String, ByVal groupname As String, ByVal number As
String) As String
Return Invoke("getpost", New Object() {NNTPServer,
groupname, number})
End Function
End Class
Private Function HandleException(ByVal ex As Exception)
Dim msgBoxTitle As String = "Error"
Try
Throw ex
Catch fex As XmlRpcFaultException
MessageBox.Show("Fault response: " + fex.FaultCode + " "
+ fex.FaultString, msgBoxTitle, MessageBoxButtons.OK,
MessageBoxIcon.Error)
Catch webex As WebException
MessageBox.Show("Web exception: " + webex.Message,
msgBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
Catch xmlrpcex As XmlRpcServerException
MessageBox.Show("XML-RPC server exception: " +
xmlrpcex.Message, msgBoxTitle, MessageBoxButtons.OK,
MessageBoxIcon.Error)
Catch defex As Exception
MessageBox.Show("XML-RPC server exception: " +
defex.Message, msgBoxTitle, MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Cursor = Cursors.WaitCursor
Try
Dim proxy As New GetPostProxy()
proxy.Url = "192.168.0.51:1234"
Dim NNTPServer As String = Convert.ToString(TextBox1.Text)
Dim GroupName As String = Convert.ToString(TextBox2.Text)
Dim Number As String = Convert.ToString(TextBox4.Text)
TextBox3.Text = proxy.getpost(NNTPServer, GroupName,
Number)
Cursor = Cursors.Default
Catch ex As Exception
HandleException(ex)
End Try
End Sub
End Class
I am aware that more bugs may creep off this code which isn't finished
yet. I am writing this code to get to know VB.NET and Charles XML-RPC
library.
Thanks for your help
Charles Nadeau
http://radio.weblogs.com/0111823/