1. ActiveXComponent activeX = new ActiveXComponent("TDApiOle80.TDConnection");
2. Dispatch tdc = activeX.getObject()
3. Variant v= Dispatch.get(tdc, "BugFactory");
4. Dispatch bugFactory = v.getDispatch();
5. v = Dispatch.call(bugFactory, "AddItem", new Variant(null)); // This should return referecne to Bug Object in QC
My questions:
1) I get following exception at line #5 above. Can somebody guide me how to call "AddItem" method on BugFactory object?
com.jacob.com.ComFailException: Invoke of: AddItem
Source:
Description:
at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.invokev(Dispatch.java:625)
at com.jacob.com.Dispatch.callN(Dispatch.java:453)
at com.jacob.com.Dispatch.call(Dispatch.java:541)
at JacobTest.main(JacobTest.java:105)
2) After solving issue in my first question, how do I set a field value on Bug object using Jacob API? I appreciate if someone can provide an example.
Thanks in advance.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1) The NULL parameter for "AddItem" method should be set as follows:
Variant paramVal = new Variant();
paramVal.putNull();
Dispatch bug = Dispatch.call(bugFactory, "AddItem", paramVall).getDispatch(); // Returns referecne to Bug Object in QC
2) 'Field' on Bug object is set as follows:
Variant v = Dispatch.invoke(bug, "Field", Dispatch.Put,
new Object {new Variant("BG_DETECTION_DATE"), new Variant(new java.util.Date()) }, new int);
Retrieve value of above 'Field' as below:
Variant v = Dispatch.invoke(bug, "Field", Dispatch.Get,
new Object {new Variant("BG_DETECTION_DATE") }, new int);
I just copied code snippets from my program. It may fail to compile if you simply copy the code. Make changes as you needed.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Venkat, how did you connect to QC using Jacob. The above code appears fine to me. Just wanted to know how did you make connection to the QC using Jacob (using QC host, username, pwd, domain and project as parameters). Currently I am trying to make the connection using the below code, but I am unable to make connection.
com.jacob.com.Dispatch.call(tdc, "login", new Variant(host), new Variant(Domain), new Variant(Project), new Variant(login), new Variant(password));
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to create a defect in QC from Java using JACOB.
The sample code to create defect in VB is as follows:
Public Function AddBug() As Long
Dim BugF As BugFactory
Set BugF = tdc.BugFactory
Dim Bug1 As Bug
Set Bug1 = BugF.AddItem(Null)
Bug1.AutoPost = False
Bug1.AssignedTo = "steves"
Bug1.DetectedBy = "steves"
Bug1.Priority = "1-Low"
Bug1.Status = "New"
Bug1.Summary = "test bug summary"
Bug1.Field("BG_DESCRIPTION") = "description of the bug"
Bug1.Field("BG_DETECTION_DATE") = "2006-02-02 12:00:01"
Bug1.Field("BG_SEVERITY") = "2-Medium"
Bug1.Field("BG_REPRODUCIBLE") = "Y"
Bug1.Field("BG_PRIORITY") = "2-Medium"
Bug1.Field("BG_RESPONSIBLE") = "annab"
Bug1.Field("BG_STATUS") = "New"
Bug1.Field("BG_USER_01") = "123"
Bug1.Field("BG_USER_03") = "item_1"
Bug1.Field("BG_USER_04") = "sa"
Bug1.Field("BG_USER_05") = "15-Feb-2006"
Bug1.Post
AddBug = Bug1.ID
End Function
In Java:
1. ActiveXComponent activeX = new ActiveXComponent("TDApiOle80.TDConnection");
2. Dispatch tdc = activeX.getObject()
3. Variant v= Dispatch.get(tdc, "BugFactory");
4. Dispatch bugFactory = v.getDispatch();
5. v = Dispatch.call(bugFactory, "AddItem", new Variant(null)); // This should return referecne to Bug Object in QC
My questions:
1) I get following exception at line #5 above. Can somebody guide me how to call "AddItem" method on BugFactory object?
com.jacob.com.ComFailException: Invoke of: AddItem
Source:
Description:
at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.invokev(Dispatch.java:625)
at com.jacob.com.Dispatch.callN(Dispatch.java:453)
at com.jacob.com.Dispatch.call(Dispatch.java:541)
at JacobTest.main(JacobTest.java:105)
2) After solving issue in my first question, how do I set a field value on Bug object using Jacob API? I appreciate if someone can provide an example.
Thanks in advance.
I found the solution to my issues #1 and #2
1) The NULL parameter for "AddItem" method should be set as follows:
Variant paramVal = new Variant();
paramVal.putNull();
Dispatch bug = Dispatch.call(bugFactory, "AddItem", paramVall).getDispatch(); // Returns referecne to Bug Object in QC
2) 'Field' on Bug object is set as follows:
Variant v = Dispatch.invoke(bug, "Field", Dispatch.Put,
new Object {new Variant("BG_DETECTION_DATE"), new Variant(new java.util.Date()) }, new int);
Retrieve value of above 'Field' as below:
Variant v = Dispatch.invoke(bug, "Field", Dispatch.Get,
new Object {new Variant("BG_DETECTION_DATE") }, new int);
I just copied code snippets from my program. It may fail to compile if you simply copy the code. Make changes as you needed.
Venkat, how did you connect to QC using Jacob. The above code appears fine to me. Just wanted to know how did you make connection to the QC using Jacob (using QC host, username, pwd, domain and project as parameters). Currently I am trying to make the connection using the below code, but I am unable to make connection.
com.jacob.com.Dispatch.call(tdc, "login", new Variant(host), new Variant(Domain), new Variant(Project), new Variant(login), new Variant(password));
You will need to make three calls to properly login to QC using COM calls: