AnsweredAssumed Answered

Requests from custom code to Blackboard webservice sometimes fails

Question asked by bert.middelhoven on Jan 13, 2017
Latest reply on Jan 13, 2017 by scott.hurrey

Hello,

 

A bit of asp.net code my colleague wrote allows users to enroll students into a course by sending a request to the Blackboard webservice. Unfortunately, we recently found out that while using this method will usually work perfectly, sometimes it fails, resulting in enrollments not being processed. As far as we can tell this is completely random, and after resubmitting these requests a number of times the request will go through and the student will be enrolled.

 

In the log files, we've found the following error being generated;

 

2016-12-06 18:19:23 +0100 - Info: [https:145.91.30.8:User.WS.getUser] Failed (blackboard.platform.ws.WebserviceException:[WSFW001]Invalid session - none specified)
2016-12-06 22:33:06 +0100 - Debug:[https:145.91.30.8:Course.WS.initializeCourseWS{31cefb4f24054b7aaa914a8d65037348:webserviceuser:Zuyd:BlackboardBridgeWebservice}] before method
2016-12-06 22:33:06 +0100 - Info: [https:145.91.30.8:Course.WS.initializeCourseWS{31cefb4f24054b7aaa914a8d65037348:webserviceuser:Zuyd:BlackboardBridgeWebservice}] Succeeded
2016-12-06 22:33:06 +0100 - Error:[Unknown] Failed to load session 31cefb4f24054b7aaa914a8d65037348 from [...]\BBLEARN\ws_sessions\31cefb4f24054b7aaa914a8d65037348 - retry count 0 - java.io.StreamCorruptedException: invalid type code: 02
at java.io.ObjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2515)
at java.io.ObjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2550)
...

 

After asking about why we are receiving this error on Behind the Blackboard, they suggested we pose our question here instead. We would like to know why the requests initially fail, why this error is occuring, and if there is any way to make sure requests no longer fail. Thank you for any help you can provide!

 

Some additional info; we are currently using Blackboard 2015 Q4, CU1, in a loadbalanced environment. Any other information you might need, please let me know!

 

Kind regards,

 

Nico Beckers
Zuyd University

 

 

 

 

