1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Structure in XML-RPC

Discussion in 'Visual Basic .NET' started by mixing, Dec 30, 2014.

  1. mixing

    mixing Regular Member

    Joined:
    Jan 18, 2014
    Messages:
    271
    Likes Received:
    33
    Gender:
    Male
    Location:
    USA
    Home Page:
    Hey everyone, I know working with XML-RPC in VB.net is a real pain and hopefully someone here can help me out. I'm trying to work with an API and unfortuanitely, it's only available in XML-RPC. Let me try to explain what I'm trying to do (I'm using the xml-rpc.net library).

    -I need to create a contact using this method. As you will see, it requires an API key string and a structure of these parameters. It will then return the response in a structure as well. Keep in mind, I am also going to be using a few extra parameters which is yet another structure (parameter), but not a required one.

    -As I mentioned above, the return will come back as a structure as well. This is what the return structure will look like.

    Now onto the code.. I'll try to explain what I'm doing through it below.
    Explanation of mapping Ignore/Error in Code
    Code:
    Imports CookComputing.XmlRpc
    
    '===== FIRST STRUCTURE parameters I am sending =====
    <XmlRpcMissingMapping(MappingAction.Ignore)> _
    Public Structure gandiContactDetails
        <XmlRpcMissingMapping(MappingAction.Error)> _
        Public city As String
        <XmlRpcMissingMapping(MappingAction.Error)> _
        Public country As String
        <XmlRpcMissingMapping(MappingAction.Error)> _
        Public email As String
        <XmlRpcMissingMapping(MappingAction.Error)> _
        Public family As String
        <XmlRpcMissingMapping(MappingAction.Error)> _
        Public given As String
        <XmlRpcMissingMapping(MappingAction.Error)> _
        Public password As String
        <XmlRpcMissingMapping(MappingAction.Error)> _
        Public phone As String
        <XmlRpcMissingMapping(MappingAction.Error)> _
        Public streetaddr As String
        <XmlRpcMissingMapping(MappingAction.Error)> _
        Public type As String
        Public accept_contract As Boolean
        Public brand_number As String
        Public community As Boolean
        Public community_hash As String
        Public community_referer As String
        Public data_obfuscated As Boolean
        Public extra_parameters As extra_parameters
        Public fax As String
        Public jo_announce_number As String
        Public jo_announce_page As String
        Public jo_declaration_date As String
        Public jo_publication_date As String
        Public lang As String
        Public mail_obfuscated As String
        Public mobile As String
        Public newsletter As Integer
        Public orgname As String
        Public security_question_answer As String
        Public security_question_num As String
        Public siren As String
        Public state As String
        Public third_part_resell As String
        Public vat_number As String
        Public zip As String
    End Structure
    
    '===== NEXT, STRUCTURE OF SPECIAL PARAMETERS =====
    <XmlRpcMissingMapping(MappingAction.Ignore)> _
    Public Structure extra_parameters
        Public birth_city As String
        Public birth_country As String
        Public birth_date As String
        Public birth_department As String
        Public brand_number As String
        Public duns As String
        Public waldec As String
        Public aero_ens_authid As String
        Public aero_ens_authkey As String
        Public au_registrant_id_number As String
        Public au_registrant_id_type As String
        Public ca_legaltype As String
        Public ca_owner_name As String
        Public coop_sponsor As String
        Public cy_reg_identity_no As String
        Public document_country As String
        Public document_type As String
        Public document_value As String
        Public es_admin_identification As String
        Public es_admin_tipo_identification As String
        Public es_bill_identification As String
        Public es_bill_tipo_identification As String
        Public es_identification As String
        Public es_legalform As String
        Public es_owner_identification As String
        Public es_owner_legalform As String
        Public es_owner_tipo_identification As String
        Public es_tech_identification As String
        Public es_tech_tipo_identification As String
        Public es_tipo_identification As String
        Public fi_based_on_person_name As String
        Public fi_business_number As String
        Public fi_ident_number As String
        Public fi_name_registration_id As String
        Public fi_name_registration_number As String
        Public hk_registrant_birth_date As String
        Public hk_registrant_document_number As String
        Public hk_registrant_document_origin_country As String
        Public hk_registrant_document_type As String
        Public hk_registrant_other_document_type As String
        Public hu_idnumber As String
        Public hu_owner_vatid As String
        Public ir_login_id As String
        Public ir_login_password As String
        Public it_pin As String
        Public kr_reg_identity_no As String
        Public lv_idnumber As String
        Public my_admin_contact_password As String
        Public my_admin_contact_username As String
        Public my_business_number As String
        Public my_organization_type As String
        Public no_registrant_identity As String
        Public nu_registrant_idnumber As String
        Public nu_registrant_vatid As String
        Public nyc_extcontact As String
        Public pro_authority As String
        Public pro_authoritywebsite As String
        Public pro_licensenumber As String
        Public pro_profession As String
        Public pt_arbitration As String
        Public pt_registrant_vatid As String
        Public pt_roid As String
        Public quebec_intendeduse As String
        Public ro_registrant_idnumber As String
        Public rs_reg_identity_no As String
        Public rs_reg_tax_no As String
        Public ru_registrant_passport_data As String
        Public se_ident_number As String
        Public sg_idnumber As String
        Public sk_registrant_idnumber As String
        Public travel_uin As String
        Public xxx_membership_contact As String
        Public xxx_sponsored_community As String
    End Structure
    
    '===== THIRD, SETUP THE STRUCTURE FOR THE RETURN PARAMETERS =====
    '===== some of these are also structures - I used XmlRpcStruct =====
    Public Structure gandiContactReply
        Public brand_number As String
        Public handle As String
        Public bu As XmlRpcStruct
        Public city As String
        Public community As Boolean
        Public country As XmlRpcStruct
        Public data_obfuscated As Integer
        Public email As String
        Public extra_parameters As XmlRpcStruct
        Public family As String
        Public fax As String
        Public given As String
        Public id As Integer
        Public is_corporate As Boolean
        Public jo_announce_number As String
        Public jo_announce_page As String
        Public jo_declaration_date As String
        Public jo_publication_date As String
        Public lang As String
        Public mail_obfuscated As Integer
        Public mobile As String
        Public newsletter As Integer
        Public orgname As String
        Public phone As String
        Public reachability As String
        Public security_question_answer As String
        Public security_question_num As Integer
        Public shippingaddress As XmlRpcStruct
        Public siren As String
        Public state As String
        Public streetaddr As String
        Public third_part_resell As Integer
        Public type As Integer
        Public validation As String
        Public vat_number As String
        Public zip As String
    End Structure
    
    '===== FOURTH, I INITIATE THE METHOD =====
    Public Interface createContact
        <CookComputing.XmlRpc.XmlRpcMethod("contact.create")> _
        Function GandiContact(ByVal apikey As String, ByVal params As gandiContactDetails) As gandiContactReply
    End Interface
    
    '===== NOW COMES THE MAIN FORM WITH A BUTTON =====
    Public Class Form1
        Public clientProtocol As XmlRpcClientProtocol
        Public createcontacts As createContact
    
        '===== SOMEONE CLICKS THE BUTTON TO CREATE CONTACT =====
        Private Sub btnCreateContact_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateContact.Click
    
        '===== I WILL HAVE SOME INPUTBOXES HERE TO GET NAME/EMAIL =====
        '===== and other required information for structure gandiContactDetails =====
    
            Dim Parameters As gandiContactDetails
            Parameters.city = gandicity
            Parameters.country = gandicountry.ToUpper
            Parameters.email = gandiemail
            Parameters.family = gandifamily
            Parameters.given = gandigiven
            Parameters.password = gandipassword
            Parameters.phone = gandiphone
            Parameters.streetaddr = gandistreetaddr
            Parameters.type = "0"
            Parameters.accept_contract = True
            Parameters.brand_number = Nothing
            Parameters.community = False
            Parameters.community_hash = Nothing
            Parameters.community_referer = Nothing
            Parameters.data_obfuscated = False
            Parameters.extra_parameters.birth_city = Nothing
            Parameters.extra_parameters.birth_country = Nothing
            Parameters.extra_parameters.birth_date = Nothing
            Parameters.extra_parameters.birth_department = Nothing
            Parameters.extra_parameters.brand_number = Nothing
            Parameters.extra_parameters.duns = Nothing
            Parameters.extra_parameters.waldec = Nothing
            Parameters.extra_parameters.aero_ens_authid = Nothing
            Parameters.extra_parameters.aero_ens_authkey = Nothing
            Parameters.extra_parameters.au_registrant_id_number = txtgandiAuIdNumber.Text
            Parameters.extra_parameters.au_registrant_id_type = txtgandiAuIdType.Text
            Parameters.extra_parameters.ca_legaltype = txtgandiCaType.Text
            Parameters.extra_parameters.ca_owner_name = txtgandiCaName.Text
            Parameters.extra_parameters.coop_sponsor = Nothing
            Parameters.extra_parameters.cy_reg_identity_no = Nothing
            Parameters.extra_parameters.document_country = Nothing
            Parameters.extra_parameters.document_type = Nothing
            Parameters.extra_parameters.document_value = Nothing
            Parameters.extra_parameters.es_admin_identification = Nothing
            Parameters.extra_parameters.es_admin_tipo_identification = Nothing
            Parameters.extra_parameters.es_bill_identification = Nothing
            Parameters.extra_parameters.es_bill_tipo_identification = Nothing
            Parameters.extra_parameters.es_identification = Nothing
            Parameters.extra_parameters.es_legalform = Nothing
            Parameters.extra_parameters.es_owner_identification = Nothing
            Parameters.extra_parameters.es_owner_legalform = Nothing
            Parameters.extra_parameters.es_owner_tipo_identification = Nothing
            Parameters.extra_parameters.es_tech_identification = Nothing
            Parameters.extra_parameters.es_tech_tipo_identification = Nothing
            Parameters.extra_parameters.es_tipo_identification = Nothing
            Parameters.extra_parameters.fi_based_on_person_name = Nothing
            Parameters.extra_parameters.fi_business_number = Nothing
            Parameters.extra_parameters.fi_ident_number = Nothing
            Parameters.extra_parameters.fi_name_registration_id = Nothing
            Parameters.extra_parameters.fi_name_registration_number = Nothing
            Parameters.extra_parameters.hk_registrant_birth_date = Nothing
            Parameters.extra_parameters.hk_registrant_document_number = Nothing
            Parameters.extra_parameters.hk_registrant_document_origin_country = Nothing
            Parameters.extra_parameters.hk_registrant_document_type = Nothing
            Parameters.extra_parameters.hk_registrant_other_document_type = Nothing
            Parameters.extra_parameters.hu_idnumber = Nothing
            Parameters.extra_parameters.hu_owner_vatid = Nothing
            Parameters.extra_parameters.ir_login_id = Nothing
            Parameters.extra_parameters.ir_login_password = Nothing
            Parameters.extra_parameters.it_pin = txtgandiItPin.Text
            Parameters.extra_parameters.kr_reg_identity_no = Nothing
            Parameters.extra_parameters.lv_idnumber = Nothing
            Parameters.extra_parameters.my_admin_contact_password = Nothing
            Parameters.extra_parameters.my_admin_contact_username = Nothing
            Parameters.extra_parameters.my_business_number = Nothing
            Parameters.extra_parameters.my_organization_type = Nothing
            Parameters.extra_parameters.no_registrant_identity = Nothing
            Parameters.extra_parameters.nu_registrant_idnumber = Nothing
            Parameters.extra_parameters.nu_registrant_vatid = Nothing
            Parameters.extra_parameters.nyc_extcontact = Nothing
            Parameters.extra_parameters.pro_authority = Nothing
            Parameters.extra_parameters.pro_authoritywebsite = Nothing
            Parameters.extra_parameters.pro_licensenumber = Nothing
            Parameters.extra_parameters.pro_profession = Nothing
            Parameters.extra_parameters.pt_arbitration = Nothing
            Parameters.extra_parameters.pt_registrant_vatid = Nothing
            Parameters.extra_parameters.pt_roid = Nothing
            Parameters.extra_parameters.quebec_intendeduse = Nothing
            Parameters.extra_parameters.ro_registrant_idnumber = Nothing
            Parameters.extra_parameters.rs_reg_identity_no = Nothing
            Parameters.extra_parameters.rs_reg_tax_no = Nothing
            Parameters.extra_parameters.ru_registrant_passport_data = txtgandiRuPassport.Text
            Parameters.extra_parameters.se_ident_number = txtgandiSeIdent.Text
            Parameters.extra_parameters.sg_idnumber = Nothing
            Parameters.extra_parameters.sk_registrant_idnumber = Nothing
            Parameters.extra_parameters.travel_uin = Nothing
            Parameters.extra_parameters.xxx_membership_contact = Nothing
            Parameters.extra_parameters.xxx_sponsored_community = Nothing
            Parameters.fax = Nothing
            Parameters.jo_announce_number = Nothing
            Parameters.jo_announce_page = Nothing
            Parameters.jo_declaration_date = Nothing
            Parameters.jo_publication_date = Nothing
            Parameters.lang = Nothing
            Parameters.mail_obfuscated = Nothing
            Parameters.mobile = Nothing
            Parameters.newsletter = 0
            Parameters.orgname = Nothing
            Parameters.security_question_answer = Nothing
            Parameters.security_question_num = Nothing
            Parameters.siren = Nothing
            Parameters.state = Nothing
            Parameters.third_part_resell = Nothing
            Parameters.vat_number = Nothing
            Parameters.zip = Nothing
    
            '===== NEXT, CREATE THE REQUEST =====
            createcontacts = CType(XmlRpcProxyGen.Create(GetType(createContact)), createContact)
            clientProtocol = CType(createcontacts, XmlRpcClientProtocol)
            clientProtocol.Url = "https://rpc.ote.gandi.net/xmlrpc/"
    
            '===== DIM THE REPLY AS STRUCTURE =====
            Dim response As XmlRpcStruct = Nothing
    
            '===== FINALLY, GET AND VIEW THE handle OF THE response =====
            response("handle") = createcontacts.GandiContact(txtGandiApiKey.Text, Parameters)
            msgbox(response)
        End Sub
    End Class
    
    When running the code above I get this error:
    Server returned a fault exception: [500037] Error on object: OBJECT_UNKNOWN (CAUSE_BADPARAMETER) [extra_parameters: Unknown ca_owner_name key]

    Not really sure why that would be happening as it's setup just as I see it in the documentation. I hope I explained this enough to where someone can maybe see what I'm doing wrong. Any help would be greatly appriciated!