Beispiel #1
0
 /// <summary>
 /// finds the code set service context among the collection of received service contexts.
 /// </summary>
 internal static CodeSetServiceContext FindCodeSetServiceContext(omg.org.IOP.ServiceContextList contexts)
 {
     if (contexts.ContainsServiceContext(SERVICE_ID))
     {
         omg.org.IOP.ServiceContext context = contexts.GetServiceContext(SERVICE_ID);
         return(new CodeSetServiceContext(context));
     }
     else
     {
         return(null);
     }
 }
Beispiel #2
0
 /// <summary>
 /// helper method, which sets the service context inside the message
 /// </summary>
 internal static void SetServiceContextInMessage(IMessage msg, ServiceContextList svcContext) {
     msg.Properties[SimpleGiopMsg.SERVICE_CONTEXT] = svcContext;                        
 }
Beispiel #3
0
 /// <summary>
 /// insert a codeset service context into the service context list.
 /// </summary>
 internal static void InsertCodeSetServiceContext(omg.org.IOP.ServiceContextList contexts,
                                                  int charSet, int wcharSet)
 {
     omg.org.IOP.ServiceContext context = CreateServiceContext(charSet, wcharSet);
     contexts.AddServiceContext(context);
 }
 public void TestSameServiceIdMultiple() {
     // checks if service contexts with the same id, doesn't throw an exception
     // checks, that the first service context is considered, others are thrown away
     GiopMessageBodySerialiser ser = new GiopMessageBodySerialiser(
                                         new ArgumentsSerializerFactory(m_serFactory));
     MemoryStream stream = new MemoryStream();
     CdrOutputStreamImpl cdrOut = new CdrOutputStreamImpl(stream, 0, new GiopVersion(1,2));
     cdrOut.WriteULong(2); // nr of contexts
     cdrOut.WriteULong(1234567); // id of context 1
     CdrEncapsulationOutputStream encap = new CdrEncapsulationOutputStream(0);
     cdrOut.WriteEncapsulation(encap);
     cdrOut.WriteULong(1234567); // id of context 2
     encap = new CdrEncapsulationOutputStream(0);
     cdrOut.WriteEncapsulation(encap);
     // reset stream
     stream.Seek(0, SeekOrigin.Begin);
     CdrInputStreamImpl cdrIn = new CdrInputStreamImpl(stream);
     cdrIn.ConfigStream(0, new GiopVersion(1,2));
     omg.org.IOP.ServiceContextList result = new ServiceContextList(cdrIn);
     // check if context is present
     Assert.IsTrue(result.ContainsServiceContext(1234567), "expected context not in collection");
 }
 /// <summary>
 /// helper method to update the GiopClientRequest with the new data from the reply
 /// </summary>
 private void UpdateClientRequestWithReplyData(GiopClientRequest request,
                                               IMessage response,
                                               ServiceContextList cntxColl) {
     request.Reply = response;
     request.ResponseServiceContext = cntxColl; // store the deserialised service context for handling in interceptors
 }
 protected void SerialiseContext(CdrOutputStream targetStream, ServiceContextList cntxList) {
     cntxList.WriteSvcContextList(targetStream);
 }
 /// <summary>
 /// perform code set establishment on the server side
 /// </summary>
 protected void PerformCodeSetEstablishmentServer(GiopVersion version,
                                                  GiopConnectionDesc conDesc, 
                                                  ServiceContextList cntxColl) {
     if (version.IsAfterGiop1_0()) {
         if (!conDesc.IsCodeSetNegotiated()) {
             // check for code set establishment
             CodeSetServiceContext context = 
                 CodeSetService.FindCodeSetServiceContext(cntxColl);
             if (context != null) {
                 CodeSetService.CheckCodeSetCompatible(context.CharSet,
                                                       context.WCharSet);
                 conDesc.SetNegotiatedCodeSets(context.CharSet,
                                               context.WCharSet);
             }
         }
     } else {
         conDesc.SetCodeSetNegotiated();
     }
 }
        /// <summary>
        /// perform code set establishment on the client side
        /// </summary>
        protected void PerformCodeSetEstablishmentClient(IIorProfile targetProfile,
                                                         GiopConnectionDesc conDesc,
                                                         ServiceContextList cntxColl) {
            
            if (targetProfile.Version.IsAfterGiop1_0()) {

                if (!conDesc.IsCodeSetNegotiated()) {
                    Codec codec =
                        m_codecFactory.create_codec(new Encoding(ENCODING_CDR_ENCAPS.ConstVal,
                                                                 targetProfile.Version.Major,
                                                                 targetProfile.Version.Minor));
                    object codeSetComponent = CodeSetService.FindCodeSetComponent(targetProfile, codec);
                    if (codeSetComponent != null) {
                        int charSet = CodeSetService.ChooseCharSet((CodeSetComponentData)codeSetComponent);
                        int wcharSet = CodeSetService.ChooseWCharSet((CodeSetComponentData)codeSetComponent);
                        conDesc.SetNegotiatedCodeSets(charSet, wcharSet);
                    } else {
                        conDesc.SetCodeSetNegotiated();
                    }
                    if (conDesc.IsCodeSetDefined()) {
                        // only insert a codeset service context, if a codeset is selected
                        CodeSetService.InsertCodeSetServiceContext(cntxColl,
                            conDesc.CharSet, conDesc.WCharSet);
                    }
                }
            } else {
                // giop 1.0; don't send code set service context; don't check again
                conDesc.SetCodeSetNegotiated();
            }
            
        }