internal void SerializeRequestArgs(string idlMethodName, object[] arguments, CdrOutputStream targetStream, LogicalCallContext context) { ArgumentsMapping mapping = GetArgumentsMapping(idlMethodName); mapping.SerializeRequestArgs(arguments, targetStream, context, m_contextElementSer); }
private void SerializeContextElements(CdrOutputStream targetStream, LogicalCallContext callContext, Serializer contextElementSer) { // if no context elements specified, don't serialise a context sequence. if (m_contextElementKeys.Length > 0) { string[] contextSeq = new string[m_contextElementKeys.Length * 2]; for (int i = 0; i < m_contextElementKeys.Length; i++) { string contextKey = m_contextElementKeys[i]; contextSeq[i * 2] = contextKey; if (callContext.GetData(contextKey) != null) { contextSeq[i * 2 + 1] = callContext.GetData(contextKey).ToString(); } else { contextSeq[i * 2 + 1] = ""; } } contextElementSer.Serialize(contextSeq, targetStream); } }
internal void SerializeResponseArgs(string idlMethodName, object result, object[] outArgs, CdrOutputStream targetStream) { ArgumentsMapping mapping = GetArgumentsMapping(idlMethodName); mapping.SerializeResponseArgs(result, outArgs, targetStream); }
private void Marshal(Type type, AttributeExtCollection attributes, object val, CdrOutputStream cdrOut) { Serializer ser = m_serFactory.Create(type, attributes); ser.Serialize(val, cdrOut); }
internal void WriteTaggedComponentList(CdrOutputStream outputStream) { outputStream.WriteULong((uint)m_components.Length); for (int i = 0; i < m_components.Length; i++) { m_components[i].Write(outputStream); } }
/// <summary> /// writes this profile to the cdrStream /// </summary> /// <param name="cdrStream"></param> /// <remarks> public override void WriteToStream(CdrOutputStream cdrStream) { // write the profile id of this profile cdrStream.WriteULong((uint)ProfileId); uint length = (uint)m_data.Length; cdrStream.WriteULong(length); cdrStream.WriteOpaque(m_data); }
/// <summary> /// writes this profile to the cdrStream /// </summary> /// <param name="cdrStream"></param> /// <remarks> public override void WriteToStream(CdrOutputStream cdrStream) { // write the profile id of this profile cdrStream.WriteULong((uint)ProfileId); CdrEncapsulationOutputStream encapStream = GetProfileContentStream(); // write the whole encapsulation to the stream cdrStream.WriteEncapsulation(encapStream); }
/// <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); } }
internal void WriteSvcContextList(CdrOutputStream outputStream) { outputStream.WriteULong((uint)m_contexts.Count); foreach (DictionaryEntry entry in m_contexts) { ServiceContext context = (ServiceContext)entry.Value; context.Write(outputStream); } }
internal FragmentedMsgDesc(CdrInputStreamImpl firstFragment, int nrOfBytesFromCurrentPos, GiopHeader header, uint reqId) { m_target = new MemoryStream(); m_header = header; CdrOutputStream outputStream = header.WriteToStream(m_target, (uint)nrOfBytesFromCurrentPos); // place-holder header outputStream.WriteULong(reqId); // add req-id, because already read AddFragment(firstFragment, nrOfBytesFromCurrentPos); }
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); } }
public void TestWriteWStringCodeSetNotSet() { byte[] expectedSerData = new byte[] { 0, 0, 0, 8, 0, 65, 0, 66, 0, 67, 0, 68 }; string testData = "ABCD"; using (MemoryStream outBase = new MemoryStream()) { CdrOutputStream outputStream = PrepareStream(outBase); outputStream.WriteWString(testData); Assert.Fail("no exception, although no wchar code set set"); } }
public void TestWriteWStringCodeSetOk() { byte[] expectedSerData = new byte[] { 0, 0, 0, 8, 0, 65, 0, 66, 0, 67, 0, 68 }; string testData = "ABCD"; using (MemoryStream outBase = new MemoryStream()) { CdrOutputStream outputStream = PrepareStream(outBase); outputStream.WCharSet = (int)Ch.Elca.Iiop.Services.WCharSet.UTF16; outputStream.WriteWString(testData); AssertOutput(expectedSerData, outBase); } }
internal void SerializeRequestArgs(object[] arguments, CdrOutputStream targetStream, LogicalCallContext context, Serializer contextElementSer) { for (int actualParamNr = 0; actualParamNr < arguments.Length; actualParamNr++) { ArgumentMapping paramInfo = m_arguments[actualParamNr]; // iterate through the parameters, nonOut and nonRetval params are serialised for a request if (paramInfo.IsInArg() || paramInfo.IsRefArg()) { paramInfo.Serialize(targetStream, arguments[actualParamNr]); } // move to next parameter // out-args are also part of the arguments array -> move to next for those whithout doing something } SerializeContextElements(targetStream, context, contextElementSer); }
internal void SerializeResponseArgs(object result, object[] outArgs, CdrOutputStream targetStream) { // first serialise the return value, if (m_returnValue.IsNonVoidReturn()) { m_returnValue.Serialize(targetStream, result); } // ... then the out/ref args int outParamNr = 0; for (int actualParamNr = 0; actualParamNr < m_arguments.Length; actualParamNr++) { ArgumentMapping paramInfo = m_arguments[actualParamNr]; // iterate through the parameters, out/ref parameters are serialised if (paramInfo.IsOutArg() || paramInfo.IsRefArg()) { paramInfo.Serialize(targetStream, outArgs[outParamNr]); outParamNr++; } } }
/// <summary> /// writes this message header to a stream /// </summary> /// <param name="stream">the stream to write to</param> /// <param name="msgLength">the length of the msg content</param> internal void WriteToStream(CdrOutputStream stream, uint msgLength) { Debug.WriteLine("\nGIOP-message header starting: "); // write magic for (int i = 0; i < m_giop_magic.Length; i++) { Debug.Write(m_giop_magic[i] + " "); stream.WriteOctet(m_giop_magic[i]); } // write GIOP_Version Debug.Write(m_version.Major + " "); stream.WriteOctet(m_version.Major); Debug.Write(m_version.Minor + " "); stream.WriteOctet(m_version.Minor); // writing GIOP_flags Debug.Write(m_flags + " "); stream.WriteOctet(m_flags); Debug.Write((byte)m_type + " "); stream.WriteOctet((byte)m_type); // the message type Debug.Write("\nMessage-length: " + msgLength + "\n"); stream.WriteULong(msgLength); }
internal override void WriteToStream(CdrOutputStream cdrStream, SerializerFactory serFactory) { base.WriteToStream(cdrStream, serFactory); CdrEncapsulationOutputStream encap = new CdrEncapsulationOutputStream(cdrStream); encap.WriteString(m_id); encap.WriteString(m_name); encap.WriteToTargetStream(); }
internal override void WriteToStream(CdrOutputStream cdrStream, SerializerFactory serFactory) { // write common part: typecode nr base.WriteToStream(cdrStream, serFactory); // complex type-code: in encapsulation CdrEncapsulationOutputStream encap = new CdrEncapsulationOutputStream(cdrStream); encap.WriteString(m_id); encap.WriteString(m_name); TypeCodeSerializer ser = new TypeCodeSerializer(serFactory); Type discrTypeCls = ((TypeCodeImpl)m_discriminatorType).GetClsForTypeCode(); ser.Serialize(m_discriminatorType, encap); encap.WriteLong(m_defaultCase); encap.WriteULong((uint)m_members.Length); Serializer serDisc = serFactory.Create(discrTypeCls, AttributeExtCollection.EmptyCollection); for (int i = 0; i < m_members.Length; i++) { serDisc.Serialize(m_members[i].DiscriminatorValue, encap); encap.WriteString(m_members[i].ElementName); ser.Serialize(m_members[i].ElementType, encap); } encap.WriteToTargetStream(); }
/// <summary>serialize the whole type-code to the stream</summary> /// <param name="cdrStream"></param> internal virtual void WriteToStream(CdrOutputStream cdrStream, SerializerFactory serFactory) { uint val = Convert.ToUInt32(kind()); StreamPosition indirPos = cdrStream.WriteIndirectableInstanceTag(val); cdrStream.StoreIndirection(this, new IndirectionInfo(indirPos.GlobalPosition, IndirectionType.TypeCode, IndirectionUsage.TypeCode)); }
internal override void WriteToStream(CdrOutputStream cdrStream, SerializerFactory serFactory) { base.WriteToStream(cdrStream, serFactory); CdrEncapsulationOutputStream encap = new CdrEncapsulationOutputStream(cdrStream); encap.WriteString(m_id); encap.WriteString(m_name); encap.WriteULong((uint)m_members.Length); foreach (string member in m_members) { encap.WriteString(member); } encap.WriteToTargetStream(); }
/// <summary>writes this profile into an encapsulation</summary> public abstract void WriteToStream(CdrOutputStream cdrStream);
/// <summary> /// serialises a locate reply message. /// </summary> /// <param name="forwardAddr"> /// specifies the IOR of the object to forward the call to. This parameter must be != null, /// if LocateStatus is OBJECT_FORWARD. /// </param> public void SerialiseLocateReply(CdrOutputStream targetStream, GiopVersion version, uint forRequestId, LocateReplyMessage msg) { targetStream.WriteULong(forRequestId); switch (msg.Status) { case LocateStatus.OBJECT_HERE: targetStream.WriteULong((uint)msg.Status); break; default: Debug.WriteLine("Locate reply status not supported"); throw new NotSupportedException("not supported"); } }
/// <summary>serialize the GIOP message body of a repsonse message</summary> /// <param name="requestId">the requestId of the request, this response belongs to</param> internal void SerialiseReply(GiopServerRequest request, CdrOutputStream targetStream, GiopVersion version, GiopConnectionDesc conDesc) { Trace.WriteLine("serializing response for method: " + request.GetRequestedMethodNameInternal()); try { bool isExceptionReply = request.IsExceptionReply; Exception exceptionToSend = null; try { request.SetRequestPICurrentFromThreadScopeCurrent(); // copy from thread scope picurrent after processing request by servant // reply interception point if (!request.IsExceptionReply) { request.InterceptSendReply(); } else { exceptionToSend = request.InterceptSendException(request.IdlException); } } catch (Exception ex) { // update the reply with the exception from interception layer isExceptionReply = true; if (SerialiseAsSystemException(ex)) { exceptionToSend = ex; } else { exceptionToSend = new UNKNOWN(300, CompletionStatus.Completed_MayBe); } } ServiceContextList cntxColl = request.ResponseServiceContext; SetCodeSet(targetStream, conDesc); if (version.IsBeforeGiop1_2()) { // for GIOP 1.0 / 1.1 SerialiseContext(targetStream, cntxColl); // serialize the context } targetStream.WriteULong(request.RequestId); if (!isExceptionReply) { Trace.WriteLine("sending normal response to client"); targetStream.WriteULong(0); // reply status ok if (!version.IsBeforeGiop1_2()) { // for GIOP 1.2 and later, service context is here SerialiseContext(targetStream, cntxColl); // serialize the context } // serialize a response to a successful request SerialiseResponseOk(targetStream, request, version); Trace.WriteLine("reply body serialised"); } else { Trace.WriteLine("excpetion to send to client: " + exceptionToSend.GetType()); if (SerialiseAsSystemException(exceptionToSend)) { targetStream.WriteULong(2); // system exception } else if (SerialiseAsUserException(exceptionToSend)) { targetStream.WriteULong(1); // user exception } else { // should not occur targetStream.WriteULong(2); exceptionToSend = new INTERNAL(204, CompletionStatus.Completed_Yes); } if (!version.IsBeforeGiop1_2()) { // for GIOP 1.2 and later, service context is here SerialiseContext(targetStream, cntxColl); // serialize the context } AlignBodyIfNeeded(targetStream, version); if (SerialiseAsSystemException(exceptionToSend)) { SerialiseSystemException(targetStream, exceptionToSend); } else { SerialiseUserException(targetStream, (AbstractUserException)exceptionToSend); } Trace.WriteLine("exception reply serialised"); } } finally { request.ClearThreadScopePICurrent(); // no longer needed, clear afterwards to prevent access to stale data during next requests } }
private void SerialiseResponseOk(CdrOutputStream targetStream, GiopServerRequest request, GiopVersion version) { // reply body // clarification form CORBA 2.6, chapter 15.4.2: no padding, when no arguments are serialised --> // for backward compatibility, do it nevertheless AlignBodyIfNeeded(targetStream, version); // marshal the parameters ArgumentsSerializer ser = m_argSerFactory.Create(request.CalledMethod.DeclaringType); ser.SerializeResponseArgs(request.RequestMethodName, request.ReturnValue, request.OutArgs, targetStream); }
private void SerialiseSystemException(CdrOutputStream targetStream, Exception corbaEx) { // serialize a system exception if (!(corbaEx is AbstractCORBASystemException)) { corbaEx = new UNKNOWN(202, omg.org.CORBA.CompletionStatus.Completed_MayBe); } Serializer ser = m_serFactory.Create(corbaEx.GetType(), Util.AttributeExtCollection.EmptyCollection); ser.Serialize(corbaEx, targetStream); }
private void SerialiseUserException(CdrOutputStream targetStream, AbstractUserException userEx) { Type exceptionType = userEx.GetType(); // serialize a user exception Serializer ser = m_serFactory.Create(exceptionType, Util.AttributeExtCollection.EmptyCollection); ser.Serialize(userEx, targetStream); }
internal void Serialize(CdrOutputStream stream, object actual) { m_ser.Serialize(actual, stream); }
/// <summary>serializes the request body</summary> /// <param name="targetStream"></param> /// <param name="clientRequest">the request to serialise</param> /// <param name="version">the GIOP-version</param> private void SerialiseRequestBody(CdrOutputStream targetStream, GiopClientRequest clientRequest, GiopVersion version, ArgumentsSerializer ser) { // body of request msg: serialize arguments // clarification from CORBA 2.6, chapter 15.4.1: no padding, when no arguments are serialised --> // for backward compatibility, do it nevertheless AlignBodyIfNeeded(targetStream, version); ser.SerializeRequestArgs(clientRequest.RequestMethodName, clientRequest.RequestArguments, targetStream, clientRequest.RequestCallContext); }
/// <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 } } }
internal override void WriteToStream(CdrOutputStream cdrStream, SerializerFactory serFactory) { base.WriteToStream(cdrStream, serFactory); cdrStream.WriteULong((uint)m_length); }
internal override void WriteToStream(CdrOutputStream cdrStream, SerializerFactory serFactory) { base.WriteToStream(cdrStream, serFactory); CdrEncapsulationOutputStream encap = new CdrEncapsulationOutputStream(cdrStream); TypeCodeSerializer ser = new TypeCodeSerializer(serFactory); ser.Serialize(m_innerDimension, encap); encap.WriteULong((uint)m_length); encap.WriteToTargetStream(); }
public DataOutputStreamImpl(CdrOutputStream cdrOut, SerializerFactory serFactory) { m_cdrOut = cdrOut; m_serFactory = serFactory; }
internal override void WriteToStream(CdrOutputStream cdrStream, SerializerFactory serFactory) { base.WriteToStream(cdrStream, serFactory); CdrEncapsulationOutputStream encap = new CdrEncapsulationOutputStream(cdrStream); encap.WriteString(m_id); encap.WriteString(m_name); encap.WriteULong((uint)m_members.Length); TypeCodeSerializer ser = new TypeCodeSerializer(serFactory); foreach (StructMember member in m_members) { encap.WriteString(member.name); ser.Serialize(member.type, encap); } encap.WriteToTargetStream(); }
internal override void WriteToStream(CdrOutputStream cdrStream, SerializerFactory serFactory) { base.WriteToStream(cdrStream, serFactory); CdrEncapsulationOutputStream encap = new CdrEncapsulationOutputStream(cdrStream); encap.WriteString(m_id); encap.WriteString(m_name); encap.WriteShort(m_typeMod); TypeCodeSerializer ser = new TypeCodeSerializer(serFactory); // ser baseclass type ser.Serialize(m_baseClass, encap); // ser members encap.WriteULong((uint)m_members.Length); foreach (ValueMember member in m_members) { encap.WriteString(member.name); ser.Serialize(member.type, encap); encap.WriteShort(member.access); } encap.WriteToTargetStream(); }
/// <summary> /// serialise the service context /// </summary> internal void Write(CdrOutputStream outputStream) { outputStream.WriteULong((uint)tag); outputStream.WriteULong((uint)component_data.Length); outputStream.WriteOpaque(component_data); }
internal override void WriteToStream(CdrOutputStream cdrStream, SerializerFactory serFactory) { base.WriteToStream(cdrStream, serFactory); CdrEncapsulationOutputStream encap = new CdrEncapsulationOutputStream(cdrStream); encap.WriteString(m_id); encap.WriteString(m_name); TypeCodeSerializer ser = new TypeCodeSerializer(serFactory); ser.Serialize(m_aliased, encap); encap.WriteToTargetStream(); }
/// <summary> /// serialise the service context /// </summary> internal void Write(CdrOutputStream outputStream) { outputStream.WriteULong((uint)context_id); outputStream.WriteULong((uint)context_data.Length); outputStream.WriteOpaque(context_data); }