/// <summary> /// Constructs a giop message handler, which uses the given /// ArgumentsSerializerFactory for serializing/deserializing /// requests/replys. The headerFlags parameter defines the /// used header flags for messages initiated by this handler. /// The interceptionOptions[] provides the information on /// channel level interceptors. /// </summary> internal GiopMessageHandler(ArgumentsSerializerFactory argSerFactory, byte headerFlags, IInterceptionOption[] interceptionOptions) { m_ser = new GiopMessageBodySerialiser(argSerFactory); m_headerFlags = headerFlags; m_interceptionOptions = interceptionOptions; }
public void TestWCharSetDefinedServer() { byte[] sourceContent = new byte[] { 0, 0, 0, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 116, 101, 115, 116, 117, 114, 105, 0, 0, 0, 0, 12, 69, 99, 104, 111, 87, 83, 116, 114, 105, 110, 103, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 12, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 9, 0, 0, 0, 8, 0, 116, 0, 101, 0, 115, 0, 116}; MemoryStream sourceStream = new MemoryStream(sourceContent); // create a connection context: this is needed for request deserialisation GiopConnectionDesc conDesc = new GiopConnectionDesc(null, null); // go to stream begin sourceStream.Seek(0, SeekOrigin.Begin); GiopMessageBodySerialiser ser = new GiopMessageBodySerialiser( new ArgumentsSerializerFactory(m_serFactory)); CdrInputStreamImpl cdrSourceStream = new CdrInputStreamImpl(sourceStream); cdrSourceStream.ConfigStream(0, new GiopVersion(1, 2)); cdrSourceStream.SetMaxLength((uint)sourceContent.Length); IMessage result = null; TestStringInterfaceImpl service = new TestStringInterfaceImpl(); try { // object which should be called string uri = "testuri"; RemotingServices.Marshal(service, uri); // deserialise request message result = ser.DeserialiseRequest(cdrSourceStream, new GiopVersion(1,2), conDesc, InterceptorManager.EmptyInterceptorOptions); } finally { RemotingServices.Disconnect(service); } // now check if values are correct Assert.IsTrue(result != null, "deserialised message is null"); object[] args = (object[])result.Properties[SimpleGiopMsg.ARGS_KEY]; Assert.IsTrue(args != null, "args is null"); Assert.AreEqual(1, args.Length); Assert.AreEqual("test", args[0]); }
public void TestWCharSetDefinedClient() { MethodInfo methodToCall = typeof(TestStringInterface).GetMethod("EchoWString"); object[] args = new object[] { "test" }; string uri = "iiop://localhost:8087/testuri"; // Giop 1.2 will be used because no version spec in uri Ior target = m_iiopUrlUtil.CreateIorForUrl(uri, ""); IIorProfile targetProfile = target.Profiles[0]; TestMessage msg = new TestMessage(methodToCall, args, uri); msg.Properties[SimpleGiopMsg.REQUEST_ID_KEY] = (uint)5; // set request-id msg.Properties[SimpleGiopMsg.TARGET_PROFILE_KEY] = targetProfile; // prepare connection context GiopClientConnectionDesc conDesc = new GiopClientConnectionDesc(null, null, new GiopRequestNumberGenerator(), null); GiopMessageBodySerialiser ser = new GiopMessageBodySerialiser( new ArgumentsSerializerFactory(m_serFactory)); GiopClientRequest request = new GiopClientRequest(msg, conDesc, new IInterceptionOption[0]); MemoryStream baseStream = new MemoryStream(); CdrOutputStreamImpl targetStream = new CdrOutputStreamImpl(baseStream, 0, new GiopVersion(1,2)); ser.SerialiseRequest(request, targetStream, targetProfile, conDesc); Assert.AreEqual( new byte[] { 0, 0, 0, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 116, 101, 115, 116, 117, 114, 105, 0, 0, 0, 0, 12, 69, 99, 104, 111, 87, 83, 116, 114, 105, 110, 103, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 12, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 9, 0, 0, 0, 8, 0, 116, 0, 101, 0, 115, 0, 116}, baseStream.ToArray(),"serialised message"); }
public void TestWCharSetNotDefinedClient() { MethodInfo methodToCall = typeof(TestStringInterface).GetMethod("EchoWString"); object[] args = new object[] { "test" }; string uri = "IOR:000000000000000100000000000000010000000000000020000102000000000A6C6F63616C686F73740004D2000000047465737400000000"; Ior target = m_iiopUrlUtil.CreateIorForUrl(uri, ""); IIorProfile targetProfile = target.Profiles[0]; TestMessage msg = new TestMessage(methodToCall, args, uri); msg.Properties[SimpleGiopMsg.REQUEST_ID_KEY] = (uint)5; // set request-id msg.Properties[SimpleGiopMsg.TARGET_PROFILE_KEY] = targetProfile; // prepare connection context GiopClientConnectionDesc conDesc = new GiopClientConnectionDesc(null, null, new GiopRequestNumberGenerator(), null); GiopMessageBodySerialiser ser = new GiopMessageBodySerialiser( new ArgumentsSerializerFactory(m_serFactory)); GiopClientRequest request = new GiopClientRequest(msg, conDesc, new IInterceptionOption[0]); CdrOutputStreamImpl targetStream = new CdrOutputStreamImpl(new MemoryStream(), 0, new GiopVersion(1,2)); ser.SerialiseRequest(request, targetStream, targetProfile, conDesc); }
public void TestSameServiceIdMultiple() { // checks if service contexts with the same id, doesn't throw an exception // checks, that the first service context is considered, others are thrown away GiopMessageBodySerialiser ser = new GiopMessageBodySerialiser( new ArgumentsSerializerFactory(m_serFactory)); MemoryStream stream = new MemoryStream(); CdrOutputStreamImpl cdrOut = new CdrOutputStreamImpl(stream, 0, new GiopVersion(1,2)); cdrOut.WriteULong(2); // nr of contexts cdrOut.WriteULong(1234567); // id of context 1 CdrEncapsulationOutputStream encap = new CdrEncapsulationOutputStream(0); cdrOut.WriteEncapsulation(encap); cdrOut.WriteULong(1234567); // id of context 2 encap = new CdrEncapsulationOutputStream(0); cdrOut.WriteEncapsulation(encap); // reset stream stream.Seek(0, SeekOrigin.Begin); CdrInputStreamImpl cdrIn = new CdrInputStreamImpl(stream); cdrIn.ConfigStream(0, new GiopVersion(1,2)); omg.org.IOP.ServiceContextList result = new ServiceContextList(cdrIn); // check if context is present Assert.IsTrue(result.ContainsServiceContext(1234567), "expected context not in collection"); }
public void TestWCharSetNotDefinedServer() { byte[] sourceContent = new byte[] { 0, 0, 0, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 116, 101, 115, 116, 117, 114, 105, 0, 0, 0, 0, 12, 69, 99, 104, 111, 87, 83, 116, 114, 105, 110, 103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 116, 0, 101, 0, 115, 0, 116}; MemoryStream sourceStream = new MemoryStream(sourceContent); // create a connection context: this is needed for request deserialisation GiopConnectionDesc conDesc = new GiopConnectionDesc(null, null); // go to stream begin sourceStream.Seek(0, SeekOrigin.Begin); GiopMessageBodySerialiser ser = new GiopMessageBodySerialiser( new ArgumentsSerializerFactory(m_serFactory)); CdrInputStreamImpl cdrSourceStream = new CdrInputStreamImpl(sourceStream); cdrSourceStream.ConfigStream(0, new GiopVersion(1, 2)); cdrSourceStream.SetMaxLength((uint)sourceContent.Length); IMessage result = null; TestStringInterfaceImpl service = new TestStringInterfaceImpl(); try { // object which should be called string uri = "testuri"; RemotingServices.Marshal(service, uri); // deserialise request message result = ser.DeserialiseRequest(cdrSourceStream, new GiopVersion(1,2), conDesc, InterceptorManager.EmptyInterceptorOptions); Assert.Fail("no exception, although code set not set"); } catch (RequestDeserializationException rde) { Assert.NotNull(rde.Reason, "rde inner exception"); Assert.AreEqual(typeof(BAD_PARAM), rde.Reason.GetType(), "rde type"); } finally { RemotingServices.Disconnect(service); } }