Donate Share

IIOP.NET

The forum address has changed, you have been automatically redirected. Please update any bookmarks to use the new URL.

Subscribe

Passing .NET string into IDL any

  1. 2004-04-02 22:30:10 UTC
    Great library! This looks to be exactly what we're looking for

    ... one small hitch, of course :)

    I'm implementing a 'spike' solution - a call from a .NET app to an existing Java server application.

    The problem is with the first parameter, TraitSelectorSeq. (It is essentially an array of TraitSelector objects. Each TraitSelector object contains a Trait object.)

    Trait is defined as:
    typedef any TraitValue;
    struct Trait {
    TraitName name;
    TraitValue value;
    };

    When I put a string in 'value', the call fails with:
    CORBA.BAD_PARAM

    Detailed error log reveals:
    org.omg.CORBA.BAD_PARAM: Illegal IDL name: omg.org.CORBA.WStringValue

    If I put the number 1 in 'value', the call succeeds.

    Possibly the interaction of IDL 'any' and .NET string?

    Can anyone help? Workaround, fix, anything?

    Thanks
    -- Joel

    Here's the IDL of the call:

    void find_candidates(
    in TraitSelectorSeq profile_selector,
    in IdStateSeq states_of_interest,
    in float confidence_threshold,
    in unsigned long sequence_max,
    in unsigned long iterator_max,
    in SpecifiedTraits traits_requested,
    out CandidateSeq returned_sequence,
    out CandidateIterator returned_iterator )

    And another part of IDL that's important:

    typedef any TraitValue;
    struct Trait {
    TraitName name;
    TraitValue value;
    };

  2. 2004-04-03 08:59:10 UTC
    Hi

    Thank you for your interest in IIOP.NET.

    Sadly I was not able to reproduce the error with a simple test (passing a string in an any to java and back).
    But according to error message posted, I've found one problem in IIOP.NET, which could possible have caused this error.
    I've just commited a change (IIOPChannel; Repository.cs v1.21), which tries to fix this.

    Please tell me, if this fixes the problem.

    If not:
    - would you please also post the minor code of the BAD_PARAM exception thrown.
    - would you please run the updated IntegrationTest in IntegrationTests\JavaRMIIIOP, to check if my simple test case also works in your environment.

    Thank you for your help in improving IIOP.NET.

    Best regards,
    Dominic
  3. 2004-04-03 14:05:06 UTC
    Thanks for quick reply.

    Didn't fix problem, but now it's a new error:
    org.omg.CORBA.BAD_TYPECODE: Cannot handle TypeCode with kind 30
    at org.jacorb.orb.Any.read_value(Any.java:816)
    at org.jacorb.orb.CDRInputStream.read_any(CDRInputStream.java:305)

    Minor: 0

    Previously, error was CORBA.BAD_PARAM, Minor: 15

    I was unable to compile Integration tests... kept bombing out saying AdderImpl couldn't be found. When I tried to compile JavaRMIIIOP, said TestService and TestServiceImpl does not exist.

    Here's the .NET code that demonstrates the problem:
    private TraitSelector createTrait(string name, string value) {
    Trait t = new Trait();
    t.name = name;
    t.value = value; // When value is a string, causes the problem
    TraitSelector ts = new TraitSelector();
    ts.__trait = t;
    ts.weight = 1F;

    return ts;
    }


    Thanks
    -- Joel
  4. 2004-04-03 14:10:22 UTC
    I think I found the answer:
    http://www.jacorb.org/problemscontents2.html

    Quote:
    wstring inside Anys: When wstrings are inserted into Anys, the marshalling stream throws a TypeCode.BadKind exception due to a missing entry in the internal TypeCode.length() method.

    Looks like I'll have to upgrade JacORB

    Thanks for your help!
    -- Joel
  5. 2004-04-03 22:29:51 UTC
    Attempt above didn't fix it. I'm willing to spend more time debugging if you have any more ideas.

    Currently using JacORB 1.4.1

    Thanks
    -- Joel
  6. 2004-04-05 19:53:22 UTC
    Tried a new ORB: ORBacus 4.0.3

    Doesn't throw an error, but the strings certainly aren't getting through. My CORBA-guru :) friend tells me it has to do with TCKind 30, and how JacORB and ORBacus expect strings to be TCKind 18.

    Please let me know if I can provide any other details or try anything else to fix this.

    Thanks
    -- Joel
  7. 2004-04-06 06:25:18 UTC
    Thank you for your help in investigating this problem.

    IIOP.NET maps .NET strings by default to the boxed value type WStringValue.
    When using any, a customization of this behaviour is currently not possible.

    To allow more control over the mapping in the any case, I should possibly add an explicit any type, which may be used instead of the object directly, if the default behaviour is not enough.
    What do you think?

    I'll try to provide a prototype solution during the next weekend.

    Best regards,
    Dominic
  8. 2004-04-08 22:01:10 UTC
    That sounds like a good solution. I would greatly appreciate it if you could make this change. Please let me know if there is any way I can help out.

    Thanks
    -- Joel
  9. 2004-04-13 07:33:41 UTC
    During the weekend, I had time to implement a way to customize the any serialisation.

    The following example shows, how to pass a string as any with string/wstring as typecode:

    // For this example, the remote object provides in
    // it's interface the following method:
    // void Test(object arg);

    OrbServices orb = OrbServices.GetSingleton();
    TypeCode wstringTC = orb.create_wstring_tc(0);
    Any any = new Any("myString", wstringTC);
    myObject.Test(any);

    // the following passes the string in a value box
    // with typecode WStringValue:
    myObject.Test("myString2");

    -> To customize the mapping behaviour, wrap the instance to pass in an Any instance instead of using it directly.
    If you don't need the customization, just use the instance itself.

    Please let me know, if this solves the problem.

    Thank you,
    Best regards,
    Dominic
  10. 2004-04-19 16:24:52 UTC
    That fixed it! Thank you so much for making that change. Only thing I did different from your example code was:

    TypeCode wstringTC = orb.create_string_tc(0);

    -- Joel
  11. 2004-04-20 07:47:17 UTC
    Hi

    I'm glad that this works for you. Thank you for trying this.

    Your feedback/help is very important and we would like to add
    you to the project contribution list (if you agree).
    See:
    http://iiop-net.sourceforge.net/faq.html#faq8_2
    Thank you for your help improving IIOP.NET.

    Best regards,
    Dominic
  12. 2007-02-13 23:41:20 UTC
    I recently came up against this same problem using TAO.

    Any structure containing a property of type object (defined as an any in the IDL file) appears to throw a CORBA.Marshal exception if the object is a string, but works fine otherwise. I have encountered this behaviour many times when attempting to pass such data into the remainder_of_body field of a StructuredEvent. Here is an example of dealing with this problem:

    private void myReporter_SendStatusOut(object sender, StatusOutEventArgs e)
    {
    StatusOutDataPackage dataPackage = new StatusOutDataPackage();
    dataPackage.Sender = e.Data.Sender;
    dataPackage.Flag = e.Data.Flag;
    dataPackage.Message = e.Data.Message;
    dataPackage.TimeStamp = e.Data.TimeStamp;
    // The following code is an attempt to address pathological behaviour (in TAO?)
    // where a field defined in a struct in the IDL as being of type any (in this case
    // any Data) throws a Marshalling Exception if the type in Data is a string.
    if (e.Data.Data != null && e.Data.Data.GetType() == typeof(string))
    {
    omg.org.CORBA.OrbServices orb = omg.org.CORBA.OrbServices.GetSingleton();
    omg.org.CORBA.TypeCode wstringTC = orb.create_wstring_tc(0);
    omg.org.CORBA.Any anyString = new omg.org.CORBA.Any((string)e.Data.Data, wstringTC);
    dataPackage.Data = anyString;
    }
    else
    {
    dataPackage.Data = e.Data.Data;
    }

    lock (this.statusOutSupplier)
    {
    this.statusOutStructuredEvent.remainder_of_body = dataPackage;
    this.statusOutSupplier.SendDataToConsumer(this.statusOutStructuredEvent);
    }
    }
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.