Question XML-RPC, struct value where string expected

digitaldrew

Well-known member
Joined
Nov 10, 2012
Messages
167
Programming Experience
Beginner
I'm trying to create a new user contact using XML-RPC (the the xml-rpc.net library), but I seam to be having an issue with my structure (I think..)

First, this is what I'm working with:
bU5SpTS.jpg


and the parameters:
ksU10yQ.jpg



Now, here is what I have in my code:
VB.NET:
Imports CookComputing.XmlRpc

Public Structure gandiContactDetails
    Public city As String
    Public country As String
    Public email As String
    Public family As String
    Public given As String
    Public password As String
    Public phone As String
    Public streetaddr As String
    Public type As String
End Structure

Public Interface createContact
    <CookComputing.XmlRpc.XmlRpcMethod("contact.create")> _
    Function GandiContact(ByVal apikey As String, ByVal params As gandiContactDetails) As String
End Interface

Public Class Form1
    Public clientProtocol As XmlRpcClientProtocol
    Public createcontacts As createContact

    Private Sub btnCreateContact_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateContact.Click
   '=========== Some inputboxes here to get the required details. ===========

        Dim Parameters As gandiContactDetails
        Parameters.city = gandicity
        Parameters.country = gandicountry
        Parameters.email = gandiemail
        Parameters.family = gandifamily
        Parameters.given = gandigiven
        Parameters.password = gandipassword
        Parameters.phone = gandiphone
        Parameters.streetaddr = gandistreetaddr
        Parameters.type = "0"

        createcontacts = CType(XmlRpcProxyGen.Create(GetType(createContact)), createContact)
        clientProtocol = CType(createcontacts, XmlRpcClientProtocol)

        clientProtocol.Url = "https://rpc.websitehere.net/xmlrpc/"

        Dim response As String
        response = ""

        Try
            response = createcontacts.GandiContact(txtGandiApiKey.Text, Parameters)
            MsgBox(response)
        Catch ex As Exception
            MsgBox("Error: " & ex.Message)
        End Try
    End Sub
End Class


Finally, this is the error I continue to receive..
Error: response contains struct value where string expected (as type String) [response]


I can't see where I'm going wrong here..Any help/input would be greatly appriciated!
 
Thanks for your reply @JohnH! You made a good point about looking for the highlighted line... I previously had it in a Try/Catch so it wasn't highlighting.

It looks to be highlighting specifically
VB.NET:
response = proxy.ContactCreate(txtGandiApiKey.Text, params)

and it is a nullReferenceException (Object reference not set to an instance of an object.)....I'm using an input box for the country just as all the others. Just for testing I threw messageboxes in there to look at each string before setting the parameters and all look good. The country should be a capitalized two-letter ISO and that's how I appear to be passing it. I'll do some more messing around with it, apparently it see's something as being null...

Thanks again!
 
So I just wanted to post another update on where I'm at. I've done some more messing around, but haven't made much progress...


If I run the code below...I get this error (which is strange because the parameter orgnam isn't required):
Server returned a fault exception: [500037] Error on object : OBJECT_UNKNOWN (CAUSE_BADPARAMETER) [missing field orgname]

VB.NET:
            Dim params As New XmlRpcStruct
            params("given") = "John" 'gandigiven
            params("family") = "Doe" 'gandifamily
            params("email") = "john@doe.com" 'gandiemail
            params("streetaddr") = "500 Main Street" 'gandistreetaddr
            params("city") = "Houston" 'gandicity
            params("country") = "US" 'gandicountry
            params("phone") = "+33.123456789" 'gandiphone
            params("type") = "1"
            params("password") = "password123" 'gandipassword

            Dim extra_parameters As New XmlRpcStruct
            extra_parameters("x-au_registrant_id_number") = "12345678" 'txtgandiAuIdNumber.Text
            extra_parameters("x-au_registrant_id_type") = "ABN" 'txtgandiAuIdType.Text
            extra_parameters("x-ca_legaltype") = "CCO" 'txtgandiCaType.Text
            extra_parameters("x-ca_owner_name") = "John Doe" 'txtgandiCaName.Text
            extra_parameters("x-it_pin") = "12345678" 'txtgandiItPin.Text
            extra_parameters("x-ru_registrant_passport_data") = "123456" 'txtgandiRuPassport.Text"
            extra_parameters("x-se_ident_number") = "1234567" 'txtgandiSeIdent.Text
            'set other extra_parameters members
            params("extra_parameters") = extra_parameters

            Dim proxy = XmlRpcProxyGen.Create(Of IGandi)()
            Dim response = proxy.ContactCreate(txtGandiApiKey.Text, params)

            Dim handle = response("handle")


If I try adding that parameter (like the code below)..I'm back to the NullReferenceException was Unhandled..
VB.NET:
            Dim params As New XmlRpcStruct
            params("given") = "John" 'gandigiven
            params("family") = "Doe" 'gandifamily
            params("email") = "john@doe.com" 'gandiemail
            params("streetaddr") = "500 Main Street" 'gandistreetaddr
            params("city") = "Houston" 'gandicity
            params("country") = "US" 'gandicountry
            params("phone") = "+33.123456789" 'gandiphone
            params("type") = "1"
            params("password") = "password123" 'gandipassword
            params("orgname") = "Test Organization"

            Dim extra_parameters As New XmlRpcStruct
            extra_parameters("x-au_registrant_id_number") = "12345678" 'txtgandiAuIdNumber.Text
            extra_parameters("x-au_registrant_id_type") = "ABN" 'txtgandiAuIdType.Text
            extra_parameters("x-ca_legaltype") = "CCO" 'txtgandiCaType.Text
            extra_parameters("x-ca_owner_name") = "John Doe" 'txtgandiCaName.Text
            extra_parameters("x-it_pin") = "12345678" 'txtgandiItPin.Text
            extra_parameters("x-ru_registrant_passport_data") = "123456" 'txtgandiRuPassport.Text"
            extra_parameters("x-se_ident_number") = "1234567" 'txtgandiSeIdent.Text
            'set other extra_parameters members
            params("extra_parameters") = extra_parameters

            Dim proxy = XmlRpcProxyGen.Create(Of IGandi)()
            Dim response = proxy.ContactCreate(txtGandiApiKey.Text, params)

            Dim handle = response("handle")

Also..I was looking at another example here..Maybe the API key needs to be sent differently, like it is in their example? I tried this...
VB.NET:
Dim gApiKey = txtGandiApiKey.Text.ToString

No difference though.
 
Last edited:
It looks to be highlighting specifically
Dim response = proxy.ContactCreate(txtGandiApiKey.Text, params)
Either it is, or it don't. Did you know you can mouse hover each part in a code line when debugger has stopped on throw/break, to see their current state? Immediate window can also be used to query objects current state. Nullreference exception is thrown when you try to access anything on something that is Nothing, for example if proxy is Nothing then Nothing.ContactCreate will throw, if txtGandiApiKey is Nothing then Nothing.Text will throw.

Change txtGandiApiKey.Text to a string with the key to be sure:
Dim response = proxy.ContactCreate("the key", params)

Although, in your post 17 you say that code line was ok, since you got a "Server returned a fault exception". That is not consistent with what you said in post (16).
 
Hey JohnH, thanks for your reply! As usual, your response has taught me something new, lol. I've now tried hovering over the yellow area and can see the Nothing..

On a side note, hard-coding the API key didn't seam to do anything.

This is what appears when hovering over 'response'
error1.jpg

Then, when I hover over 'proxy' I would say things look good
error2.jpg

Finally, when hovering over the 'handle' it also shows "Nothing" (Probably because the response is currently throwing nothing?)
error3.jpg
 
Last edited:
So just another update..I've been messing with things some more, but still not much luck.

I notice the responses are usually smart enough to tell me if a required parameter is missing or invalid..Therefor, I'm not really sure if this 'Null' issue is has anything to do with the parameters...

1) Would it be needed to set "As New" for the return XmlRpcStruct?

2) This particular line of code tells me: Public Shared Fuction Create(Of Application.IGandi)() As Application.IGandi
VB.NET:
Dim proxy = XmlRpcProxyGen.Create(Of IGandi)()

Should this be something along the lines of 'As New Application.IGandi'?

