2009-08-31 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Mon, 31 Aug 2009 12:10:33 +0000 (12:10 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Mon, 31 Aug 2009 12:10:33 +0000 (12:10 -0000)
* HttpChannelFactory.cs : reject URI mismatch cases when required.

* HttpTransportBindingElementTest.cs : test for URI mismatch case.

svn path=/trunk/mcs/; revision=140960

mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelFactory.cs
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/ChangeLog
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/HttpTransportBindingElementTest.cs

index 526c27356a7593fd1b5d7574ad18c4b9572cc2c0..008926f2c33e8d444ccc2f72153aa7d76747fec5 100755 (executable)
@@ -1,3 +1,7 @@
+2009-08-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpChannelFactory.cs : reject URI mismatch cases when required.
+
 2009-08-26  Atsushi Enomoto  <atsushi@ximian.com>
 
        * PeerDuplexChannel.cs : When received Connect() from neighbor,
index 048ad4bbc5745693c62c28d919435db49c11cab1..df9bfe18a19f7b692cb5e8280a1f2defd00662a8 100644 (file)
@@ -68,6 +68,10 @@ namespace System.ServiceModel.Channels
                        if (source.Scheme != address.Uri.Scheme)
                                throw new ArgumentException (String.Format ("Argument EndpointAddress has unsupported URI scheme: {0}", address.Uri.Scheme));
 
+                       if (MessageEncoder.MessageVersion.Addressing.Equals (AddressingVersion.None) &&
+                           !address.Uri.Equals (via))
+                               throw new ArgumentException (String.Format ("The endpoint address '{0}' and via uri '{1}' must match when the corresponding binding has addressing version in the message version value as None.", address.Uri, via));
+
                        Type t = typeof (TChannel);
                        if (t == typeof (IRequestChannel))
                                return (TChannel) (object) new HttpRequestChannel ((HttpChannelFactory<IRequestChannel>) (object) this, address, via);
index 85dfad6549efbf2b884d95b3e4281d246239cbd3..939332fc7892a389c879cab37008d1ac57c8e583 100644 (file)
@@ -1,3 +1,7 @@
+2009-08-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpTransportBindingElementTest.cs : test for URI mismatch case.
+
 2009-08-20  Atsushi Enomoto  <atsushi@ximian.com>
 
        * MessageHeadersTest.cs : added a couple od duplicate tests. Fixed
index 3a9b445608eeaaeaf23d18a0f47b5a3f7b478c38..9cb37118cd00f69c829397bbeacdfa71004a3c1e 100644 (file)
@@ -30,6 +30,7 @@ using System.Collections.ObjectModel;
 using System.IO;
 using System.Net;
 using System.Net.Security;
+using System.Reflection;
 using System.ServiceModel;
 using System.ServiceModel.Channels;
 using System.ServiceModel.Description;
@@ -204,6 +205,36 @@ namespace MonoTests.System.ServiceModel.Channels
                        new BasicHttpBinding ().BuildChannelListener<IReplyChannel> (new BindingParameterCollection ());
                }
 
+               // when AddressingVersion is None (in MessageVersion), then
+               // EndpointAddress.Uri and via URIs must match.
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void EndpointAddressAndViaMustMatchOnAddressingNone ()
+               {
+                       try {
+                               var ch = ChannelFactory<IFoo>.CreateChannel (new BasicHttpBinding (), new EndpointAddress ("http://localhost:37564/"), new Uri ("http://localhost:8080/HogeService"));
+                               ((ICommunicationObject) ch).Close ();
+                       } catch (TargetInvocationException) {
+                               // we throw this exception so far. Since it is
+                               // very internal difference (channel is created
+                               // inside ClientRuntimeChannel.ctor() while .NET
+                               // does it in ChannelFactory<T>.CreateChannel(),
+                               // there is no point of treating it as failure).
+                               throw new ArgumentException ();
+                       }
+               }
+
+               #region contracts
+
+               [ServiceContract]
+               interface IFoo
+               {
+                       [OperationContract]
+                       string DoWork (string s1, string s2);
+               }
+
+               #endregion
+
                #region connection test
 
                string svcret;