コード例 #1
0
        public void TestLocateReplySerialisation()
        {
            uint requestId = 5;

            byte[]               objectKey = new byte[] { 116, 101, 115, 116, 111, 98, 106, 101, 99, 116 }; // testobject
            string               targetUri = "testobject";
            GiopVersion          version   = new GiopVersion(1, 2);
            LocateRequestMessage locReq    = new LocateRequestMessage(requestId, objectKey, targetUri);
            // create a connection context
            GiopConnectionDesc conDesc = new GiopConnectionDesc(null, null);

            // create the reply
            LocateStatus       replyStatus = LocateStatus.OBJECT_HERE;
            LocateReplyMessage locReply    = new LocateReplyMessage(replyStatus);

            MemoryStream targetStream = new MemoryStream();

            m_handler.SerialiseOutgoingLocateReplyMessage(locReply, locReq, version, targetStream, conDesc);

            // check to serialised stream
            targetStream.Seek(0, SeekOrigin.Begin);

            CdrInputStreamImpl cdrIn = new CdrInputStreamImpl(targetStream);

            cdrIn.ConfigStream(0, version);

            // first is Giop-magic
            byte data;

            AssertBytesFollowing(m_giopMagic, cdrIn);
            // Giop version
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual(1, data);
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual(2, data);
            // flags: big-endian, no fragements
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual(0, data);
            // Giop Msg type: locate reply
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual((byte)GiopMsgTypes.LocateReply, data);
            // Giop Msg length
            uint msgLength = cdrIn.ReadULong();

            cdrIn.SetMaxLength(msgLength);
            // req-id
            Assert.AreEqual(requestId, cdrIn.ReadULong());
            // the location status
            Assert.AreEqual((uint)replyStatus, cdrIn.ReadULong());
        }
コード例 #2
0
ファイル: IOR.cs プロジェクト: JnS-Software-LLC/iiop-net
 /// <summary>
 /// creates an IOR from the IOR stringified form
 /// </summary>
 public Ior(string iorAsString)
 {
     // iorAsString contains only characters 0-9, A-F and IOR --> all of this are short characters
     if (iorAsString.StartsWith("IOR:"))
     {
         MemoryStream memStream = new MemoryStream(StringConversions.Destringify(iorAsString, 4));
         CdrInputStreamImpl cdrStream = new CdrInputStreamImpl(memStream);
         byte flags = cdrStream.ReadOctet();
         cdrStream.ConfigStream(flags, new GiopVersion(1, 2)); // giop dep operation are not used for IORs
         List<IorProfile> profiles = new List<IorProfile>();
         ParseIOR(cdrStream, out m_typId, profiles);
         m_profiles = profiles.ToArray();
     }
     else
     {
         throw new INV_OBJREF(9420, CompletionStatus.Completed_No);
     }
 }
コード例 #3
0
 /// <summary>
 /// creates an IOR from the IOR stringified form
 /// </summary>
 public Ior(string iorAsString)
 {
     // iorAsString contains only characters 0-9, A-F and IOR --> all of this are short characters
     if (iorAsString.StartsWith("IOR:"))
     {
         MemoryStream       memStream = new MemoryStream(StringConversions.Destringify(iorAsString, 4));
         CdrInputStreamImpl cdrStream = new CdrInputStreamImpl(memStream);
         byte flags = cdrStream.ReadOctet();
         cdrStream.ConfigStream(flags, new GiopVersion(1, 2)); // giop dep operation are not used for IORs
         List <IorProfile> profiles = new List <IorProfile>();
         ParseIOR(cdrStream, out m_typId, profiles);
         m_profiles = profiles.ToArray();
     }
     else
     {
         throw new INV_OBJREF(9420, CompletionStatus.Completed_No);
     }
 }
コード例 #4
0
        /// <param name="expectedContentLength">length in bytes after the request-id</param>
        private void CheckAssembledMessage(Stream msgStream, GiopVersion version,
                                           byte endianFlags, uint reqId,
                                           uint expectedContentLength)
        {
            CdrInputStreamImpl inStream = new CdrInputStreamImpl(msgStream);
            GiopHeader         header   = new GiopHeader(inStream);

            Assert.AreEqual(GiopMsgTypes.Request, header.GiopType);
            Assert.AreEqual(version, header.Version);

            uint contentLength = 0;
            uint msgReqId      = 0;

            if (!((version.Major == 1) && (version.Minor <= 1)))
            {
                // GIOP 1.2
                // req-id
                contentLength = (uint)(4 + expectedContentLength);
                msgReqId      = inStream.ReadULong();
            }
            else
            {
                // svc-cntx + req-id
                contentLength = (uint)(8 + expectedContentLength);
                inStream.ReadULong(); // svc-cnxt
                msgReqId = inStream.ReadULong();
            }

            Assert.AreEqual(contentLength, header.ContentMsgLength);
            Assert.AreEqual(endianFlags, header.GiopFlags);

            for (int i = 0; i < expectedContentLength; i++)
            {
                Assert.AreEqual(i % 255, inStream.ReadOctet());
            }
        }
コード例 #5
0
        public void TestLocateReplySerialisation() {
            uint requestId = 5;
            byte[] objectKey = new byte[] { 116, 101, 115, 116, 111, 98, 106, 101, 99, 116 }; // testobject
            string targetUri = "testobject";
            GiopVersion version = new GiopVersion(1, 2);
            LocateRequestMessage locReq = new LocateRequestMessage(requestId, objectKey, targetUri);
            // create a connection context
            GiopConnectionDesc conDesc = new GiopConnectionDesc(null, null);

            // create the reply
            LocateStatus replyStatus = LocateStatus.OBJECT_HERE;
            LocateReplyMessage locReply = new LocateReplyMessage(replyStatus);
 
            MemoryStream targetStream = new MemoryStream();
 
            m_handler.SerialiseOutgoingLocateReplyMessage(locReply, locReq, version, targetStream, conDesc);
 
            // check to serialised stream
            targetStream.Seek(0, SeekOrigin.Begin);

            CdrInputStreamImpl cdrIn = new CdrInputStreamImpl(targetStream);
            cdrIn.ConfigStream(0, version);
 
            // first is Giop-magic
            byte data;
            AssertBytesFollowing(m_giopMagic, cdrIn);
            // Giop version
            data = (byte) cdrIn.ReadOctet();
            Assert.AreEqual(1, data);
            data = (byte) cdrIn.ReadOctet();
            Assert.AreEqual(2, data);
            // flags: big-endian, no fragements
            data = (byte) cdrIn.ReadOctet();
            Assert.AreEqual(0, data);
            // Giop Msg type: locate reply
            data = (byte) cdrIn.ReadOctet();
            Assert.AreEqual((byte)GiopMsgTypes.LocateReply, data);
            // Giop Msg length
            uint msgLength = cdrIn.ReadULong();
            cdrIn.SetMaxLength(msgLength);
            // req-id
            Assert.AreEqual(requestId, cdrIn.ReadULong());
            // the location status
            Assert.AreEqual((uint)replyStatus, cdrIn.ReadULong());
        }
コード例 #6
0
        public void TestReplySerialisation() {
            // request msg the reply is for
            MethodInfo methodToCall = typeof(TestService).GetMethod("Add");
            object[] args = new object[] { ((Int32) 1), ((Int32) 2) };
            string uri = "iiop://localhost:8087/testuri"; // Giop 1.2 will be used because no version spec in uri
            GiopVersion version = new GiopVersion(1, 2);
            TestMessage msg = new TestMessage(methodToCall, args, uri);
            msg.Properties[SimpleGiopMsg.REQUEST_ID_KEY] = (uint)5;
            msg.Properties[SimpleGiopMsg.GIOP_VERSION_KEY] = version;
            msg.Properties[SimpleGiopMsg.CALLED_METHOD_KEY] = methodToCall;
            msg.Properties[SimpleGiopMsg.IDL_METHOD_NAME_KEY] = methodToCall.Name; // done by serialization normally
            // create a connection context
            GiopConnectionDesc conDesc = new GiopConnectionDesc(null, null);

            // create the reply
            ReturnMessage retMsg = new ReturnMessage((Int32) 3, new object[0], 0, null, msg);
 
            MemoryStream targetStream = new MemoryStream();
 
            m_handler.SerialiseOutgoingReplyMessage(retMsg, msg, version,
                                                    targetStream, conDesc);
 
            // check to serialised stream
            targetStream.Seek(0, SeekOrigin.Begin);

            CdrInputStreamImpl cdrIn = new CdrInputStreamImpl(targetStream);
            cdrIn.ConfigStream(0, new GiopVersion(1, 2));
 
            // first is Giop-magic
            byte data;
            AssertBytesFollowing(m_giopMagic, cdrIn);
            // Giop version
            data = (byte) cdrIn.ReadOctet();
            Assert.AreEqual(1, data);
            data = (byte) cdrIn.ReadOctet();
            Assert.AreEqual(2, data);
            // flags: big-endian, no fragements
            data = (byte) cdrIn.ReadOctet();
            Assert.AreEqual(0, data);
            // Giop Msg type: reply
            data = (byte) cdrIn.ReadOctet();
            Assert.AreEqual(1, data);
            // Giop Msg length
            uint msgLength = cdrIn.ReadULong();
            cdrIn.SetMaxLength(msgLength);
            // req-id
            Assert.AreEqual(5, cdrIn.ReadULong());
            // response status: NO_EXCEPTION
            Assert.AreEqual(0, cdrIn.ReadULong());
            // ignore service contexts
            SkipServiceContexts(cdrIn);
            // Giop 1.2, must be aligned on 8
            cdrIn.ForceReadAlign(Aligns.Align8);
            // now return value is following
            Assert.AreEqual(3, cdrIn.ReadLong());
        }
コード例 #7
0
        public void TestRequestSerialisation() {
            // prepare message
            MethodInfo methodToCall = typeof(TestService).GetMethod("Add");
            object[] args = new object[] { ((Int32) 1), ((Int32) 2) };
            string uri = "iiop://localhost:8087/testuri"; // Giop 1.2 will be used because no version spec in uri
            Ior target = m_iiopUrlUtil.CreateIorForUrl(uri, "");
            TestMessage msg = new TestMessage(methodToCall, args, uri);
            // prepare connection context
            GiopClientConnectionDesc conDesc = new GiopClientConnectionDesc(null, null,
                                                                            new GiopRequestNumberGenerator(), null);

            // serialise
            MemoryStream targetStream = new MemoryStream();
 
            uint reqId = 5;
            m_handler.SerialiseOutgoingRequestMessage(msg, target.Profiles[0], conDesc, targetStream, reqId);
 
            // check to serialised stream
            targetStream.Seek(0, SeekOrigin.Begin);
 
            CdrInputStreamImpl cdrIn = new CdrInputStreamImpl(targetStream);
            cdrIn.ConfigStream(0, new GiopVersion(1, 2));
 
            // first is Giop-magic
            byte data;
            AssertBytesFollowing(m_giopMagic, cdrIn);
            // Giop version
            data = (byte) cdrIn.ReadOctet();
            Assert.AreEqual(1, data);
            data = (byte) cdrIn.ReadOctet();
            Assert.AreEqual(2, data);
            // flags: big-endian, no fragements
            data = (byte) cdrIn.ReadOctet();
            Assert.AreEqual(0, data);
            // Giop Msg type: request
            data = (byte) cdrIn.ReadOctet();
            Assert.AreEqual(0, data);
            // Giop Msg length
            uint msgLength = cdrIn.ReadULong();
            cdrIn.SetMaxLength(msgLength);
            // req-id
            Assert.AreEqual(reqId, cdrIn.ReadULong());
            // response flags
            data = (byte) cdrIn.ReadOctet();
            Assert.AreEqual(3, data);
            cdrIn.ReadPadding(3); // reserved
            // target
            Assert.AreEqual(0, cdrIn.ReadUShort());
            // target must be testuri encoded as ascii-characters
            Assert.AreEqual(7 , cdrIn.ReadULong());
            AssertBytesFollowing(
                new byte[] { 116, 101, 115, 116, 117, 114, 105 },
                cdrIn);
            // now the target method follows: Add (string is terminated by a zero)
            Assert.AreEqual(4, cdrIn.ReadULong());
            AssertBytesFollowing(new byte[] { 65, 100, 100, 0}, cdrIn);
            // now service contexts are following
            SkipServiceContexts(cdrIn);
            // Giop 1.2, must be aligned on 8
            cdrIn.ForceReadAlign(Aligns.Align8);
            // now params are following
            Assert.AreEqual(1, cdrIn.ReadLong());
            Assert.AreEqual(2, cdrIn.ReadLong());
        }
コード例 #8
0
        /// <param name="expectedContentLength">length in bytes after the request-id</param>
        private void CheckAssembledMessage(Stream msgStream, GiopVersion version,
                                           byte endianFlags, uint reqId,
                                           uint expectedContentLength) {
 
            CdrInputStreamImpl inStream = new CdrInputStreamImpl(msgStream);
            GiopHeader header = new GiopHeader(inStream);
 
            Assert.AreEqual(GiopMsgTypes.Request, header.GiopType);
            Assert.AreEqual(version, header.Version);
 
            uint contentLength = 0;
            uint msgReqId = 0;
            if (!((version.Major == 1) && (version.Minor <= 1))) {
                // GIOP 1.2
                // req-id
                contentLength = (uint)(4 + expectedContentLength);
                msgReqId = inStream.ReadULong();
            } else {
                // svc-cntx + req-id
                contentLength = (uint)(8 + expectedContentLength);
                inStream.ReadULong(); // svc-cnxt
                msgReqId = inStream.ReadULong();
            }
 
            Assert.AreEqual(contentLength, header.ContentMsgLength);
            Assert.AreEqual(endianFlags, header.GiopFlags);

            for (int i = 0; i < expectedContentLength; i++) {
                Assert.AreEqual(i % 255, inStream.ReadOctet());
            }
 
        }
コード例 #9
0
        public void TestReplySerialisation()
        {
            // request msg the reply is for
            MethodInfo methodToCall = typeof(TestService).GetMethod("Add");

            object[]    args    = new object[] { ((Int32)1), ((Int32)2) };
            string      uri     = "iiop://localhost:8087/testuri"; // Giop 1.2 will be used because no version spec in uri
            GiopVersion version = new GiopVersion(1, 2);
            TestMessage msg     = new TestMessage(methodToCall, args, uri);

            msg.Properties[SimpleGiopMsg.REQUEST_ID_KEY]      = (uint)5;
            msg.Properties[SimpleGiopMsg.GIOP_VERSION_KEY]    = version;
            msg.Properties[SimpleGiopMsg.CALLED_METHOD_KEY]   = methodToCall;
            msg.Properties[SimpleGiopMsg.IDL_METHOD_NAME_KEY] = methodToCall.Name; // done by serialization normally
            // create a connection context
            GiopConnectionDesc conDesc = new GiopConnectionDesc(null, null);

            // create the reply
            ReturnMessage retMsg = new ReturnMessage((Int32)3, new object[0], 0, null, msg);

            MemoryStream targetStream = new MemoryStream();

            m_handler.SerialiseOutgoingReplyMessage(retMsg, msg, version,
                                                    targetStream, conDesc);

            // check to serialised stream
            targetStream.Seek(0, SeekOrigin.Begin);

            CdrInputStreamImpl cdrIn = new CdrInputStreamImpl(targetStream);

            cdrIn.ConfigStream(0, new GiopVersion(1, 2));

            // first is Giop-magic
            byte data;

            AssertBytesFollowing(m_giopMagic, cdrIn);
            // Giop version
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual(1, data);
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual(2, data);
            // flags: big-endian, no fragements
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual(0, data);
            // Giop Msg type: reply
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual(1, data);
            // Giop Msg length
            uint msgLength = cdrIn.ReadULong();

            cdrIn.SetMaxLength(msgLength);
            // req-id
            Assert.AreEqual(5, cdrIn.ReadULong());
            // response status: NO_EXCEPTION
            Assert.AreEqual(0, cdrIn.ReadULong());
            // ignore service contexts
            SkipServiceContexts(cdrIn);
            // Giop 1.2, must be aligned on 8
            cdrIn.ForceReadAlign(Aligns.Align8);
            // now return value is following
            Assert.AreEqual(3, cdrIn.ReadLong());
        }
コード例 #10
0
        public void TestRequestSerialisation()
        {
            // prepare message
            MethodInfo methodToCall = typeof(TestService).GetMethod("Add");

            object[]    args   = new object[] { ((Int32)1), ((Int32)2) };
            string      uri    = "iiop://localhost:8087/testuri"; // Giop 1.2 will be used because no version spec in uri
            Ior         target = m_iiopUrlUtil.CreateIorForUrl(uri, "");
            TestMessage msg    = new TestMessage(methodToCall, args, uri);
            // prepare connection context
            GiopClientConnectionDesc conDesc = new GiopClientConnectionDesc(null, null,
                                                                            new GiopRequestNumberGenerator(), null);

            // serialise
            MemoryStream targetStream = new MemoryStream();

            uint reqId = 5;

            m_handler.SerialiseOutgoingRequestMessage(msg, target.Profiles[0], conDesc, targetStream, reqId);

            // check to serialised stream
            targetStream.Seek(0, SeekOrigin.Begin);

            CdrInputStreamImpl cdrIn = new CdrInputStreamImpl(targetStream);

            cdrIn.ConfigStream(0, new GiopVersion(1, 2));

            // first is Giop-magic
            byte data;

            AssertBytesFollowing(m_giopMagic, cdrIn);
            // Giop version
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual(1, data);
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual(2, data);
            // flags: big-endian, no fragements
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual(0, data);
            // Giop Msg type: request
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual(0, data);
            // Giop Msg length
            uint msgLength = cdrIn.ReadULong();

            cdrIn.SetMaxLength(msgLength);
            // req-id
            Assert.AreEqual(reqId, cdrIn.ReadULong());
            // response flags
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual(3, data);
            cdrIn.ReadPadding(3); // reserved
            // target
            Assert.AreEqual(0, cdrIn.ReadUShort());
            // target must be testuri encoded as ascii-characters
            Assert.AreEqual(7, cdrIn.ReadULong());
            AssertBytesFollowing(
                new byte[] { 116, 101, 115, 116, 117, 114, 105 },
                cdrIn);
            // now the target method follows: Add (string is terminated by a zero)
            Assert.AreEqual(4, cdrIn.ReadULong());
            AssertBytesFollowing(new byte[] { 65, 100, 100, 0 }, cdrIn);
            // now service contexts are following
            SkipServiceContexts(cdrIn);
            // Giop 1.2, must be aligned on 8
            cdrIn.ForceReadAlign(Aligns.Align8);
            // now params are following
            Assert.AreEqual(1, cdrIn.ReadLong());
            Assert.AreEqual(2, cdrIn.ReadLong());
        }