3) Would it maybe help to put the XmlStructure params into an array? For example:
VB.NET:
Function ContactCreate(ByVal apikey As String, ByVal params() As XmlRpcStruct) As XmlRpcStruct()


Just an update of my current code...
VB.NET:
Imports CookComputing.XmlRpc
Imports System.Web

<XmlRpcUrl("https://rpc.ote.gandi.net/xmlrpc/")> _
Public Interface IGandi
    <XmlRpcMethod("contact.create")> _
    Function ContactCreate(ByVal apikey As String, ByVal params As XmlRpcStruct) As XmlRpcStruct
End Interface

Public Class GandiApi
    Public Sub createGandiContact()
            Dim params As New XmlRpcStruct
            params("given") = "John"
            params("family") = "Doe"
            params("email") = "john@doe.com"
            params("streetaddr") = "500 Main Street"
            params("city") = "Chicago"
            params("country") = "US"
            params("phone") = "+33.123456789"
            params("type") = "0"
            params("password") = "password"

            If txtgandiAuIdNumber.Text <> "" Or txtgandiCaType.Text <> "" Or txtgandiItPin.Text <> "" Or _
                txtgandiRuPassport.Text <> "" Or txtgandiSeIdent.Text <> "" Then
                Dim extra_parameters As New XmlRpcStruct
                If txtgandiAuIdNumber.Text <> "" And txtgandiAuIdType.Text <> "" Then
                    extra_parameters("x-au_registrant_id_number") = txtgandiAuIdNumber.Text
                    extra_parameters("x-au_registrant_id_type") = txtgandiAuIdType.Text
                End If
                If txtgandiCaType.Text <> "" And txtgandiCaType.Text <> "" Then
                    extra_parameters("x-ca_legaltype") = txtgandiCaType.Text
                    extra_parameters("x-ca_owner_name") = txtgandiCaName.Text
                End If
                If txtgandiItPin.Text <> "" Then
                    extra_parameters("x-it_pin") = txtgandiItPin.Text
                End If
                If txtgandiRuPassport.Text <> "" Then
                    extra_parameters("x-ru_registrant_passport_data") = txtgandiRuPassport.Text
                End If
                If txtgandiSeIdent.Text <> "" Then
                    extra_parameters("x-se_ident_number") = txtgandiSeIdent.Text
                End If
                params("extra_parameters") = extra_parameters
            End If

            Dim proxy = XmlRpcProxyGen.Create(Of IGandi)()
            Dim response = proxy.ContactCreate(txtGandiApiKey.Text, params)
            Dim handle = response("handle")
            MsgBox(handle)
    End Sub
 
This is what appears when hovering over 'response'
response is Nothing at that point because the proxy call has not yet completed to return anything.
Then, when I hover over 'proxy' I would say things look good
Looks so.
Finally, when hovering over the 'handle' it also shows "Nothing" (Probably because the response is currently throwing nothing?)
That line of code has not yet been executed at that time.
Update..just a few other screenshots. But, I still can't see where the issue is.
Neither can I. Stack trace and possibly inner exception may tell you more.

1) Would it be needed to set "As New" for the return XmlRpcStruct?
It is not you that is creating the response, it is the return value of that web service call.
2) This particular line of code tells me: Public Shared Fuction Create(Of Application.IGandi)() As Application.IGandi
Should this be something along the lines of 'As New Application.IGandi'?
No, that is the function definition of the library method, you can't change that.
3) Would it maybe help to put the XmlStructure params into an array? For example:
Web service method definition says it takes a single 'params struct' as input, not an array.
 
Just an update of my current code...
Well, I'll be... a "bug" snuck into my post 13, I copy/pasted and manually modified the interface to match your service as example, but based on other xml-rpc.net examples it is missing inherits statement and should be:
Public Interface IGandi : Inherits IXmlRpcProxy

I have test this with the sample StateName service, and for me it has no consequence whether the interface inherits IXmlRpcProxy or not, but since all their samples include it you should too just to be sure.
 
Thanks for your reply JohnH! Not really sure if this would help at all...

