CORBA 클라이언트에서 WCHAR 문자열에 대한 코드 세트를 지정하는 방법

StackOverflow https://stackoverflow.com/questions/6044334

문제

이 질문은 내가 고투하고있는 또 다른 질문과 관련이 있습니다. CORBA 인터페이스에 액세스하는 방법 IDL 또는 늦은 바인딩 원격 방법

나는 규정되지 않은 코드 세트에 대해이 오류를 지나치게하는 방법에 대해 정말로 엉망이된다. IIOP 코드가 지정 될 수 있는지 알아 내려고 노력하고 프로파일과 연관된 태그 구성된 구성 요소로 지정할 수있는 것처럼 보입니다. CORBA에 익숙하지 않은 태그 구성 요소가 무엇인지 또는 프로파일이 무엇인지 또는 어떻게 제어하는지 모르지만 휴대용 객체 인터셉터를 만드는 것의 영향을받을 수 있다고 의심스럽게도 태그가 지정된 코드를 추가 할 수 있습니다. 프로필에 대한 구성 요소, 즉 아무것도 의미합니다. 나는 IIOP.NET 코드와 Google에서 배울 수있는 것만으로 가고 있습니다.

누군가가 이해하고 잘 이해하고 잘 통제하도록 도와 줄 수 있습니까? 서버가 블랙 상자이고 문자열을 출력하는 메소드를 호출하기 위해 클라이언트를 작성 해야하는 경우, IIOP.NET을 사용하는 WCHAR 코드 묘티가 불특정 오류를주지 않으므로 어떻게해야합니까? 나는 클라이언트에서 쓸모없는 장난을 시도했지만 그 효과가없는 것처럼 보입니다. 해당 함수의 IIOP 샘플 코드는 서버 측에서 사용되는 것을 보여줍니다.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top