ROInvalidVariantCodeException

We have created a service and it is apparently easy to use in .NET but I am having difficulty calling it within XCode. Here is the method I am trying call:

  • (ROVariant*)CreateJournal
    :(NSString*)_p_JournalSubject
    :(NSData*)_p_binRecipientList
    :(int32)_p_JournalSysCategoryid1
    :(int32)_p_JournalSysCategoryid2
    :(int32)_p_Userid
    :(int32)_p_Deptid
    :(int32)_p_Activityid
    :(NSString*)_p_DeptDescription
    :(int32)_p_SecLevel
    :(NSString*)_p_AttachedDocs
    :(NSString*)_p_Priority
    :(NSString*)_p_AssociatedActivity
    :(NSString*)_p_JournalPerson
    :(NSString*)_p_JournalDoc
    :(NSString*)_p_JournalTransmission
    :(NSString*)_p_JournalAssignment
    :(NSString*)_p_JournalTag
    :(NSString*)_p_JournalMemo
    :(NSString*)_p_CreateUserFullname
    :(int32)_p_Macroid
    :(NSString*)_p_sContext
    :(int32)_p_iDetail1
    :(int32)_p_iDetail2
    :(int32)_p_iDetail3
    :(int32)_p_iDetail4
    :(NSString*)_p_sConcerning
    :(NSString*)_p_sFaxCover
    :(BOOL)_p_bTransmit
    :(NSString*)_p_JounalHeaderAccess
    :(ROVariant*)_p_vParams
    :(NSData*)_p_binDocumentList

And the error I’m getting when trying to do is:

*** Terminating app due to uncaught exception ‘ROException’, reason: ‘Invalid or unsupported variant type code’

Any help trying to figure this out would be greatly appreciated.

Hello Bobby,

A Variant is a special general data type that can contain many different kinds of data.
Particular type of the stored object is specified in type property of the ROVariant instance
At the moment RO/Xcode supports following subtypes in the ROVariant:

varEmpty, varNull, varVariant, varArray
varBoolean, varByte, varDateTime,varGuid, varBinary
varInt8, varWord, varInt16, varLongWord, varInt32, varInt64
varDecimal, varDouble, varCurrency
varString, varDelphiString, varDelphiUtfString,

So can you look what exact subtype of the variant instances is used at your .NET part?
(I’m seing that your method returns ROVariant and vParams also has ROVariant types)

Thanks!

I have seen this error with a Delphi server and Android (Java) Client. For me, it happens when the Delphi server sends a value of varEmpty. RO Java has the following variant types declared in VariantType.pas

VariantTypeCode = public enum (
    varEmpty,
    varNull,
    varInt8,
    varInt32,
    varSingle,
    varDouble,
    varCurrency,
    varDateTime,
    varString,
    varDispatch,
    varError,
    varBoolean,
    varVariant,
    varUnknown,
    varDecimal,
    varInt16,
    varByte,
    varWord,
    varLongWord,
    varInt64,
    varGuid,
    varDelphiString,
    varDelphiUtfString,
    varArray, 
    varBinary
  );

Delphi can issue these types but the BinReaderWriter Method does not decode all of them.

method BinReaderWriter.readVariant(aValue: VariantType; aTypeCode: VariantTypeCode);
begin
  case aTypeCode of
    VariantTypeCode.varBoolean : aValue.AsBoolean := readBoolean;
    VariantTypeCode.varByte, VariantTypeCode.varInt8 : aValue.AsInt32 := readByte;
    VariantTypeCode.varDateTime : aValue.AsDate := readDateTime;
    VariantTypeCode.varDecimal : aValue.AsDecimal := readDecimalLittleEndian;
    VariantTypeCode.varDouble : aValue.AsDouble := readDoubleLittleEndian;
    VariantTypeCode.varCurrency : aValue.AsDecimal := readCurrencyLittleEndian;
    VariantTypeCode.varInt32, VariantTypeCode.varLongWord : aValue.AsInt32 := readInt32LittleEndian;
    VariantTypeCode.varInt64 : aValue.AsInt64 := readInt64LittleEndian;
    VariantTypeCode.varString, VariantTypeCode.varDelphiUtfString : aValue.AsUtfString := readUtf8String;
    VariantTypeCode.varDelphiString : aValue.AsString := readAnsiString;
    VariantTypeCode.varInt16, VariantTypeCode.varWord : aValue.AsInt32 := readSingleLittleEndian as Integer;
    VariantTypeCode.varNull : aValue.setNull;
    VariantTypeCode.varGuid : aValue.AsUuid := readGuid;
    else raise new Exception("BinReaderWriter : Unknown or unsupported variant type code");
  end;
end;

The most notable absence is varEmpty which in Delphi is the same as varUnassigned which is the default state for a variant. I think these values should be mapped properly even if the types have to be coalesced into something available on the target system.

Regards,
Will.

Thanks, logged as bugs://67540: varEmpty isn’t supported

Hello,
Was bugs bugs://67540 ever fixed?

Regards,
Will.

#67540 isn’t fixed yet.

That’s a shame. Delphi servers initialise Variant to varEmpty, which android clients then blow up on when they receive them.

My use of variants is to allow nullable types across the wire. I’m not keen on variant use as they are not typesafe. Does remobjects have any plans for nullable types across the wire? It is the only feature I really wish that you could add as its absence causes a lot of jumping through hoops to get the functionality.

Regards,
Will.

#67540 was logged as XCode issue. I’ll move it to Java category and re-review later

bugs://67540 got closed with status fixed.

as a workaround, add

    VariantTypeCode.varEmpty : aValue.setEmpty;

into that code