Question

Cette question est liée à une autre question avec laquelle j'ai eu du mal: Comment accéder à l'interface Corba sans IDL ou lié à la fin des méthodes de remotage

Je suis vraiment excentré sur la façon de dépasser cette erreur sur le code de code non spécifié. J'ai suivi dans le code IIOP en essayant de déterminer comment le code de code peut être spécifié, et il semble que cela puisse être spécifié avec un composant étiqueté associé au profil. Être inconnu avec Corba, je ne sais pas ce qu'est un composant tagué ou quel profil est ou comment les contrôler, mais je soupçonne qu'il peut être influencé par la création d'un intercepteur d'objet portable, à quel point je pouvais ajouter un code de code marqué. composant au profil, si cela signifie n'importe quoi. Je vais juste en quoi je peux apprendre du code IIOP.NET et de Google.

Quelqu'un pourrait-il vous aider à comprendre et d'espérer contrôler cela? Si le serveur est une boîte noire et que j'ai besoin d'écrire un client pour appeler une méthode qui diffuse une chaîne, comment puis-je indiquer IIOP.net ce que WCHAR Codeset utiliser pour qu'il ne me donne pas une erreur à ce sujet sans préciser. J'ai essayé de dépasserFaultChargarsets de la cliente, mais cela ne semblait avoir aucun effet. Le code d'échantillon IIOP pour cette fonction montre qu'il est utilisé sur le côté serveur.

Était-ce utile?

La solution

This was a real pain to work out, but I got it:

class MyOrbInitializer : omg.org.PortableInterceptor.ORBInitializer
{
    public void post_init(omg.org.PortableInterceptor.ORBInitInfo info)
    {
        // Nothing to do
    }

    public void pre_init(omg.org.PortableInterceptor.ORBInitInfo info)
    {
        omg.org.IOP.Codec codec = info.codec_factory.create_codec(
            new omg.org.IOP.Encoding(omg.org.IOP.ENCODING_CDR_ENCAPS.ConstVal, 1, 2));
        Program.m_codec = codec;
    }
}


class Program
{
    public static omg.org.IOP.Codec m_codec;

    static void Main(string[] args)
    {
        IOrbServices orb = OrbServices.GetSingleton();
        orb.OverrideDefaultCharSets(CharSet.UTF8, WCharSet.UTF16);
        orb.RegisterPortableInterceptorInitalizer(new MyOrbInitializer());
        orb.CompleteInterceptorRegistration();
...
        MarshalByRefObject objRef = context.resolve(names);
        string origObjData = orb.object_to_string(objRef);
        Ch.Elca.Iiop.CorbaObjRef.Ior iorObj = new Ch.Elca.Iiop.CorbaObjRef.Ior(origObjData);
        CodeSetComponentData cscd = new CodeSetComponentData(
            (int)Ch.Elca.Iiop.Services.CharSet.UTF8,
            new int[] { (int)Ch.Elca.Iiop.Services.CharSet.UTF8 },
            (int)Ch.Elca.Iiop.Services.WCharSet.UTF16,
            new int[] { (int)Ch.Elca.Iiop.Services.WCharSet.UTF16 });
        omg.org.IOP.TaggedComponent codesetcomp = new omg.org.IOP.TaggedComponent(
            omg.org.IOP.TAG_CODE_SETS.ConstVal, m_codec.encode_value(cscd));
        iorObj.Profiles[0].TaggedComponents.AddComponent(codesetcomp);
        string newObjData = iorObj.ToString();
        MarshalByRefObject newObj = (MarshalByRefObject)orb.string_to_object(newObjData);
        ILicenseInfo li = (ILicenseInfo)newObj;
...
    }

Unfortunately in my case the problem remained that the byte ordering was backwards too, so I had to go with an entirely different solution based on just getting bytes back and manually converting them to a string instead of getting string directly.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top