Stack trace:
VB.NET:
   at CookComputing.XmlRpc.XmlRpcStruct.Add(Object key, Object value)
   at CookComputing.XmlRpc.XmlRpcSerializer.ParseHashtable(XmlNode node, Type valueType, ParseStack parseStack, MappingAction mappingAction)
   at CookComputing.XmlRpc.XmlRpcSerializer.ParseValue(XmlNode node, Type ValueType, ParseStack parseStack, MappingAction mappingAction, Type& ParsedType, Type& ParsedArrayType)
   at CookComputing.XmlRpc.XmlRpcSerializer.ParseValue(XmlNode node, Type ValueType, ParseStack parseStack, MappingAction mappingAction)
   at CookComputing.XmlRpc.XmlRpcSerializer.DeserializeResponse(XmlDocument xdoc, Type returnType)
   at CookComputing.XmlRpc.XmlRpcSerializer.DeserializeResponse(Stream stm, Type svcType)
   at CookComputing.XmlRpc.XmlRpcClientProtocol.ReadResponse(XmlRpcRequest req, WebResponse webResp, Stream respStm, Type returnType)
   at CookComputing.XmlRpc.XmlRpcClientProtocol.Invoke(Object clientObj, MethodInfo mi, Object[] parameters)
   at CookComputing.XmlRpc.XmlRpcClientProtocol.Invoke(MethodInfo mi, Object[] Parameters)
   at XmlRpcProxy2b5ce216-db8b-48a9-9740-aecc254fe0d9.ContactCreate(String apikey, XmlRpcStruct params)
   at ApplicationName.GandiApi.createGandiContact() in C:\Users\Drew\Documents\Visual Studio 2010\Projects\WindowsApplication1\WindowsApplication1\Gandi\GandiApi.vb:line 167
   at ApplicationName.GandiApi.btnSubmit_Click(Object sender, EventArgs e) in C:\Users\Drew\Documents\Visual Studio 2010\Projects\WindowsApplication1\WindowsApplication1\Gandi\GandiApi.vb:line 95
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(ApplicationContext context)
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   at ApplicationName.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

The InnerException is Nothing (not really sure what that means)..You can see a screenshot below:
detail.jpg

Once again, thanks for taking the time to help me with this!

Also, thanks for the Inherits IXmlRpcProxy idea..I noticed that in their examples as well and tried adding that last night (directly below the Public Interface line), but it also didn't do anything. I just tested again, but same error.
 
Stacktrace is telling me that during the deserialization process of the response xml a call to XmlRpcStruct.Add is throwing the nullreference exception. This is probably either a bug in the CookComputing.XmlRpc library or a malformed response from the web service. There are some options that can be set on proxy object, for example the NonStandard property, but I wouldn't know if any of those is relevant for your service.
 
Hey JohnH - Thanks for replying. So, I think I've made a little more progress..Just a few things:

1) It looks like the CookComputing DLL file I had may have been outdated. I went to the website and downloaded/imported a fresh DLL file. Now, when running the same code as before, I get a different errror:
nil.jpg

2) Now that it's telling me one of the values (I'm assuming of the 'response') is nil, I started looking at how to tell XMLRPC to ignore nil rows....I was looking specifically here:
XML-RPC.NET FAQ - Under 'Struct Members'

They give an example in C, which I've tried converting to VB and basically came up with this
VB.NET:
Public Structure TestStruct
    <XmlRpcMissingMapping(MappingAction.Ignore)> _
    Public x As System.Nullable(Of Integer)
    <XmlRpcNullMapping(NullMappingAction.[Error])> _
    Public y As System.Nullable(Of Integer)
    <XmlRpcNullMapping(NullMappingAction.Nil)> _
    Public z As System.Nullable(Of Integer)
End Structure

Public Enum NullMappingAction
    Ignore = 0
    [Error] = 1
    Nil = 2
End Enum

In this instance, would it better to use Ignore so it just ignores it, or Nil so that it just places a 'Nil' where it would normally be null? Since I don't have any structures defined anymore, where would I go about placing <XmlRpcNullMapping(NullMappingAction.Nil)> _ or <XmlRpcNullMapping(NullMappingAction.Ignore)> _?

I've tried a few things..for example:
VB.NET:
<XmlRpcUrl("https://rpc.ote.gandi.net/xmlrpc/")> _
 <XmlRpcNullMapping(NullMappingAction.Ignore)> _
