/// <summary>reads an incoming Giop reply message from the Message input stream msgInput</summary> /// <remarks>Precondition: sourceStream contains a Giop reply Msg</remarks> /// <returns>the .NET reply Msg created from the Giop Reply</returns> internal IMessage ParseIncomingReplyMessage(CdrMessageInputStream msgInput, IMethodCallMessage requestMessage, GiopClientConnectionDesc conDesc) { Debug.WriteLine("receive reply message at client side"); CdrInputStream msgBody = msgInput.GetMessageContentReadingStream(); GiopClientRequest request = new GiopClientRequest(requestMessage, conDesc, m_interceptionOptions); if (request.IsAsyncRequest) { try { // with respec to interception, this is a new request -> call again send_request interception before reply request.PrepareSecondAscyncInterception(); request.InterceptSendRequest(); } catch (Exception ex) { request.Reply = new ReturnMessage(ex, requestMessage); Exception newException = request.InterceptReceiveException(ex); if (newException == ex) { throw; } else { throw newException; // exeption has been changed by interception point } } } // deserialize message body IMessage result = m_ser.DeserialiseReply(msgBody, msgInput.Header.Version, request, conDesc); return(result); }
/// <summary> /// deserialise from input stream /// </summary> internal TaggedComponent(CdrInputStream inputStream) { this.tag = (int)inputStream.ReadULong(); int componentDataLength = (int)inputStream.ReadULong(); this.component_data = inputStream.ReadOpaque(componentDataLength); }
public void TestDecodeNoBomBeStream() { byte[] encoded = new byte[] { 0, 0, 0, 5, 0, 84, 0, 101, 0, 115, 0, 116, 0, 0 }; // Test CdrInputStream cdrStream = CreateInputStream(encoded, false); Assert.AreEqual("Test", cdrStream.ReadWString(), "wrongly decoded"); }
/// <summary> /// deserialise from input stream /// </summary> internal ServiceContext(CdrInputStream inputStream) { context_id = (int)inputStream.ReadULong(); int contextDataLength = (int)inputStream.ReadULong(); context_data = inputStream.ReadOpaque(contextDataLength); }
internal object DeserializeResponseArgs(string idlMethodName, out object[] outArgs, CdrInputStream sourceStream) { ArgumentsMapping mapping = GetArgumentsMapping(idlMethodName); return(mapping.DeserialiseResponseArgs(out outArgs, sourceStream)); }
/// <summary> /// parses an IOR embedded in a GIOP message /// </summary> internal Ior(CdrInputStream cdrStream) { List <IorProfile> profiles = new List <IorProfile>(); ParseIOR(cdrStream, out m_typId, profiles); m_profiles = profiles.ToArray(); }
public void TestDecodeBeBomLeStream() { byte[] encoded = new byte[] { 6, 0, 0, 0, 0xFE, 0xFF, 0, 84, 0, 101, 0, 115, 0, 116, 0, 0 }; // Test CdrInputStream cdrStream = CreateInputStream(encoded, true); Assert.AreEqual("Test", cdrStream.ReadWString(), "wrongly decoded"); }
protected override void ReadDataFromStream(CdrInputStream inputStream) { // internet-iiop profile is encapsulated CdrEncapsulationInputStream encapsulation = inputStream.ReadEncapsulation(); Debug.WriteLine("parse Internet IIOP Profile"); byte giopMajor = encapsulation.ReadOctet(); byte giopMinor = encapsulation.ReadOctet(); m_giopVersion = new GiopVersion(giopMajor, giopMinor); Debug.WriteLine("giop-verion: " + m_giopVersion); m_hostName = encapsulation.ReadString(); Debug.WriteLine("hostname: " + m_hostName); m_port = encapsulation.ReadUShort(); Debug.WriteLine("port: " + m_port); uint objectKeyLength = encapsulation.ReadULong(); m_objectKey = new byte[objectKeyLength]; Debug.WriteLine("object key follows"); for (uint i = 0; i < objectKeyLength; i++) { m_objectKey[i] = encapsulation.ReadOctet(); Debug.Write(m_objectKey[i] + " "); } Debug.WriteLine(""); // GIOP 1.1, 1.2: if (!(m_giopVersion.Major == 1 && m_giopVersion.Minor == 0)) { m_taggedComponents = new TaggedComponentList(encapsulation); } Debug.WriteLine("parsing Internet-IIOP-profile completed"); }
private object Unmarshal(Type type, AttributeExtCollection attributes, CdrInputStream cdrIn) { Serializer ser = m_serFactory.Create(type, attributes); return(ser.Deserialize(cdrIn)); }
internal object DeserialiseResponseArgs(out object[] outArgs, CdrInputStream sourceStream) { // demarshal first the return value; object retValue = null; if (m_returnValue.IsNonVoidReturn()) { retValue = m_returnValue.Deserialize(sourceStream); } // ... then the outargs outArgs = new object[m_arguments.Length]; bool outArgFound = false; for (int actualParamNr = 0; actualParamNr < m_arguments.Length; actualParamNr++) { ArgumentMapping paramInfo = m_arguments[actualParamNr]; if (paramInfo.IsOutArg() || paramInfo.IsRefArg()) { outArgs[actualParamNr] = paramInfo.Deserialize(sourceStream); outArgFound = true; } // else: for an in param null must be added to out-args } // prepare the result // need to return empty array, if no out-arg is present, because otherwise async calls fail if (!outArgFound) { outArgs = new object[0]; } return(retValue); }
private IDictionary DeserializeContextElements(CdrInputStream sourceStream, Serializer contextElementSer) { IDictionary result = new HybridDictionary(); // if no context elements specified, don't deserialise a context sequence. if (m_contextElementKeys.Length > 0) { string[] contextElems = (string[])contextElementSer.Deserialize(sourceStream); if (contextElems.Length % 2 != 0) { throw new omg.org.CORBA.MARSHAL(67, omg.org.CORBA.CompletionStatus.Completed_No); } for (int i = 0; i < contextElems.Length; i += 2) { string contextElemKey = contextElems[i]; // insert into call context, if part of signature for (int j = 0; j < m_contextElementKeys.Length; j++) { if (m_contextElementKeys[j] == contextElemKey) { result[contextElemKey] = contextElems[i + 1]; break; } } } } return(result); }
public void TestReadStringCodeSetOk() { byte[] testData = new byte[] { 0, 0, 0, 5, 65, 66, 67, 68, 0 }; CdrInputStream inputStream = PrepareStream(testData); string result = inputStream.ReadString(); Assert.AreEqual("ABCD", result, "read string"); }
internal object[] DeserializeRequestArgs(string idlMethodName, CdrInputStream sourceStream, out IDictionary contextElements) { ArgumentsMapping mapping = GetArgumentsMapping(idlMethodName); return(mapping.DeserialiseRequestArgs(sourceStream, out contextElements, m_contextElementSer)); }
public void TestReadWStringCodeSetNotSet() { byte[] testData = new byte[] { 0, 0, 0, 8, 0, 65, 0, 66, 0, 67, 0, 68 }; CdrInputStream inputStream = PrepareStream(testData); string result = inputStream.ReadWString(); Assert.Fail("no exception, although no wchar code set set"); }
/// <summary> /// asserts that the expected byte sequence is following in the stream /// </summary> private void AssertBytesFollowing(byte[] expected, CdrInputStream cdrIn) { for (int i = 0; i < expected.Length; i++) { byte data = (byte)cdrIn.ReadOctet(); Assert.AreEqual(expected[i], data); } }
/// <summary> /// reads a locate-request message. /// </summary> internal LocateRequestMessage ParseIncomingLocateRequestMessage(CdrMessageInputStream msgInput) { CdrInputStream msgBody = msgInput.GetMessageContentReadingStream(); // deserialize message body LocateRequestMessage result = m_ser.DeserialiseLocateRequest(msgBody, msgInput.Header.Version); Debug.WriteLine("locate request for target-uri: " + result.TargetUri); return(result); }
protected override void ReadDataFromStream(CdrInputStream inputStream) { Debug.WriteLine("parse unsupported ior profile"); uint length = inputStream.ReadULong(); m_data = inputStream.ReadOpaque((int)length); Debug.WriteLine("parsing unsupported profile completed"); }
/// <summary>reads an incoming Giop request-message from the message input stream msgInput</summary> /// <returns>the .NET request message created from this Giop-message</returns> internal IMessage ParseIncomingRequestMessage(CdrMessageInputStream msgInput, GiopConnectionDesc conDesc) { CdrInputStream msgBody = msgInput.GetMessageContentReadingStream(); // deserialize the message body (the GIOP-request id is included in this message) return(m_ser.DeserialiseRequest(msgBody, msgInput.Header.Version, conDesc, m_interceptionOptions)); }
private static void ParseIOR(CdrInputStream cdrStream, out string typId, List <IorProfile> profiles) { typId = cdrStream.ReadString(); ulong nrOfProfiles = cdrStream.ReadULong(); for (ulong i = 0; i < nrOfProfiles; i++) { profiles.Add(ParseProfile(cdrStream)); } }
protected override void ReadDataFromStream(CdrInputStream inputStream) { // internet-iiop profile is encapsulated CdrEncapsulationInputStream encapsulation = inputStream.ReadEncapsulation(); Debug.WriteLine("parse Multiple component Profile"); m_taggedComponents = new TaggedComponentList(encapsulation); Debug.WriteLine("parsing multiple components profile completed"); }
public void TestReadWStringCodeSetOk() { byte[] testData = new byte[] { 0, 0, 0, 8, 0, 65, 0, 66, 0, 67, 0, 68 }; CdrInputStream inputStream = PrepareStream(testData); inputStream.WCharSet = (int)Ch.Elca.Iiop.Services.WCharSet.UTF16; string result = inputStream.ReadWString(); Assert.AreEqual("ABCD", result, "read string"); }
private void ReadTaggedComponenttList(CdrInputStream inputStream) { int nrOfComponents = (int)inputStream.ReadULong(); m_components = new TaggedComponent[nrOfComponents]; for (int i = 0; i < nrOfComponents; i++) { TaggedComponent component = new TaggedComponent(inputStream); m_components[i] = component; } }
/// <summary> /// skips the service contexts in a request / reply msg /// </summary> private void SkipServiceContexts(CdrInputStream cdrIn) { uint nrOfContexts = cdrIn.ReadULong(); // Skip service contexts: not part of this test for (uint i = 0; i < nrOfContexts; i++) { cdrIn.ReadULong(); // context id uint lengthOfContext = cdrIn.ReadULong(); cdrIn.ReadPadding(lengthOfContext); } }
internal object[] DeserialiseRequestArgs(CdrInputStream sourceStream, out IDictionary contextElements, Serializer contextElementSer) { object[] result = new object[m_arguments.Length]; for (int actualParamNr = 0; actualParamNr < m_arguments.Length; actualParamNr++) { ArgumentMapping paramInfo = m_arguments[actualParamNr]; if (paramInfo.IsInArg() || paramInfo.IsRefArg()) { result[actualParamNr] = paramInfo.Deserialize(sourceStream); } // else: null for an out parameter } contextElements = DeserializeContextElements(sourceStream, contextElementSer); return(result); }
private void ReadSvcContextList(CdrInputStream inputStream) { uint nrOfServiceContexts = inputStream.ReadULong(); for (int i = 0; i < nrOfServiceContexts; i++) { ServiceContext context = new ServiceContext(inputStream); if (!m_contexts.Contains(context.context_id)) { m_contexts[context.context_id] = context; } else { // ignore multiple contexts with same id; iop interfaces allow access by id Debug.WriteLine("ignoring duplicate context with id: " + context.context_id); } } }
/// <summary> /// parses an IOR-profile embedded in a CDRStream /// </summary> /// <param name="cdrStream"></param> /// <returns></returns> private static IorProfile ParseProfile(CdrInputStream cdrStream) { int profileType = (int)cdrStream.ReadULong(); switch (profileType) { case 0: IorProfile result = new InternetIiopProfile(cdrStream); return(result); case 1: return(new MultipleComponentsProfile(cdrStream)); default: // unsupported profile type return(new UnsupportedIorProfile(cdrStream, profileType)); } }
private IDictionary DeserializeContextElements(CdrInputStream sourceStream, Serializer contextElementSer) { IDictionary result = new HybridDictionary(); // if no context elements specified, don't deserialise a context sequence. if (m_contextElementKeys.Length > 0) { string[] contextElems = (string[])contextElementSer.Deserialize(sourceStream); if (contextElems.Length % 2 != 0) { throw new omg.org.CORBA.MARSHAL(67, omg.org.CORBA.CompletionStatus.Completed_No); } for (int i = 0; i < contextElems.Length; i += 2) { string contextElemKey = contextElems[i]; // insert into call context, if part of signature for (int j = 0; j < m_contextElementKeys.Length; j++) { if (m_contextElementKeys[j] == contextElemKey) { result[contextElemKey] = contextElems[i + 1]; break; } } } } return result; }
internal object[] DeserialiseRequestArgs(CdrInputStream sourceStream, out IDictionary contextElements, Serializer contextElementSer) { object[] result = new object[m_arguments.Length]; for (int actualParamNr = 0; actualParamNr < m_arguments.Length; actualParamNr++) { ArgumentMapping paramInfo = m_arguments[actualParamNr]; if (paramInfo.IsInArg() || paramInfo.IsRefArg()) { result[actualParamNr] = paramInfo.Deserialize(sourceStream); } // else: null for an out parameter } contextElements = DeserializeContextElements(sourceStream, contextElementSer); return result; }
internal object Deserialize(CdrInputStream stream) { return m_ser.Deserialize(stream); }
internal override void ReadFromStream(CdrInputStream cdrStream, SerializerFactory serFactory) { CdrEncapsulationInputStream encap = cdrStream.ReadEncapsulation(); m_id = ReadRepositoryId(encap); m_name = encap.ReadString(); TypeCodeSerializer ser = new TypeCodeSerializer(serFactory); m_discriminatorType = (omg.org.CORBA.TypeCode)ser.Deserialize(encap); Type discrTypeCls = ((TypeCodeImpl)m_discriminatorType).GetClsForTypeCode(); m_defaultCase = encap.ReadLong(); uint length = encap.ReadULong(); m_members = new UnionSwitchCase[length]; Serializer serDisc = serFactory.Create(discrTypeCls, AttributeExtCollection.EmptyCollection); for (int i = 0; i < length; i++) { object discrLabel = serDisc.Deserialize(encap); string memberName = encap.ReadString(); omg.org.CORBA.TypeCode memberType = (omg.org.CORBA.TypeCode)ser.Deserialize(encap); UnionSwitchCase member = new UnionSwitchCase(discrLabel, memberName, memberType); m_members[i] = member; } }
internal override void ReadFromStream(CdrInputStream cdrStream, SerializerFactory serFactory) { CdrEncapsulationInputStream encap = cdrStream.ReadEncapsulation(); m_id = ReadRepositoryId(encap); m_name = encap.ReadString(); }
internal override void ReadFromStream(CdrInputStream cdrStream, SerializerFactory serFactory) { CdrEncapsulationInputStream encap = cdrStream.ReadEncapsulation(); TypeCodeSerializer ser = new TypeCodeSerializer(serFactory); m_innerDimension = (TypeCode)ser.Deserialize(encap); m_length = (int)encap.ReadULong(); }
/// <summary>reads the type-code content from the stream, without the TCKind at the beginning</summary> /// <remarks>helper which is used by the constructor with arg CdrInputStream</remarks> internal virtual void ReadFromStream(CdrInputStream cdrStream, SerializerFactory serFactory) { }
/// <summary> /// parses an IOR-profile embedded in a CDRStream /// </summary> /// <param name="cdrStream"></param> /// <returns></returns> private static IorProfile ParseProfile(CdrInputStream cdrStream) { int profileType = (int)cdrStream.ReadULong(); switch (profileType) { case 0: IorProfile result = new InternetIiopProfile(cdrStream); return result; case 1: return new MultipleComponentsProfile(cdrStream); default: // unsupported profile type return new UnsupportedIorProfile(cdrStream, profileType); } }
internal override void ReadFromStream(CdrInputStream cdrStream, SerializerFactory serFactory) { m_length = (int)cdrStream.ReadULong(); }
/// <summary> /// reads an unsupported profile from an encapsulation (created with the method readEncapsulation in /// CDRStream) /// </summary> /// <param name="encapsulation"></param> public UnsupportedIorProfile(CdrInputStream inputStream, int profileId) : base(inputStream) { m_profileId = profileId; }
private static void ParseIOR(CdrInputStream cdrStream, out string typId, List<IorProfile> profiles) { typId = cdrStream.ReadString(); ulong nrOfProfiles = cdrStream.ReadULong(); for (ulong i = 0; i < nrOfProfiles; i++) { profiles.Add(ParseProfile(cdrStream)); } }
/// <summary> /// skips the service contexts in a request / reply msg /// </summary> private void SkipServiceContexts(CdrInputStream cdrIn) { uint nrOfContexts = cdrIn.ReadULong(); // Skip service contexts: not part of this test for (uint i = 0; i < nrOfContexts; i++) { uint contextId = cdrIn.ReadULong(); uint lengthOfContext = cdrIn.ReadULong(); cdrIn.ReadPadding(lengthOfContext); } }
internal object Deserialize(CdrInputStream stream) { return(m_ser.Deserialize(stream)); }
private object Unmarshal(Type type, AttributeExtCollection attributes, CdrInputStream cdrIn) { Serializer ser = m_serFactory.Create(type, attributes); return ser.Deserialize(cdrIn); }
internal object DeserializeResponseArgs(string idlMethodName, out object[] outArgs, CdrInputStream sourceStream) { ArgumentsMapping mapping = GetArgumentsMapping(idlMethodName); return mapping.DeserialiseResponseArgs(out outArgs, sourceStream); }
/// <summary> /// creates an IOR from the data in a stream /// </summary> /// <param name="stream">the stream containing the profile data</param> protected IorProfile(CdrInputStream stream) { ReadDataFromStream(stream); }
public DataInputStreamImpl(CdrInputStream cdrIn, SerializerFactory serFactory) { m_cdrIn = cdrIn; m_serFactory = serFactory; }
/// <summary>reads this profile data from a stream</summary> protected abstract void ReadDataFromStream(CdrInputStream cdrStream);
internal override void ReadFromStream(CdrInputStream cdrStream, SerializerFactory serFactory) { CdrEncapsulationInputStream encap = cdrStream.ReadEncapsulation(); m_id = ReadRepositoryId(encap); m_name = encap.ReadString(); uint length = encap.ReadULong(); m_members = new string[length]; for (int i = 0; i < length; i++) { m_members[i] = encap.ReadString(); } }
/// <summary> /// reads an InternetIIOPProfile from a cdr stream /// </summary> /// <param name="encapsulation"></param> public InternetIiopProfile(CdrInputStream dataStream) : base(dataStream) { }
internal override void ReadFromStream(CdrInputStream cdrStream, SerializerFactory serFactory) { CdrEncapsulationInputStream encap = cdrStream.ReadEncapsulation(); m_id = ReadRepositoryId(encap); m_name = encap.ReadString(); uint length = encap.ReadULong(); m_members = new StructMember[length]; TypeCodeSerializer ser = new TypeCodeSerializer(serFactory); for (int i = 0; i < length; i++) { string memberName = encap.ReadString(); TypeCode memberType = (TypeCode)ser.Deserialize(encap); StructMember member = new StructMember(memberName, memberType); m_members[i] = member; } }
protected string ReadRepositoryId(CdrInputStream cdrStream) { return cdrStream.ReadString(); }
/// <summary> /// reads a multiple component profile data from a stream /// </summary> /// <param name="encapsulation"></param> public MultipleComponentsProfile(CdrInputStream inputStream) : base(inputStream) { }
internal override void ReadFromStream(CdrInputStream cdrStream, SerializerFactory serFactory) { CdrEncapsulationInputStream encap = cdrStream.ReadEncapsulation(); m_id = ReadRepositoryId(encap); m_name = encap.ReadString(); m_typeMod = encap.ReadShort(); TypeCodeSerializer ser = new TypeCodeSerializer(serFactory); m_baseClass = (TypeCode)ser.Deserialize(encap); // deser members uint length = encap.ReadULong(); m_members = new ValueMember[length]; for (int i = 0; i < length; i++) { string memberName = encap.ReadString(); TypeCode memberType = (TypeCode)ser.Deserialize(encap); short visibility = encap.ReadShort(); ValueMember member = new ValueMember(memberName, memberType, visibility); m_members[i] = member; } }
internal override void ReadFromStream(CdrInputStream cdrStream, SerializerFactory serFactory) { CdrEncapsulationInputStream encap = cdrStream.ReadEncapsulation(); m_id = ReadRepositoryId(encap); m_name = encap.ReadString(); TypeCodeSerializer ser = new TypeCodeSerializer(serFactory); m_aliased = (TypeCode)ser.Deserialize(encap); }
internal object DeserialiseResponseArgs(out object[] outArgs, CdrInputStream sourceStream) { // demarshal first the return value; object retValue = null; if (m_returnValue.IsNonVoidReturn()) { retValue = m_returnValue.Deserialize(sourceStream); } // ... then the outargs outArgs = new object[m_arguments.Length]; bool outArgFound = false; for (int actualParamNr = 0; actualParamNr < m_arguments.Length; actualParamNr++) { ArgumentMapping paramInfo = m_arguments[actualParamNr]; if (paramInfo.IsOutArg() || paramInfo.IsRefArg()) { outArgs[actualParamNr] = paramInfo.Deserialize(sourceStream); outArgFound = true; } // else: for an in param null must be added to out-args } // prepare the result // need to return empty array, if no out-arg is present, because otherwise async calls fail if (!outArgFound) { outArgs = new object[0]; } return retValue; }
internal object[] DeserializeRequestArgs(string idlMethodName, CdrInputStream sourceStream, out IDictionary contextElements) { ArgumentsMapping mapping = GetArgumentsMapping(idlMethodName); return mapping.DeserialiseRequestArgs(sourceStream, out contextElements, m_contextElementSer); }
/// <summary> /// parses an IOR embedded in a GIOP message /// </summary> internal Ior(CdrInputStream cdrStream) { List<IorProfile> profiles = new List<IorProfile>(); ParseIOR(cdrStream, out m_typId, profiles); m_profiles = profiles.ToArray(); }
/// <summary> /// deserialise a service context from /// </summary> /// <param name="inputStream"></param> internal TaggedComponentList(CdrInputStream inputStream) { ReadTaggedComponenttList(inputStream); }
/// <summary> /// deserialise a service context from /// </summary> /// <param name="inputStream"></param> internal ServiceContextList(CdrInputStream inputStream) { ReadSvcContextList(inputStream); }