Beispiel #1
0
        /// <summary><see cref="Ch.Elca.Iiop.IClientTransportFactory.CreateTransport(IIorProfile)"/></summary>
        public IClientTransport CreateTransport(IIorProfile profile)
        {
            if (profile.ProfileId != TAG_INTERNET_IOP.ConstVal)
            {
                throw new INTERNAL(734, CompletionStatus.Completed_No);
            }
            object sslComponentDataObject = GetSSLComponent(profile, m_codec);

            if (sslComponentDataObject == null)
            {
                throw new INTERNAL(734, CompletionStatus.Completed_No);
            }
            SSLComponentData     sslComponent  = (SSLComponentData)sslComponentDataObject;
            IInternetIiopProfile targetProfile = (IInternetIiopProfile)profile;
            int              port    = sslComponent.GetPort();
            SecurityOptions  options = CreateClientSecurityOptions(sslComponent);
            IPAddress        asIpAddress;
            IClientTransport result =
                IPAddress.TryParse(targetProfile.HostName, out asIpAddress)
                    ? new SslClientTransport(asIpAddress, port, options)
                    : new SslClientTransport(targetProfile.HostName, port, options);

            result.ReceiveTimeOut = m_receiveTimeOut;
            result.SendTimeOut    = m_sendTimeOut;
            return(result);
        }
        /// <summary>
        /// Allocate a connection for the message to the given target.
        /// </summary>
        private GiopClientConnection AllocateConnectionForTarget(IMessage msg, IIorProfile target,
                                                                 string targetKey,
                                                                 out uint requestNr)
        {
            GiopClientConnection          result        = null;
            GiopClientInitiatedConnection newConnection = null; // contains the new connection, if one is created

            lock (this) {
                while (result == null)
                {
                    result = GetFromAvailable(targetKey);
                    if (result != null)
                    {
                        break;
                    }
                    else
                    {
                        // if no usable connection, create new one (if possible)
                        if (CanInitiateNewConnection(targetKey))
                        {
                            IClientTransport transport =
                                m_transportFactory.CreateTransport(target);
                            newConnection = CreateClientConnection(targetKey, transport, m_requestTimeOut);
                            result        = newConnection;
                        }
                        else
                        {
                            // wait for connections to become available
                            Monitor.Wait(this); // wait for a new connection to become available.
                        }
                    }
                }
                result.IncrementNumberOfRequests();
                requestNr = result.Desc.ReqNumberGen.GenerateRequestId();
                m_allocatedConnections[msg] = result;
                if (newConnection != null)
                {
                    // Register the new connection, if everything went ok
                    RegisterConnection(targetKey, result);
                }
            }
            if (newConnection != null)
            {
                // open the connection now outside the locked session,
                // to allow other threads to access connection manager during
                // this lenghty operation.
                try {
                    newConnection.OpenConnection();
                } catch (Exception) {
                    lock (this) {
                        // clean up dead connection
                        UnregisterConnection(targetKey, newConnection);
                    }
                    throw;
                }
            }
            return(result);
        }
Beispiel #3
0
        public TaggedComponent[] get_effective_components(int id)
        {
            IIorProfile selectedProfile = m_clientRequest.SelectedProfile;

            if (selectedProfile.ContainsTaggedComponent(id))
            {
                return(selectedProfile.GetTaggedComponents(id));
            }
            throw new BAD_PARAM(25, CompletionStatus.Completed_MayBe);
        }