Public Interface IGandi : Inherits IXmlRpcProxy
    <XmlRpcMethod("contact.create")> _
    Function ContactCreate(ByVal apikey As String, ByVal params As XmlRpcStruct) As XmlRpcStruct
End Interface

The above code tells me 'Type 'XmlRpcNullMapping' is not defined'

and

VB.NET:
<XmlRpcNullMapping(NullMappingAction.Ignore)> _
<XmlRpcUrl("https://rpc.ote.gandi.net/xmlrpc/")> _
 Public Interface IGandi : Inherits IXmlRpcProxy
    <XmlRpcMethod("contact.create")> _
    Function ContactCreate(ByVal apikey As String, ByVal params As XmlRpcStruct) As XmlRpcStruct
End Interface

and the above code tell me the same thing.

Just a quick update of how my code looks now (with the error above)
VB.NET:
Imports CookComputing.XmlRpc
Imports System.Web

<XmlRpcNullMapping(NullMappingAction.Ignore)> _
<XmlRpcUrl("https://rpc.ote.gandi.net/xmlrpc/")> _
 Public Interface IGandi : Inherits IXmlRpcProxy
    <XmlRpcMethod("contact.create")> _
    Function ContactCreate(ByVal apikey As String, ByVal params As XmlRpcStruct) As XmlRpcStruct
End Interface

Public Enum NullMappingAction
    Ignore = 0
    [Error] = 1
    Nil = 2
End Enum

Public Class GandiApi
    Public Sub createGandiContact()
        If txtGandiApiKey.Text = "" Then
            MsgBox("You Must Enter Your Gandi API Key before Creating a Contact!")
            Exit Sub
        Else
            Dim params As New XmlRpcStruct
            params("given") = "John"
            params("family") = "Doe"
            params("email") = "john@doe.com"
            params("streetaddr") = "500 Main Street"
            params("city") = "Chicago"
            params("country") = "US"
            params("phone") = "+33.123456789"
            params("type") = "1"
            params("password") = "password"
            params("orgname") = "Test Organization"

            If txtgandiAuIdNumber.Text <> "" Or txtgandiCaType.Text <> "" Or txtgandiItPin.Text <> "" Or _
                txtgandiRuPassport.Text <> "" Or txtgandiSeIdent.Text <> "" Then
                Dim extra_parameters As New XmlRpcStruct
                If txtgandiAuIdNumber.Text <> "" And txtgandiAuIdType.Text <> "" Then
                    extra_parameters("x-au_registrant_id_number") = txtgandiAuIdNumber.Text
                    extra_parameters("x-au_registrant_id_type") = txtgandiAuIdType.Text
                End If
                If txtgandiCaType.Text <> "" And txtgandiCaType.Text <> "" Then
                    extra_parameters("x-ca_legaltype") = txtgandiCaType.Text
                    extra_parameters("x-ca_owner_name") = txtgandiCaName.Text
                End If
                If txtgandiItPin.Text <> "" Then
                    extra_parameters("x-it_pin") = txtgandiItPin.Text
                End If
                If txtgandiRuPassport.Text <> "" Then
                    extra_parameters("x-ru_registrant_passport_data") = txtgandiRuPassport.Text
                End If
                If txtgandiSeIdent.Text <> "" Then
                    extra_parameters("x-se_ident_number") = txtgandiSeIdent.Text
                End If
                params("extra_parameters") = extra_parameters
            End If

            Dim proxy = XmlRpcProxyGen.Create(Of IGandi)()
            Dim response = proxy.ContactCreate(txtGandiApiKey.Text, params)
            Dim handle = response("handle")
            MsgBox(handle)
        End If
    End Sub
End Class

Thanks again!!
 
It looks like the CookComputing DLL file I had may have been outdated.
v.2.5 is current, but v.3 where support for <nil> extension was added is "work in progress".
I'm assuming of the 'response') is nil
It could be, it could not be.

Regarding <nil> I read this for v.3 (maybe 'struct members' is excluded) :
1.18 Does XML-RPC.NET support the <nil> extension?

XML-RPC.NET supports the <nil> extension by default without any additional configuration.
Regarding NullMappingAction: Don't do that. That enumeration is defined in library. XmlRpcNullMapping attribute can only be applied to field/property and structure/class.