PS, the following is part of the asp.net code;

 

        public Boolean BlackboarWebserviceLogin(String host, String vendor, String program, String secret, String username, string userpass, String logintype)
        {
            // If not logged in already...
            if (!loggedIn)
            {
                // Initialize and configure web service wrapper

                ws = new WebserviceWrapper(host, "...", program, EXPECTED_LIFE);

                // Context.WS initialize to establish session and get session Id
                ws.initialize_v1();

                if (logintype.Equals("tool"))
                {
                    // Login as proxy Tool
                    loggedIn = ws.loginTool(secret);
                }
                else
                {
                    // Login as user
                    loggedIn = ws.loginUser(username, userpass);
                }

                if (!loggedIn)
                {
                    //Console.WriteLine("Login " + logintype + " failed: " + ws.getLastError());
                    String result = ws.getLastError();
                    SoapException se = new SoapException("Can't login to Blackboard webservice: " + result,
                    SoapException.ClientFaultCode,
                    Context.Request.Url.AbsoluteUri);

                    throw se;        
                }
            }

            //Initialize the web service wrappers necessary for this sample
            initWrappers();

            return true;
        }

        [WebMethod]
        public EnrollStudentForCoursesResponse EnrollStudentForCourses(EnrollStudentForCoursesRequest esfcsrequest)
        {
            foreach (EnrollStudentForCoursesCourse course in esfcsrequest.Courses)
            {
                try
                {
                    EnrollAccountForCourse(course.CourseSiteBatchUid, esfcsrequest.PersonBatchUid, "S");
                }
                catch (SoapException se)
                {
                    throw se;
                }
            }

            return new EnrollStudentForCoursesResponse();
        }

        [WebMethod]
        public EnrollInstructorForCoursesResponse EnrollInstructorForCourses(EnrollInstructorForCoursesRequest eifcsrequest)
        {
             foreach (EnrollInstructorForCoursesCourse course in  eifcsrequest.ForCoursesCourses)
             {
                 try
                 {
                     EnrollAccountForCourse(course.CourseSiteBatchUid, eifcsrequest.PersonBatchUid, "P");
                 }
                 catch( SoapException se ) {
                     throw se;
                 }
             }
           
            return new EnrollInstructorForCoursesResponse();
        }

        public Boolean EnrollAccountForCourse(String course, String accountUid, String roleid)
        {
          
               if (BlackboarWebserviceLogin(HsZuyd.BlackboardWebServiceBridge.Properties.Settings.Default.BlackboardWebserviceHost, HsZuyd.BlackboardWebServiceBridge.Properties.Settings.Default.BlackboardWebserviceHost, HsZuyd.BlackboardWebServiceBridge.Properties.Settings.Default.BlackboardWebserviceProgram, " ", HsZuyd.BlackboardWebServiceBridge.Properties.Settings.Default.BlackboardWebserviceUserName, HsZuyd.BlackboardWebServiceBridge.Properties.Settings.Default.BlackboardWebserviceUserPass, HsZuyd.BlackboardWebServiceBridge.Properties.Settings.Default.BlackboardWebserviceLoginType))
                   {

                    //Get userid of user to enroll the user to the course   
                    UserFilter ufl = new UserFilter();
                    ufl.filterType = 6;
                    ufl.filterTypeSpecified = true;
                    ufl.name = new string[] {accountUid };
                    // Get the user object
                    UserVO[] user = usr.getUser(ufl);

                    if (user == null)
                    {
                        throw new SoapException("Can't retrieve user: " + user, SoapException.ServerFaultCode);
                    }

                    //Get the course object
                    CourseFilter cfl = new CourseFilter();
                    /* The following filtertypes are available:
                     *
                     0 - Load all (course|org)
                     1 - Load by courseids and (course|org) flag
                     2 - Load by batchUids and (course|org) flag
                     3 - Load by ids and (course|org) flag
                     4 - Load by categoryids and (course|org) flag
                     5 - Load by searchkey,searchoperator,searchvalue,searchdate,searchdateoperator and (course|org) flag
                     *
                     * source: http://library.blackboard.com/ref/fd8c40a0-f670-4c48-9e02-c5d84e61eda7/blackboard/ws/course/CourseFilter.html#getFilterType%28%29
                     *
                     * /
           
                  
                    cfl.filterType = 2;
                    cfl.filterTypeSpecified = true;
                    cfl.batchUids = new string[] { course };
                    CourseVO[] coursetst = crs.loadCourses(cfl);
                    if (coursetst[0] == null)
                    {                       
                        throw new SoapException("Can't retrieve Blackboard course: " + course, SoapException.ServerFaultCode);
                    }

 

                    String courseIdtst = coursetst[0].id;

                    //create membership object
                    CourseMembershipVO[] cmemberships = new CourseMembershipVO[1];
                    CourseMembershipVO membership = new CourseMembershipVO();

                    cmemberships[0] = membership;
                    cmemberships[0].available = true;
                    cmemberships[0].courseId = courseIdtst;
                    cmemberships[0].enrollmentDateSpecified = false;
                    cmemberships[0].userId = user[0].id;
                    cmemberships[0].availableSpecified = true;

                    cmemberships[0].roleId = roleid;
                    crm.saveCourseMembership(courseIdtst, cmemberships);
                   
                    MembershipFilter mf = new MembershipFilter();
                    mf.filterType = 6; // Load by course pk1 and user pk1
                    mf.filterTypeSpecified = true;
                    mf.userIds = new string[] { user[0].id };
                    mf.courseIds = new string[] { courseIdtst }; 
                             
                    CourseMembershipVO[] memberships = crm.loadCourseMembership(courseIdtst, mf);

                    if ((memberships.Length == 0) || (memberships[0] == null))
                        throw new SoapException("Can't retrieve membership,  course enrollment was not successfully created : " + course, SoapException.ServerFaultCode);
                   
                    String result = ws.getLastError();
                    if (result != null)
                    {
                        SoapException se = new SoapException("Can't save course membership: " + result,
                        SoapException.ClientFaultCode,
                        Context.Request.Url.AbsoluteUri);

                        throw se;
                    }

                   return true;
               }
               else return false;
        }

Outcomes