/// <summary> /// write this IOR to a CDR-Stream in non-stringified form /// </summary> internal void WriteToStream(CdrOutputStream cdrStream) { cdrStream.WriteString(m_typId); cdrStream.WriteULong((uint)m_profiles.Length); // nr of profiles for (int i = 0; i < m_profiles.Length; i++) { m_profiles[i].WriteToStream(cdrStream); } }
public void TestWriteStringCodeSetOk() { byte[] expectedSerData = new byte[] { 0, 0, 0, 5, 65, 66, 67, 68, 0 }; string testData = "ABCD"; using (MemoryStream outBase = new MemoryStream()) { CdrOutputStream outputStream = PrepareStream(outBase); outputStream.WriteString(testData); AssertOutput(expectedSerData, outBase); } }
/// <summary> /// write a null IOR instance to a CDR-Stream in non-stringified form /// </summary> internal static void WriteNullToStream(CdrOutputStream cdrStream) { cdrStream.WriteString(string.Empty); cdrStream.WriteULong(0); }
/// <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 } } }