locked
Help with collections in Web Services (VB.NET 1.1) RRS feed

  • Question

  • User1048192908 posted

    I have 3 tables. course, catalog and course_catalog. The catalog can have multiple courses and each course catalog entry will be recorded in the course_catalog table. 

    I wrote 4 objects. Course obj (courseObj), catalog obj(catalogObj), and a course collection obj (courseObjColl), and a course catalog obj (courseCatalogObj).

    The courseCatalogObj has 2 properties --> catalogObj,  courseObjColl

    The webservice needs the courseCatalogObj to be passed to it. So the client will have to send a catalog and a collection of courses. The webservice will create the catalog and the courses and assign the courses to that catalog. 

    So I instantiate a catalog obj and populate it with data. The problem I am having is populating the courseObjColl. I can instantiate a courseObj but not the courseObjColl. So I am guessing I have to create an array of type courseObj. I tried that too but I am doing something wrong and it's failing. If I just send the catalog and just skip the courseObjColl then the catalog gets created without any errors. But as soon as I try to add the courses I am getting an internal error (Server was unable to read request. --> There is an error in XML document (1, 1015). --> Value cannot be null.
    Parameter name: value)

    This is my code

    Dim container As New catalog2.KCatalogStatusContainer
    Dim maintain As New Catalog2Client.catalog2.Catalog2
    Dim Kcatalog As New catalog2.courseCatalogObj
    Dim cat As New catalog2.catalogObj
    Dim course As New catalog2.courseObj
    Dim cc As catalog2.courseCatalogObj
    Dim ccColl(1) As catalog2.KCourseCatalogObj

    Kcatalog.command = catalog2.KIOCommand.insertORupdate
    cat.foreign_catalog_key = "TestCatalog"
    cat.catalog_description = "Test Catalog"
    cat.catalog_title = "Test Catalog"
    cat.expiration_date = "2013-03-31"

    cc = New catalog2.courseCatalogObj
    cc.company_type_id = 1
    cc.course_catalog_expiration_date = DateAdd(DateInterval.Day, 10, Now)
    course.foreign_catalog_key = "32918"
    cc.courseObj = course

    ccColl(0) = cc
    Kcatalog.catalog = cat
    Kcatalog.catalog.courses = ccColl

    cc = Nothing

    container = maintain.MaintainCatalog("username", "password", 111, Kcatalog)

    Please tell me what I am doing wrong. I am still using VB.NET 1.1

    Thanks.

    Wednesday, June 20, 2012 3:22 PM

All replies