Beispiel #4
0
 private bool HasSSLComponent(IIorProfile profile)
 {
     if (profile.ProfileId == TAG_INTERNET_IOP.ConstVal)
     {
         if (profile.TaggedComponents.ContainsTaggedComponent(TAG_SSL_SEC_TRANS.ConstVal))
         {
             return(true);
         }
     }
     return(false);
 }
 /// <summary>
 /// <see cref="Ch.Elca.Iiop.IClientTransportFactory.CanUseProfile"/>
 /// </summary>
 public bool CanUseProfile(IIorProfile profile)
 {
     if (profile.ProfileId == TAG_INTERNET_IOP.ConstVal)
     {
         IInternetIiopProfile iiopProf = (IInternetIiopProfile)profile;
         if ((iiopProf.HostName != null) && (iiopProf.Port > 0))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #6
0
 private object GetSSLComponent(IIorProfile profile, Codec codec)
 {
     if (profile.ProfileId == TAG_INTERNET_IOP.ConstVal)
     {
         return(profile.TaggedComponents.GetComponentData(TAG_SSL_SEC_TRANS.ConstVal, codec,
                                                          SSLComponentData.TypeCode));
     }
     else
     {
         return(null);
     }
 }
Beispiel #7
0
 /// <summary>
 /// <see cref="Ch.Elca.Iiop.IClientTransportFactory.CanUseProfile"/>
 /// </summary>
 public bool CanUseProfile(IIorProfile profile)
 {
     if (profile.ProfileId == TAG_INTERNET_IOP.ConstVal)
     {
         IInternetIiopProfile iiopProf = (IInternetIiopProfile)profile;
         return((iiopProf.HostName != null) && HasSSLComponent(profile));
     }
     else
     {
         return(false);
     }
 }
 /// <summary><see cref="Ch.Elca.Iiop.IClientTransportFactory.GetEndpointKey(Ior)"/></summary>
 public string GetEndpointKey(IIorProfile target)
 {
     if (target.ProfileId == TAG_INTERNET_IOP.ConstVal)
     {
         IInternetIiopProfile prof = (IInternetIiopProfile)target;
         return("iiop" + prof.Version.Major + "." +
                prof.Version.Minor + "://" + prof.HostName + ":" + prof.Port);
     }
     else
     {
         return(String.Empty);
     }
 }
Beispiel #9
0
        /// <summary>
        /// returns the code set component data or null if not found
        /// </summary>
        internal static object /* CodeSetComponentData */ FindCodeSetComponent(IIorProfile profile, Codec codec)
        {
            TaggedComponentList list = profile.TaggedComponents;
            object result            =
                list.GetComponentData(TAG_CODE_SETS.ConstVal, codec,
                                      CodeSetComponentData.TypeCode);

            if (result != null)
            {
                return((CodeSetComponentData)result);
            }
            return(null);
        }
Beispiel #10
0
 /// <summary><see cref="Ch.Elca.Iiop.IClientTransportFactory.GetEndpointKey(IIorProfile)"/></summary>
 public string GetEndpointKey(IIorProfile target)
 {
     if (target.ProfileId == TAG_INTERNET_IOP.ConstVal)
     {
         object sslComponent       = GetSSLComponent(target, m_codec);
         IInternetIiopProfile prof = (IInternetIiopProfile)target;
         return("iiop-ssl" + prof.Version.Major + "." +
                prof.Version.Minor + "://" + prof.HostName + ":" + ((SSLComponentData)sslComponent).Port);
     }
     else
     {
         return(String.Empty);
     }
 }
Beispiel #11
0
 /// <summary>serialises the .NET msg to a GIOP-message</summary>
 private void SerialiseRequest(IMessage msg, IIorProfile target, GiopClientConnectionDesc conDesc,
                               uint reqId,
                               out ITransportHeaders headers, out Stream stream)
 {
     headers = new TransportHeaders();
     headers[GiopClientConnectionDesc.CLIENT_TR_HEADER_KEY] = conDesc;
     // get the stream into which the message should be serialied from the first stream handling
     // sink in the stream handling chain
     stream = m_nextSink.GetRequestStream(msg, headers);
     if (stream == null)              // the next sink delegated the decision to which stream the message should be serialised to this sink
     {
         stream = new MemoryStream(); // create a new stream
     }
     m_messageHandler.SerialiseOutgoingRequestMessage(msg, target, conDesc, stream, reqId);
 }
Beispiel #12
0
        public void TestSSLComponent()
        {
            IOrbServices orb       = OrbServices.GetSingleton();
            string       iorString = orb.object_to_string(m_newTestService);
            Ior          ior       = new Ior(iorString);

            Assert.IsTrue(ior.Profiles.Length > 0, "nr of profiles");
            IIorProfile profile = ior.Profiles[0];

            omg.org.IOP.CodecFactory codecFactory = (omg.org.IOP.CodecFactory)
                                                    orb.resolve_initial_references("CodecFactory");
            object sslData =
                profile.TaggedComponents.GetComponentData(20, codecFactory.create_codec(new omg.org.IOP.Encoding(omg.org.IOP.ENCODING_CDR_ENCAPS.ConstVal, 1, 2)),
                                                          SSLComponentData.TypeCode);

            Assert.NotNull(sslData);
            Assert.AreEqual((int)8087, ((SSLComponentData)sslData).GetPort());
        }
 /// <summary>allocation a connection and reqNr on connection for the message.</summary>
 internal GiopClientConnectionDesc AllocateConnectionFor(IMessage msg, IIorProfile target,
                                                         out uint requestNr)
 {
     if (target != null)
     {
         string targetKey = m_transportFactory.GetEndpointKey(target);
         if (targetKey == null)
         {
             throw new BAD_PARAM(1178, CompletionStatus.Completed_MayBe);
         }
         return(AllocateConnectionForTarget(msg, target, targetKey, out requestNr).Desc);
     }
     else
     {
         // should not occur
         throw new BAD_PARAM(995,
                             omg.org.CORBA.CompletionStatus.Completed_No);
     }
 }
Beispiel #14
0
        public void TestCodeSetComponent()
        {
            IOrbServices orb       = OrbServices.GetSingleton();
            string       iorString = orb.object_to_string(m_newTestService);
            Ior          ior       = new Ior(iorString);

            Assert.IsTrue(ior.Profiles.Length > 0, "nr of profiles");
            IIorProfile profile = ior.Profiles[0];

            omg.org.IOP.CodecFactory codecFactory = (omg.org.IOP.CodecFactory)
                                                    orb.resolve_initial_references("CodecFactory");
            object codeset =
                profile.TaggedComponents.GetComponentData(1, codecFactory.create_codec(new omg.org.IOP.Encoding(omg.org.IOP.ENCODING_CDR_ENCAPS.ConstVal, 1, 2)),
                                                          CodeSetComponentData.TypeCode);

            Assert.NotNull(codeset);
            Assert.AreEqual((int)CharSet.UTF8, ((CodeSetComponentData)codeset).NativeCharSet);
            Assert.AreEqual((int)WCharSet.UTF16, ((CodeSetComponentData)codeset).NativeWCharSet);
        }
 /// <summary><see cref="Ch.Elca.Iiop.IClientTransportFactory.CreateTransport(IIorProfile)"/></summary>
 public IClientTransport CreateTransport(IIorProfile targetProfile)
 {
     if (targetProfile.ProfileId == TAG_INTERNET_IOP.ConstVal)
     {
         IInternetIiopProfile iiopProf    = (IInternetIiopProfile)targetProfile;
         IPAddress            asIpAddress = ConvertToIpAddress(iiopProf.HostName);
         IClientTransport     result;
         if (asIpAddress == null)
         {
             ArrayList hostNames = new ArrayList();
             ArrayList ports     = new ArrayList();
             hostNames.Add(iiopProf.HostName);
             ports.Add(iiopProf.Port);
             foreach (TaggedComponent taggedComponent in
                      iiopProf.TaggedComponents.GetComponents(ALTERNATE_IIOP_ADDRESS.ConstVal))
             {
                 string hostName = System.Text.ASCIIEncoding.ASCII.GetString(
                     taggedComponent.component_data,
                     8,
                     BitConverter.ToInt32(taggedComponent.component_data, 4) - 1);
                 ushort port = BitConverter.ToUInt16(taggedComponent.component_data,
                                                     taggedComponent.component_data.Length - 2);
                 hostNames.Add(hostName);
                 ports.Add(port);
                 Debug.WriteLine(string.Format("CreateTransport(): host {0}:{1} from IOR added to list", hostName, port));
             }
             result = new TcpClientTransport((string[])hostNames.ToArray(ReflectionHelper.StringType),
                                             (int[])ports.ToArray(ReflectionHelper.Int32Type));
         }
         else
         {
             result = new TcpClientTransport(asIpAddress, iiopProf.Port);
         }
         result.ReceiveTimeOut = m_receiveTimeOut;
         result.SendTimeOut    = m_sendTimeOut;
         return(result);
     }
     else
     {
         throw new INTERNAL(3001, CompletionStatus.Completed_No);
     }
 }
Beispiel #16
0
        private void CheckIorForUrl(Ior iorForUrl, int expectedNumberOfComponents,
                                    bool shouldHaveCodeSetComponent)
        {
            Assert.AreEqual(1, iorForUrl.Profiles.Length, "number of profiles");
            Assert.AreEqual(typeof(MarshalByRefObject),
                            iorForUrl.Type, "type");
            IIorProfile profile = iorForUrl.FindInternetIiopProfile();

            Assert.NotNull(profile, "internet iiop profile");
            Assert.AreEqual(
                new byte[] { 116, 101, 115, 116 },
                profile.ObjectKey, "profile object key");
            Assert.AreEqual(new GiopVersion(1, 2), profile.Version, "profile giop version");

            if (shouldHaveCodeSetComponent)
            {
                Assert.AreEqual(
                    expectedNumberOfComponents,
                    profile.TaggedComponents.Count, "number of components");
                Assert.IsTrue(profile.ContainsTaggedComponent(
                                  CodeSetService.SERVICE_ID), "code set component present");
                CodeSetComponentData data = (CodeSetComponentData)
                                            profile.TaggedComponents.GetComponentData(CodeSetService.SERVICE_ID,
                                                                                      m_codec,
                                                                                      CodeSetComponentData.TypeCode);
                Assert.AreEqual(
                    (int)CharSet.LATIN1,
                    data.NativeCharSet, "code set component: native char set");
                Assert.AreEqual(
                    (int)WCharSet.UTF16,
                    data.NativeWCharSet, "code set component: native char set");
            }
            else
            {
                Assert.IsTrue(
                    !profile.ContainsTaggedComponent(
                        CodeSetService.SERVICE_ID), "code set component present");
            }
        }
Beispiel #17
0
 /// <summary>serialises an outgoing .NET request Message on client side</summary>
 internal void SerialiseOutgoingRequestMessage(IMessage msg, IIorProfile target, GiopClientConnectionDesc conDesc,
                                               Stream targetStream, uint requestId)
 {
     if (msg is IConstructionCallMessage)
     {
         // not supported in CORBA, TBD: replace through do nothing instead of exception
         throw new NotSupportedException("client activated objects are not supported with this channel");
     }
     else if (msg is IMethodCallMessage)
     {
         GiopVersion version = target.Version;
         // write a CORBA request message into the stream targetStream
         GiopHeader header = new GiopHeader(version.Major, version.Minor,
                                            m_headerFlags, GiopMsgTypes.Request);
         CdrMessageOutputStream msgOutput = new CdrMessageOutputStream(targetStream, header);
         // serialize the message, this insert some data into msg, e.g. request-id
         msg.Properties[SimpleGiopMsg.REQUEST_ID_KEY]     = requestId; // set request-id
         msg.Properties[SimpleGiopMsg.TARGET_PROFILE_KEY] = target;
         GiopClientRequest request = new GiopClientRequest((IMethodCallMessage)msg, conDesc, m_interceptionOptions);
         m_ser.SerialiseRequest(request,
                                msgOutput.GetMessageContentWritingStream(),
                                target, conDesc);
         msgOutput.CloseStream();
         if ((request.IsAsyncRequest) || (request.IsOneWayCall))
         {
             // after successful serialisation, call for oneway and async requests receive other,
             // see corba 2.6, page 21-12.
             request.InterceptReceiveOther();
         }
     }
     else
     {
         throw new NotImplementedException("handling for this type of .NET message is not implemented at the moment, type: " +
                                           msg.GetType());
     }
 }
Beispiel #18
0
 private object GetSSLComponent(IIorProfile profile, Codec codec) {
     if (profile.ProfileId == TAG_INTERNET_IOP.ConstVal) {
         return profile.TaggedComponents.GetComponentData(TAG_SSL_SEC_TRANS.ConstVal, codec,
                                                          SSLComponentData.TypeCode);
     } else {
         return null;
     }
 }
Beispiel #19
0
 /// <summary><see cref="Ch.Elca.Iiop.IClientTransportFactory.GetEndpointKey(IIorProfile)"/></summary>
 public string GetEndpointKey(IIorProfile target) {
     if (target.ProfileId ==  TAG_INTERNET_IOP.ConstVal) {
         object sslComponent = GetSSLComponent(target, m_codec);
         IInternetIiopProfile prof = (IInternetIiopProfile)target;
         return "iiop-ssl" + prof.Version.Major + "." +
                prof.Version.Minor + "://"+prof.HostName+":"+((SSLComponentData)sslComponent).Port;
     } else {
         return String.Empty;
     }
 }
Beispiel #20
0
 /// <summary>
 /// <see cref="Ch.Elca.Iiop.IClientTransportFactory.CanUseProfile"/>
 /// </summary>
 public bool CanUseProfile(IIorProfile profile) {
     if (profile.ProfileId == TAG_INTERNET_IOP.ConstVal) {
         IInternetIiopProfile iiopProf = (IInternetIiopProfile)profile;
         return ((iiopProf.HostName != null) && HasSSLComponent(profile));
     } else {
         return false;
     }
 }
Beispiel #21
0
 private bool HasSSLComponent(IIorProfile profile) {
     if (profile.ProfileId == TAG_INTERNET_IOP.ConstVal) {
         if (profile.TaggedComponents.ContainsTaggedComponent(TAG_SSL_SEC_TRANS.ConstVal)) {
             return true;
         }
     }
     return false;
 }
Beispiel #22
0
 /// <summary>allocates a connection and adds
 /// the connectionDesc to the message</summary>
 private GiopClientConnectionDesc AllocateConnection(IMessage msg, Ior target, out IIorProfile selectedProfile,
                                                     out uint reqId)
 {
     for (int i = 0; i < target.Profiles.Length; i++)
     {
         if (m_conManager.CanConnectWithProfile(target.Profiles[i]))
         {
             selectedProfile = target.Profiles[i];
             try {
                 return(m_conManager.AllocateConnectionFor(msg, selectedProfile, out reqId));
             } catch (Exception ex) {
                 Trace.WriteLine("exception while trying to connect to target: " + ex);
                 continue; // try next profile
             }
         }
     }
     throw new TRANSIENT(CorbaSystemExceptionCodes.TRANSIENT_CANTCONNECT,
                         CompletionStatus.Completed_No, "Unable to connect to target."); // can't connect to ior at the moment.
 }
Beispiel #23
0
 /// <summary><see cref="Ch.Elca.Iiop.IClientTransportFactory.CreateTransport(IIorProfile)"/></summary>
 public IClientTransport CreateTransport(IIorProfile profile) {
     if (profile.ProfileId != TAG_INTERNET_IOP.ConstVal) {
         throw new INTERNAL(734, CompletionStatus.Completed_No);
     }
     object sslComponentDataObject = GetSSLComponent(profile, m_codec);
     if (sslComponentDataObject == null) {
         throw new INTERNAL(734, CompletionStatus.Completed_No);
     }
     SSLComponentData sslComponent = (SSLComponentData)sslComponentDataObject;
     IInternetIiopProfile targetProfile = (IInternetIiopProfile)profile;
     int port = sslComponent.GetPort();
     SecurityOptions options = CreateClientSecurityOptions(sslComponent);
     IPAddress asIpAddress;
     IClientTransport result =
         IPAddress.TryParse(targetProfile.HostName, out asIpAddress)
             ? new SslClientTransport(asIpAddress, port, options)
             : new SslClientTransport(targetProfile.HostName, port, options);
     result.ReceiveTimeOut = m_receiveTimeOut;
     result.SendTimeOut = m_sendTimeOut;
     return result;
 }
 /// <summary>serialises the .NET msg to a GIOP-message</summary>
 private void SerialiseRequest(IMessage msg, IIorProfile target, GiopClientConnectionDesc conDesc,
                               uint reqId,
                               out ITransportHeaders headers, out Stream stream) {
     headers = new TransportHeaders();
     headers[GiopClientConnectionDesc.CLIENT_TR_HEADER_KEY] = conDesc;
     // get the stream into which the message should be serialied from the first stream handling
     // sink in the stream handling chain
     stream = m_nextSink.GetRequestStream(msg, headers);
     if (stream == null) { // the next sink delegated the decision to which stream the message should be serialised to this sink
         stream = new MemoryStream(); // create a new stream
     }
     m_messageHandler.SerialiseOutgoingRequestMessage(msg, target, conDesc, stream, reqId);
 }
 /// <summary>
 /// <see cref="Ch.Elca.Iiop.IClientTransportFactory.CanUseProfile"/>
 /// </summary>
 public bool CanUseProfile(IIorProfile profile) {
     if (profile.ProfileId == TAG_INTERNET_IOP.ConstVal) {
         IInternetIiopProfile iiopProf = (IInternetIiopProfile)profile;
         if ((iiopProf.HostName != null) && (iiopProf.Port > 0)) {
             return true;
         }
     }
     return false;
 }
 /// <summary>allocation a connection and reqNr on connection for the message.</summary>
 internal GiopClientConnectionDesc AllocateConnectionFor(IMessage msg, IIorProfile target,
                                                         out uint requestNr) {
     if (target != null) {
         string targetKey = m_transportFactory.GetEndpointKey(target);
         if (targetKey == null) {
             throw new BAD_PARAM(1178, CompletionStatus.Completed_MayBe);
         }
         return AllocateConnectionForTarget(msg, target, targetKey, out requestNr).Desc;
     } else {
         // should not occur
         throw new BAD_PARAM(995,
                             omg.org.CORBA.CompletionStatus.Completed_No);
     }
 }
 /// <summary>
 /// Allocate a connection for the message to the given target.
 /// </summary>
 private GiopClientConnection AllocateConnectionForTarget(IMessage msg, IIorProfile target,
                                                          string targetKey,
                                                          out uint requestNr) {
     GiopClientConnection result = null;
     GiopClientInitiatedConnection newConnection = null; // contains the new connection, if one is created
     lock(this) {
         while (result == null) {
             result = GetFromAvailable(targetKey);
             if (result != null) {
                 break;
             } else {
                 // if no usable connection, create new one (if possible)
                 if (CanInitiateNewConnection(targetKey)) {
                     IClientTransport transport =
                         m_transportFactory.CreateTransport(target);
                     newConnection = CreateClientConnection(targetKey, transport, m_requestTimeOut);
                     result = newConnection;
                 } else {
                     // wait for connections to become available
                     Monitor.Wait(this); // wait for a new connection to become available.
                 }
             }
         }
         result.IncrementNumberOfRequests();
         requestNr = result.Desc.ReqNumberGen.GenerateRequestId();
         m_allocatedConnections[msg] = result;
         if (newConnection != null) {
             // Register the new connection, if everything went ok
             RegisterConnection(targetKey, result);
         }
     }
     if (newConnection != null) {
         // open the connection now outside the locked session,
         // to allow other threads to access connection manager during
         // this lenghty operation.
         try {
             newConnection.OpenConnection();
         } catch(Exception) {
             lock(this) {
                 // clean up dead connection
                 UnregisterConnection(targetKey, newConnection);
             }
             throw;
         }
     }
     return result;
 }
 /// <summary>
 /// checks, if this connection manager is able to build up a connection with the given target profile.
 /// </summary>
 internal bool CanConnectWithProfile(IIorProfile targetProfile)
 {
     return(m_transportFactory.CanUseProfile(targetProfile));
 }
 /// <summary>allocates a connection and adds
 /// the connectionDesc to the message</summary>
 private GiopClientConnectionDesc AllocateConnection(IMessage msg, Ior target, out IIorProfile selectedProfile,
                                                     out uint reqId) {
     for (int i = 0; i < target.Profiles.Length; i++) {
         if (m_conManager.CanConnectWithProfile(target.Profiles[i])) {
             selectedProfile = target.Profiles[i];
             try {
                 return m_conManager.AllocateConnectionFor(msg, selectedProfile, out reqId);
             } catch (Exception ex) {
                 Trace.WriteLine("exception while trying to connect to target: " + ex);
                 continue; // try next profile
             }
         }
     }
     throw new TRANSIENT(CorbaSystemExceptionCodes.TRANSIENT_CANTCONNECT,
                         CompletionStatus.Completed_No, "Unable to connect to target."); // can't connect to ior at the moment.
 }
 /// <summary>
 /// serialises the message body for a GIOP request
 /// </summary>
 /// <param name="clientRequest">the giop request Msg</param>
 /// <param name="targetStream"></param>
 /// <param name="version">the Giop version to use</param>
 /// <param name="conDesc">the connection used for this request</param>
 internal void SerialiseRequest(GiopClientRequest clientRequest,
                                CdrOutputStream targetStream, 
                                IIorProfile targetProfile, GiopConnectionDesc conDesc) {
     Trace.WriteLine(String.Format("serializing request for method {0}; uri {1}; id {2}", 
                                   clientRequest.MethodToCall, clientRequest.CalledUri, 
                                   clientRequest.RequestId));
     try {
         clientRequest.SetRequestPICurrentFromThreadScopeCurrent(); // copy from thread scope picurrent before processing request
         
         ArgumentsSerializer ser =
             m_argSerFactory.Create(clientRequest.MethodToCall.DeclaringType);
         // determine the request method to send
         string idlRequestName = ser.GetRequestNameFor(clientRequest.MethodToCall);
         clientRequest.RequestMethodName = idlRequestName;
         
         clientRequest.InterceptSendRequest();
         GiopVersion version = targetProfile.Version;
         ServiceContextList cntxColl = clientRequest.RequestServiceContext;
         // set code-set for the stream
         PerformCodeSetEstablishmentClient(targetProfile, conDesc, cntxColl);
         SetCodeSet(targetStream, conDesc);
         
         if (version.IsBeforeGiop1_2()) { // for GIOP 1.0 / 1.1
             SerialiseContext(targetStream, cntxColl); // service context
         }
         
         targetStream.WriteULong(clientRequest.RequestId);
         byte responseFlags = 0;
         if (version.IsBeforeGiop1_2()) { // GIOP 1.0 / 1.1
             responseFlags = 1;
         } else {
             // reply-expected, no DII-call --> must be 0x03, no reply --> must be 0x00
             responseFlags = 3;
         }
         if (clientRequest.IsOneWayCall) {
             responseFlags = 0;
         } // check if one-way
         // write response-flags
         targetStream.WriteOctet(responseFlags);
         
         targetStream.WritePadding(3); // reserved bytes
         WriteTarget(targetStream, targetProfile.ObjectKey, version); // write the target-info
         targetStream.WriteString(clientRequest.RequestMethodName); // write the method name
         
         if (version.IsBeforeGiop1_2()) { // GIOP 1.0 / 1.1
             targetStream.WriteULong(0); // no principal
         } else { // GIOP 1.2
             SerialiseContext(targetStream, cntxColl); // service context
         }
         SerialiseRequestBody(targetStream, clientRequest, version, ser);
     } catch (Exception ex) {
         Debug.WriteLine("exception while serialising request: " + ex);
         Exception newException = clientRequest.InterceptReceiveException(ex); // interception point may change exception
         if (newException == ex) {
             throw;
         } else {
             throw newException; // exception has been changed by interception point
         }
     }
 }
 /// <summary><see cref="Ch.Elca.Iiop.IClientTransportFactory.GetEndpointKey(Ior)"/></summary>
 public string GetEndpointKey(IIorProfile target) {
     if (target.ProfileId ==  TAG_INTERNET_IOP.ConstVal) {
         IInternetIiopProfile prof = (IInternetIiopProfile)target;
         return "iiop" + prof.Version.Major + "." +
                prof.Version.Minor + "://"+prof.HostName+":"+prof.Port;
     } else {
         return String.Empty;
     }
 }
 /// <summary>
 /// checks, if this connection manager is able to build up a connection with the given target profile.
 /// </summary>
 internal bool CanConnectWithProfile(IIorProfile targetProfile) {
     return m_transportFactory.CanUseProfile(targetProfile);
 }
 /// <summary>serialises an outgoing .NET request Message on client side</summary>
 internal void SerialiseOutgoingRequestMessage(IMessage msg, IIorProfile target, GiopClientConnectionDesc conDesc,
                                             Stream targetStream, uint requestId) {
     if (msg is IConstructionCallMessage) {
         // not supported in CORBA, TBD: replace through do nothing instead of exception
         throw new NotSupportedException("client activated objects are not supported with this channel");
     } else if (msg is IMethodCallMessage) {
         GiopVersion version = target.Version;
         // write a CORBA request message into the stream targetStream
         GiopHeader header = new GiopHeader(version.Major, version.Minor,
                                            m_headerFlags, GiopMsgTypes.Request);
         CdrMessageOutputStream msgOutput = new CdrMessageOutputStream(targetStream, header);
         // serialize the message, this insert some data into msg, e.g. request-id
         msg.Properties[SimpleGiopMsg.REQUEST_ID_KEY] = requestId; // set request-id
         msg.Properties[SimpleGiopMsg.TARGET_PROFILE_KEY] = target;
         GiopClientRequest request = new GiopClientRequest((IMethodCallMessage)msg, conDesc, m_interceptionOptions);
         m_ser.SerialiseRequest(request,
                                msgOutput.GetMessageContentWritingStream(),
                                target, conDesc);
         msgOutput.CloseStream();
         if ((request.IsAsyncRequest) || (request.IsOneWayCall)) {
             // after successful serialisation, call for oneway and async requests receive other,
             // see corba 2.6, page 21-12.
             request.InterceptReceiveOther();
         }
     } else {
         throw new NotImplementedException("handling for this type of .NET message is not implemented at the moment, type: " +
                                           msg.GetType());
     }
 }
 /// <summary>
 /// returns the code set component data or null if not found
 /// </summary>
 internal static object /* CodeSetComponentData */ FindCodeSetComponent(IIorProfile profile, Codec codec) {
     TaggedComponentList list = profile.TaggedComponents;
     object result = 
         list.GetComponentData(TAG_CODE_SETS.ConstVal, codec,
                               CodeSetComponentData.TypeCode);
     if (result != null) {
         return (CodeSetComponentData)result;
     }            
     return null;
 }        
        /// <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();
            }
            
        }
 /// <summary><see cref="Ch.Elca.Iiop.IClientTransportFactory.CreateTransport(IIorProfile)"/></summary>
 public IClientTransport CreateTransport(IIorProfile targetProfile) {
     if (targetProfile.ProfileId == TAG_INTERNET_IOP.ConstVal) {
         IInternetIiopProfile iiopProf = (IInternetIiopProfile)targetProfile;
         IPAddress asIpAddress = ConvertToIpAddress(iiopProf.HostName);
         IClientTransport result;
         if (asIpAddress == null) {
             ArrayList hostNames = new ArrayList();
             ArrayList ports = new ArrayList();
             hostNames.Add(iiopProf.HostName);
             ports.Add(iiopProf.Port);
             foreach (TaggedComponent taggedComponent in 
                      iiopProf.TaggedComponents.GetComponents(ALTERNATE_IIOP_ADDRESS.ConstVal)) {
                 string hostName = System.Text.ASCIIEncoding.ASCII.GetString(
                     taggedComponent.component_data,
                     8,
                     BitConverter.ToInt32(taggedComponent.component_data, 4) - 1);
                 ushort port = BitConverter.ToUInt16(taggedComponent.component_data, 
                                                     taggedComponent.component_data.Length - 2);
                 hostNames.Add(hostName);
                 ports.Add(port);
                 Debug.WriteLine(string.Format("CreateTransport(): host {0}:{1} from IOR added to list", hostName, port));
             }                    
             result = new TcpClientTransport((string[])hostNames.ToArray(ReflectionHelper.StringType),
                                             (int[])ports.ToArray(ReflectionHelper.Int32Type));
         } else {
             result = new TcpClientTransport(asIpAddress, iiopProf.Port);
         }
         result.ReceiveTimeOut = m_receiveTimeOut;
         result.SendTimeOut = m_sendTimeOut;
         return result;
     } else {
         throw new INTERNAL(3001, CompletionStatus.Completed_No);
     }
 }