Hi,
i am new to j-interop and have a problem with structs.
i am trying to call a method in a DCOM object which has 5 parameters, all of them are of type Struct. I tried the following to call that method:
IJIDispatch dispatch = (IJIDispatch)JIObjectFactory.narrowObject((IJIComObject)excelObject.queryInterface(IJIDispatch.IID)); JIStruct param1 = new JIStruct(); JIStruct param2 = new JIStruct(); JIStruct param3 = new JIStruct(); JIStruct param4 = new JIStruct(); JIStruct param5 = new JIStruct(); param1.addMember(new JIString("test")); param2.addMember(new JIString("test")); param3.addMember(new JIString("test")); param4.addMember(new JIString("test")); param5.addMember(new JIString("test")); dispatch.callMethodA("StartService", new Object[] {param1, param2, param3, param4, param5});
As result i get the following Exception: org.jinterop.dcom.common.JIRuntimeException: Unsupported type for VARIANT. [0x00001030]
Is it not possible to call methods with parameters of type struct, or am i using the JIStruct class in a wrong way?
Any help would be appreciated.
Thanks, Stefan
Hi , Can I see the IDL signature for this method. (Complete one please).
Thanks, best regards, Vikram
Hi Vikram,
thanks for your fast answer.
The IDL for the COM object is the following:
// Generated .IDL file (by the OLE/COM Object Viewer) // // typelib filename: pdvService.dll
[ uuid(94505AA2-FFDD-4789-B6C9-6C625E8E0EB8), version(2.0), helpstring("pdv Service-DLL") ] library pdvService { // TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046} importlib("stdole2.tlb");
// Forward declare all types defined in this typelib interface _Main;
[ odl, uuid(426E12A8-3429-4098-89FD-4B0114187E65), version(1.0), hidden, dual, nonextensible, oleautomation ] interface _Main : IDispatch { [id(0x6003000b)] HRESULT StartService( [in, out] recFunktionType* recFunktion, [in, out] recKundeType* recKunde, [in, out] recVermittlerType* recVermittler, [in, out] recAngebotType* recAngebot, [in, out] recStatusType* recStatus, [out, retval] VARIANT* ); [id(0x60030011)] HRESULT ExecCmd( [in, out] BSTR* cmdline, [out, retval] long* ); };
[ uuid(3D770151-4F73-4AEB-8405-75995B5378B6), version(1.0) ] coclass Main { [default] interface _Main; };
typedef [uuid(5D6C2D78-1798-483E-B38F-59DB1F504256), version(1.0)] struct tagrecFunktionType { [helpstring("lngFkt") ] long lngFkt; } recFunktionType;
typedef [uuid(6555DDDE-1A06-4E07-83E6-01731F303793), version(1.0)] struct tagrecKundeType { [helpstring("strPersID") ] BSTR strPersID; [helpstring("strPers_Keng") ] BSTR strPers_Keng; [helpstring("lngAnr_Schl") ] long lngAnr_Schl; [helpstring("strName1") ] BSTR strName1; [helpstring("strName2") ] BSTR strName2; [helpstring("strName3") ] BSTR strName3; [helpstring("strTitel") ] BSTR strTitel; [helpstring("strLKZ") ] BSTR strLKZ; [helpstring("strPLZ") ] BSTR strPLZ; [helpstring("strOrt") ] BSTR strOrt; [helpstring("strStrasse") ] BSTR strStrasse; [helpstring("strPF") ] BSTR strPF; [helpstring("lngGebDat") ] long lngGebDat; [helpstring("strStaat") ] BSTR strStaat; [helpstring("strAZ") ] BSTR strAZ; [helpstring("strZiel_Gr_Schl") ] BSTR strZiel_Gr_Schl; [helpstring("strASicht_frei_VN") ] BSTR strASicht_frei_VN; [helpstring("strP_KNZ") ] BSTR strP_KNZ; [helpstring("strTelPrivat") ] BSTR strTelPrivat; [helpstring("strTelGesch") ] BSTR strTelGesch; [helpstring("strTelefax") ] BSTR strTelefax; [helpstring("strTelMobil") ] BSTR strTelMobil; } recKundeType;
typedef [uuid(5A662E95-5680-45E0-8DBA-36B9FAC45862), version(1.0)] struct tagrecVermittlerType { [helpstring("strVerm") ] BSTR strVerm; [helpstring("strPers_Keng") ] BSTR strPers_Keng; [helpstring("lngAnr_Schl") ] long lngAnr_Schl; [helpstring("strName1") ] BSTR strName1; [helpstring("strName2") ] BSTR strName2; [helpstring("strName3") ] BSTR strName3; [helpstring("strTitel") ] BSTR strTitel; [helpstring("strLKZ") ] BSTR strLKZ; [helpstring("strPLZ") ] BSTR strPLZ; [helpstring("strOrt") ] BSTR strOrt; [helpstring("strStrasse") ] BSTR strStrasse; [helpstring("strPF") ] BSTR strPF; [helpstring("lngGebDat") ] long lngGebDat; [helpstring("strStaat") ] BSTR strStaat; [helpstring("strAZ") ] BSTR strAZ; [helpstring("strZiel_Gr_Schl") ] BSTR strZiel_Gr_Schl; [helpstring("strASicht_frei_VN") ] BSTR strASicht_frei_VN; [helpstring("strP_KNZ") ] BSTR strP_KNZ; [helpstring("strTelefon") ] BSTR strTelefon; [helpstring("strTelefax") ] BSTR strTelefax; [helpstring("strMobiltelefon") ] BSTR strMobiltelefon; } recVermittlerType;
typedef [uuid(C9CB0B61-273D-4357-B153-9183BF8FCFFB), version(1.0)] struct tagrecAngebotType { [helpstring("lngAngNo") ] long lngAngNo; [helpstring("lngSparte") ] long lngSparte; [helpstring("strAngRah") ] BSTR strAngRah; [helpstring("strBeginn") ] BSTR strBeginn; [helpstring("dblBeitragGesamt") ] double dblBeitragGesamt; [helpstring("dblNettoZahlbeitrag") ] double dblNettoZahlbeitrag; [helpstring("strWaehrung") ] BSTR strWaehrung; [helpstring("lngZahlungsweise") ] long lngZahlungsweise; } recAngebotType;
typedef [uuid(74B59216-1DD8-4F29-ABCC-0AC8685A3C95), version(1.0)] struct tagrecStatusType { [helpstring("lngStatus") ] long lngStatus; [helpstring("lngFehlercode") ] long lngFehlercode; [helpstring("strFehlertext") ] BSTR strFehlertext; } recStatusType; };
Log in to post a comment.
Hi,
i am new to j-interop and have a problem with structs.
i am trying to call a method in a DCOM object which has 5 parameters, all of them are of type Struct.
I tried the following to call that method:
IJIDispatch dispatch = (IJIDispatch)JIObjectFactory.narrowObject((IJIComObject)excelObject.queryInterface(IJIDispatch.IID));
JIStruct param1 = new JIStruct();
JIStruct param2 = new JIStruct();
JIStruct param3 = new JIStruct();
JIStruct param4 = new JIStruct();
JIStruct param5 = new JIStruct();
param1.addMember(new JIString("test"));
param2.addMember(new JIString("test"));
param3.addMember(new JIString("test"));
param4.addMember(new JIString("test"));
param5.addMember(new JIString("test"));
dispatch.callMethodA("StartService", new Object[] {param1, param2, param3, param4, param5});
As result i get the following Exception:
org.jinterop.dcom.common.JIRuntimeException: Unsupported type for VARIANT. [0x00001030]
Is it not possible to call methods with parameters of type struct, or am i using the JIStruct class in a wrong way?
Any help would be appreciated.
Thanks,
Stefan
Hi ,
Can I see the IDL signature for this method. (Complete one please).
Thanks,
best regards,
Vikram
Hi Vikram,
thanks for your fast answer.
The IDL for the COM object is the following:
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: pdvService.dll
[
uuid(94505AA2-FFDD-4789-B6C9-6C625E8E0EB8),
version(2.0),
helpstring("pdv Service-DLL")
]
library pdvService
{
// TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");
// Forward declare all types defined in this typelib
interface _Main;
[
odl,
uuid(426E12A8-3429-4098-89FD-4B0114187E65),
version(1.0),
hidden,
dual,
nonextensible,
oleautomation
]
interface _Main : IDispatch {
[id(0x6003000b)]
HRESULT StartService(
[in, out] recFunktionType* recFunktion,
[in, out] recKundeType* recKunde,
[in, out] recVermittlerType* recVermittler,
[in, out] recAngebotType* recAngebot,
[in, out] recStatusType* recStatus,
[out, retval] VARIANT* );
[id(0x60030011)]
HRESULT ExecCmd(
[in, out] BSTR* cmdline,
[out, retval] long* );
};
[
uuid(3D770151-4F73-4AEB-8405-75995B5378B6),
version(1.0)
]
coclass Main {
[default] interface _Main;
};
typedef [uuid(5D6C2D78-1798-483E-B38F-59DB1F504256), version(1.0)]
struct tagrecFunktionType {
[helpstring("lngFkt")
]
long lngFkt;
} recFunktionType;
typedef [uuid(6555DDDE-1A06-4E07-83E6-01731F303793), version(1.0)]
struct tagrecKundeType {
[helpstring("strPersID")
]
BSTR strPersID;
[helpstring("strPers_Keng")
]
BSTR strPers_Keng;
[helpstring("lngAnr_Schl")
]
long lngAnr_Schl;
[helpstring("strName1")
]
BSTR strName1;
[helpstring("strName2")
]
BSTR strName2;
[helpstring("strName3")
]
BSTR strName3;
[helpstring("strTitel")
]
BSTR strTitel;
[helpstring("strLKZ")
]
BSTR strLKZ;
[helpstring("strPLZ")
]
BSTR strPLZ;
[helpstring("strOrt")
]
BSTR strOrt;
[helpstring("strStrasse")
]
BSTR strStrasse;
[helpstring("strPF")
]
BSTR strPF;
[helpstring("lngGebDat")
]
long lngGebDat;
[helpstring("strStaat")
]
BSTR strStaat;
[helpstring("strAZ")
]
BSTR strAZ;
[helpstring("strZiel_Gr_Schl")
]
BSTR strZiel_Gr_Schl;
[helpstring("strASicht_frei_VN")
]
BSTR strASicht_frei_VN;
[helpstring("strP_KNZ")
]
BSTR strP_KNZ;
[helpstring("strTelPrivat")
]
BSTR strTelPrivat;
[helpstring("strTelGesch")
]
BSTR strTelGesch;
[helpstring("strTelefax")
]
BSTR strTelefax;
[helpstring("strTelMobil")
]
BSTR strTelMobil;
} recKundeType;
typedef [uuid(5A662E95-5680-45E0-8DBA-36B9FAC45862), version(1.0)]
struct tagrecVermittlerType {
[helpstring("strVerm")
]
BSTR strVerm;
[helpstring("strPers_Keng")
]
BSTR strPers_Keng;
[helpstring("lngAnr_Schl")
]
long lngAnr_Schl;
[helpstring("strName1")
]
BSTR strName1;
[helpstring("strName2")
]
BSTR strName2;
[helpstring("strName3")
]
BSTR strName3;
[helpstring("strTitel")
]
BSTR strTitel;
[helpstring("strLKZ")
]
BSTR strLKZ;
[helpstring("strPLZ")
]
BSTR strPLZ;
[helpstring("strOrt")
]
BSTR strOrt;
[helpstring("strStrasse")
]
BSTR strStrasse;
[helpstring("strPF")
]
BSTR strPF;
[helpstring("lngGebDat")
]
long lngGebDat;
[helpstring("strStaat")
]
BSTR strStaat;
[helpstring("strAZ")
]
BSTR strAZ;
[helpstring("strZiel_Gr_Schl")
]
BSTR strZiel_Gr_Schl;
[helpstring("strASicht_frei_VN")
]
BSTR strASicht_frei_VN;
[helpstring("strP_KNZ")
]
BSTR strP_KNZ;
[helpstring("strTelefon")
]
BSTR strTelefon;
[helpstring("strTelefax")
]
BSTR strTelefax;
[helpstring("strMobiltelefon")
]
BSTR strMobiltelefon;
} recVermittlerType;
typedef [uuid(C9CB0B61-273D-4357-B153-9183BF8FCFFB), version(1.0)]
struct tagrecAngebotType {
[helpstring("lngAngNo")
]
long lngAngNo;
[helpstring("lngSparte")
]
long lngSparte;
[helpstring("strAngRah")
]
BSTR strAngRah;
[helpstring("strBeginn")
]
BSTR strBeginn;
[helpstring("dblBeitragGesamt")
]
double dblBeitragGesamt;
[helpstring("dblNettoZahlbeitrag")
]
double dblNettoZahlbeitrag;
[helpstring("strWaehrung")
]
BSTR strWaehrung;
[helpstring("lngZahlungsweise")
]
long lngZahlungsweise;
} recAngebotType;
typedef [uuid(74B59216-1DD8-4F29-ABCC-0AC8685A3C95), version(1.0)]
struct tagrecStatusType {
[helpstring("lngStatus")
]
long lngStatus;
[helpstring("lngFehlercode")
]
long lngFehlercode;
[helpstring("strFehlertext")
]
BSTR strFehlertext;
} recStatusType;
};