XmlRpcStruct class has no attributes applied to it, and default NullMappingAction is Error. I would first try adding a class that inherits XmlRpcStruct and apply XmlRpcNullMapping to it, and use that as interface method return type. For example:
<XmlRpcNullMapping(NullMappingAction.Ignore)>
Public Class NullableXmlRpcStruct : Inherits XmlRpcStruct
End Class

Function ContactCreate(...) As NullableXmlRpcStruct
 
Thanks for your response JohnH! Just a few things..

1) Is there really any difference between creating a NullMappingAction Enum (like in my last reply), or just doing it how we were before with regular MappingAction? For example:
Before: <XmlRpcMissingMapping(MappingAction.Ignore)> _
Now: <XmlRpcNullMapping(NullMappingAction.Ignore)> _

Here is the code I'm working with now..I still seam to be getting the <nil> error though. Does it look like I have it setup correctly?

VB.NET:
Imports CookComputing.XmlRpc
Imports System.Web

<XmlRpcUrl("https://rpc.ote.gandi.net/xmlrpc/")> _
Public Interface IGandi : Inherits IXmlRpcProxy
    <XmlRpcMethod("contact.create")> _
    Function ContactCreate(ByVal apikey As String, ByVal params As XmlRpcStruct) As NullableXmlRpcStruct
End Interface

Public Enum NullMappingAction
    Ignore = 0
    [Error] = 1
    Nil = 2
End Enum

Public Class GandiApi
    Public Sub createGandiContact()
        If txtGandiApiKey.Text = "" Then
            MsgBox("You Must Enter Your Gandi API Key before Creating a Contact!")
            Exit Sub
        Else
            Dim params As New XmlRpcStruct
            params("given") = "John"
            params("family") = "Doe"
            params("email") = "john@doe.com"
            params("streetaddr") = "500 Main Street"
            params("city") = "Chicago"
            params("country") = "US"
            params("phone") = "+33.123456789"
            params("type") = "1"
            params("password") = "password"
            params("orgname") = "Caught by DesktopCatcher"

            If txtgandiAuIdNumber.Text <> "" Or txtgandiCaType.Text <> "" Or txtgandiItPin.Text <> "" Or _
                txtgandiRuPassport.Text <> "" Or txtgandiSeIdent.Text <> "" Then
                Dim extra_parameters As New XmlRpcStruct
                If txtgandiAuIdNumber.Text <> "" And txtgandiAuIdType.Text <> "" Then
                    extra_parameters("x-au_registrant_id_number") = txtgandiAuIdNumber.Text
                    extra_parameters("x-au_registrant_id_type") = txtgandiAuIdType.Text
                End If
                If txtgandiCaType.Text <> "" And txtgandiCaType.Text <> "" Then
                    extra_parameters("x-ca_legaltype") = txtgandiCaType.Text
                    extra_parameters("x-ca_owner_name") = txtgandiCaName.Text
                End If
                If txtgandiItPin.Text <> "" Then
                    extra_parameters("x-it_pin") = txtgandiItPin.Text
                End If
                If txtgandiRuPassport.Text <> "" Then
                    extra_parameters("x-ru_registrant_passport_data") = txtgandiRuPassport.Text
                End If
                If txtgandiSeIdent.Text <> "" Then
                    extra_parameters("x-se_ident_number") = txtgandiSeIdent.Text
                End If
                params("extra_parameters") = extra_parameters
            End If

            Dim proxy = XmlRpcProxyGen.Create(Of IGandi)()
            Dim response = proxy.ContactCreate(txtGandiApiKey.Text, params)
            Dim handle = response("handle")
            MsgBox(handle)
        End If
    End Sub
End Class

<XmlRpcNullMapping(NullMappingAction.Ignore)>
Public Class NullableXmlRpcStruct : Inherits XmlRpcStruct
End Class

When using the "XmlRpcNullMapping" option it tells me I need to generate a class for it. this is what the class looks like:
VB.NET:
NotInheritable Class XmlRpcNullMappingAttribute
    Inherits Attribute

    Private _nullMappingAction As NullMappingAction

    Sub New(ByVal nullMappingAction As NullMappingAction)
        ' TODO: Complete member initialization 
        _nullMappingAction = nullMappingAction
    End Sub
End Class

Thanks again for all your help on this! Sorry if I'm not implementing it correctly :|
 
Last edited:
difference between creating a NullMappingAction Enum
Library attribute type CookComputing.XmlRpc.XmlRpcNullMapping takes library enum type CookComputing.XmlRpc.NullMappingAction as argument. If you don't get a compiler error trying to use your own type as argument it means you have Option Strict off, you should turn it on to avoid such unnecessary coding errors.
When using the "XmlRpcNullMapping" option it tells me I need to generate a class for it.
Get rid of your erroneous NullMappingAction and XmlRpcNullMappingAttribute types, they are defined in library.
 
Thanks again for your reply JohnH! Are you certain XmlRpcNullMapping is defined in the library? When removing the XmlRpcNullMappingAttribute.vb I get a squiggly blue line under <XmlRpcNullMapping tell me to define the type. Just a quick update of my code right now.

VB.NET:
Option Strict On
Imports CookComputing.XmlRpc
Imports System.Web

<XmlRpcUrl("https://rpc.ote.gandi.net/xmlrpc/")> _
Public Interface IGandi : Inherits IXmlRpcProxy
    <XmlRpcMethod("contact.create")> _
    Function ContactCreate(ByVal apikey As String, ByVal params As XmlRpcStruct) As NullableXmlRpcStruct
End Interface

Public Class GandiApi
    Public Sub createGandiContact()
        If txtGandiApiKey.Text = "" Then
            MsgBox("You Must Enter Your Gandi API Key before Creating a Contact!")
            Exit Sub
        Else
            Dim params As New XmlRpcStruct
            params("given") = "John"
            params("family") = "Doe"
            params("email") = "john@doe.com"
            params("streetaddr") = "500 Main Street"
            params("city") = "Chicago"
            params("country") = "US"
            params("phone") = "+33.123456789"
            params("type") = "1"
            params("password") = "password"
            params("orgname") = "Caught by DesktopCatcher"

            If txtgandiAuIdNumber.Text <> "" Or txtgandiCaType.Text <> "" Or txtgandiItPin.Text <> "" Or _
                txtgandiRuPassport.Text <> "" Or txtgandiSeIdent.Text <> "" Then
                Dim extra_parameters As New XmlRpcStruct
                If txtgandiAuIdNumber.Text <> "" And txtgandiAuIdType.Text <> "" Then
                    extra_parameters("x-au_registrant_id_number") = txtgandiAuIdNumber.Text
                    extra_parameters("x-au_registrant_id_type") = txtgandiAuIdType.Text
                End If
                If txtgandiCaType.Text <> "" And txtgandiCaType.Text <> "" Then
                    extra_parameters("x-ca_legaltype") = txtgandiCaType.Text
                    extra_parameters("x-ca_owner_name") = txtgandiCaName.Text
                End If
                If txtgandiItPin.Text <> "" Then
                    extra_parameters("x-it_pin") = txtgandiItPin.Text
                End If
                If txtgandiRuPassport.Text <> "" Then
                    extra_parameters("x-ru_registrant_passport_data") = txtgandiRuPassport.Text
                End If
                If txtgandiSeIdent.Text <> "" Then
                    extra_parameters("x-se_ident_number") = txtgandiSeIdent.Text
                End If
                params("extra_parameters") = extra_parameters
            End If

            Dim proxy = XmlRpcProxyGen.Create(Of IGandi)()
            Dim response = proxy.ContactCreate(txtGandiApiKey.Text, params)
            Dim handle = response("handle")
            MsgBox(handle)
        End If
    End Sub
End Class

<XmlRpcNullMapping(NullMappingAction.Ignore)>
Public Class NullableXmlRpcStruct : Inherits XmlRpcStruct
End Class

and I've removed the contents of XmlRpcNullMappingAttribute.vb

Keep in mind, I can get rid of the squiggly blue line by changing the XmlRpcNullMapping structure to
VB.NET:
<XmlRpcMissingMapping(MappingAction.Ignore)> _
Public Class NullableXmlRpcStruct : Inherits XmlRpcStruct
End Class

However, this returns the same <nil> result.

Thanks again for your help!
 
Back
Top