Imported Upstream version 4.2.0.179

Former-commit-id: 4610231f55806d2a05ed69e5ff3faa7336cc1479
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent aa7da660d6
commit c042cd0c52
7507 changed files with 90259 additions and 657307 deletions

View File

@@ -46,12 +46,12 @@ namespace System.ServiceModel.Channels
public static class UrlUtility {
public static string UrlEncode (string s, Encoding e)
{
return System.Net.WebUtility.UrlEncode (s);
return System.Runtime.UrlUtility.UrlEncode (s, e);
}
public static string UrlDecode (string s, Encoding e)
{
return System.Net.WebUtility.UrlDecode (s);
return System.Runtime.UrlUtility.UrlDecode (s, e);
}
}
}
@@ -66,4 +66,4 @@ namespace System.ServiceModel.Description
namespace System.ServiceModel.Channels
{
public interface ITransportTokenAssertionProvider {}
}
}

42
mcs/class/System.ServiceModel/Makefile Executable file → Normal file
View File

@@ -8,14 +8,11 @@ RESOURCE_FILES = \
LIBRARY = System.ServiceModel.dll
LIB_REFS = System System.Xml System.Core System.Runtime.Serialization
LIB_MCS_FLAGS = \
/nowarn:414,169,67,3005,436,219,618 \
/unsafe \
/d:TRACE \
/r:System.dll \
/r:System.Xml.dll \
/r:System.Core.dll \
/r:System.Runtime.Serialization.dll \
$(RESOURCE_FILES:%=/resource:%)
ifdef XAMMAC_4_5
@@ -23,48 +20,31 @@ LIB_REFS += System.ServiceModel.Internals
endif
ifneq (2.1, $(FRAMEWORK_VERSION))
LIB_MCS_FLAGS += /d:NET_3_0 \
/r:System.Configuration.dll \
/r:System.Data.dll \
/r:System.Security.dll \
/r:System.IdentityModel.dll \
/r:System.IdentityModel.Selectors.dll \
/r:System.Transactions.dll \
/r:System.Messaging.dll \
/r:System.Web.Services.dll \
/r:Mono.Security.dll
ifdef XAMAMC_4_5
LIB_MCS_FLAGS += /r:System.Net.dll
endif
LIB_REFS += System.Configuration System.Data System.Security System.IdentityModel System.IdentityModel.Selectors System.Transactions System.Messaging System.Web.Services Mono.Security
LIB_MCS_FLAGS += /d:NET_3_0
ifndef NO_SYSTEM_WEB_DEPENDENCY
LIB_MCS_FLAGS += /r:System.Web.dll
endif
LIB_REFS += System.Web
endif
ifeq (4, $(FRAMEWORK_VERSION_MAJOR))
ifndef NO_SYSTEM_WEB_APPSERVICES_DEPENDENCY
LIB_MCS_FLAGS += /r:System.Web.ApplicationServices.dll
endif
ifndef NO_SYSTEM_SERVICEMODEL_ACTIVATION_DEPENDENCY
activation = $(the_libdir_base)System.ServiceModel.Activation.dll
servicemodel_deps = $(activation)
endif
ifneq (plainservice/,$(intermediate))
ifndef NO_SYSTEM_SERVICEMODEL_ACTIVATION_DEPENDENCY
LIB_MCS_FLAGS += -define:HAS_ACTIVATION -r:System.ServiceModel.Activation.dll
endif
endif # NO_SYSTEM_SERVICEMODEL_ACTIVATION_DEPENDENCY
ifndef NO_SYSTEM_WEB_APPSERVICES_DEPENDENCY
LIB_REFS += System.Web.ApplicationServices
endif
ifndef NO_SYSTEM_WEB_APPSERVICES_DEPENDENCY
LIB_MCS_FLAGS += -r:System.Web.ApplicationServices.dll
endif
endif
endif # (4, $(FRAMEWORK_VERSION_MAJOR))
endif
endif # (2.1, $(FRAMEWORK_VERSION))
TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)

View File

@@ -120,7 +120,7 @@ namespace System.ServiceModel.Channels
{
VerifyMessageVersion (message);
using (var xw = XmlDictionaryWriter.CreateBinaryWriter (stream, Constants.SoapDictionary, session ? CurrentWriterSession : null))
using (var xw = XmlDictionaryWriter.CreateBinaryWriter (stream, Constants.SoapDictionary, session ? CurrentWriterSession : null, false))
message.WriteMessage (xw);
}

View File

@@ -125,9 +125,7 @@ namespace System.ServiceModel.Channels
//web_request.UseDefaultCredentials = false;
}
#if !NET_2_1 // FIXME: implement this to not depend on Timeout property
web_request.Timeout = (int) timeout.TotalMilliseconds;
#endif
// There is no SOAP Action/To header when AddressingVersion is None.
if (message.Version.Envelope.Equals (EnvelopeVersion.Soap11) ||
@@ -190,6 +188,7 @@ namespace System.ServiceModel.Channels
if (hp.SuppressEntityBody)
suppressEntityBody = true;
}
#if !NET_2_1
if (source.ClientCredentials != null) {
var cred = source.ClientCredentials;
@@ -205,9 +204,7 @@ namespace System.ServiceModel.Channels
if (buffer.Length > int.MaxValue)
throw new InvalidOperationException ("The argument message is too large.");
#if !NET_2_1
web_request.ContentLength = (int) buffer.Length;
#endif
web_request.BeginGetRequestStream (delegate (IAsyncResult r) {
try {
@@ -217,9 +214,7 @@ namespace System.ServiceModel.Channels
web_request.BeginGetResponse (GotResponse, result);
} catch (WebException ex) {
switch (ex.Status) {
#if !NET_2_1
case WebExceptionStatus.NameResolutionFailure:
#endif
case WebExceptionStatus.ConnectFailure:
result.Complete (new EndpointNotFoundException (new EndpointNotFoundException ().Message, ex));
break;

View File

@@ -31,7 +31,6 @@ using System.IO;
using System.Runtime.Serialization;
using System.Xml;
using System.Xml.Schema;
using Mono.Xml.XPath;
namespace System.ServiceModel.Channels
{
@@ -259,9 +258,16 @@ namespace System.ServiceModel.Channels
WriteBodyContents (body);
}
var nt = new NameTable ();
var nsmgr = new XmlNamespaceManager (nt);
nsmgr.AddNamespace ("s", Version.Envelope.Namespace);
nsmgr.AddNamespace ("a", Version.Addressing.Namespace);
var pc = new XmlParserContext (nt, nsmgr, null, XmlSpace.None);
var rs = new XmlReaderSettings ();
rs.ConformanceLevel = ConformanceLevel.Auto;
return XmlDictionaryReader.CreateDictionaryReader (XmlReader.Create (new StringReader (sw.ToString ()), rs));
return XmlDictionaryReader.CreateDictionaryReader (XmlReader.Create (new StringReader (sw.ToString ()), rs, pc));
}
protected abstract void OnWriteBodyContents (

View File

@@ -99,17 +99,6 @@ namespace System.ServiceModel.Description
#region internals required for moonlight compatibility
#if NET_2_1 // it uses S.R.Serialization internals which is InternalVisible to this assembly only in 2.1. So, DON'T use this member in full 2.0 profile.
XmlName msg_name;
internal XmlName MessageName {
get {
if (msg_name == null)
msg_name = new XmlName (KnownTypeCollection.GetStaticQName (MessageType).Name);
return msg_name;
}
}
#endif
internal bool IsTypedMessage {
get { return MessageType == null; }
}

View File

@@ -53,6 +53,7 @@ namespace System.ServiceModel.Description
EndpointAddress address;
SMBinding binding;
MetadataExchangeClientMode mode = MetadataExchangeClientMode.MetadataExchange;
TimeSpan? operation_timeout = null;
// constructors
@@ -88,7 +89,17 @@ namespace System.ServiceModel.Description
[MonoTODO]
public int MaximumResolvedReferences { get; set; }
public TimeSpan OperationTimeout { get; set; }
public TimeSpan OperationTimeout {
get {
if (!this.operation_timeout.HasValue) {
this.operation_timeout = DefaultCommunicationTimeouts.Instance.ReceiveTimeout;
}
return this.operation_timeout.Value;
}
set {
this.operation_timeout = value;
}
}
[MonoTODO]
public bool ResolveMetadataReferences { get; set; }

View File

@@ -96,8 +96,9 @@ namespace System.ServiceModel.Description
MetadataSection.CreateFromServiceDescription (sd));
foreach (XmlSchema xs in GeneratedXmlSchemas.Schemas ())
metadata.MetadataSections.Add (
MetadataSection.CreateFromSchema (xs));
if (xs.TargetNamespace != XmlSchema.Namespace)
metadata.MetadataSections.Add (
MetadataSection.CreateFromSchema (xs));
return metadata;
}
@@ -459,7 +460,6 @@ namespace System.ServiceModel.Description
get {
if (xsd_exporter == null)
xsd_exporter = new XsdDataContractExporter ();
return xsd_exporter;
}
}
@@ -651,6 +651,9 @@ namespace System.ServiceModel.Description
return;
}
if (ns == string.Empty)
return;
XmlSchemaImport imp = new XmlSchemaImport ();
imp.Namespace = ns;
schema.Includes.Add (imp);

View File

@@ -584,10 +584,14 @@ namespace System.ServiceModel.Dispatcher
{
Message msg;
var input = (IInputChannel) result.AsyncState;
if (input.EndTryReceive (result, out msg))
ProcessInput (input, msg);
else
try {
if (input.EndTryReceive (result, out msg))
ProcessInput (input, msg);
else
input.Close ();
} catch (ObjectDisposedException) {
input.Close ();
}
}
void ProcessRequest (IReplyChannel reply, RequestContext rc)

View File

@@ -67,6 +67,8 @@ namespace System.ServiceModel.MonoInternal
TimeSpan default_open_timeout, default_close_timeout;
IChannel channel;
IChannelFactory factory;
TimeSpan? operation_timeout = null;
ChannelFactory channel_factory;
#region delegates
readonly ProcessDelegate _processDelegate;
@@ -86,6 +88,7 @@ namespace System.ServiceModel.MonoInternal
ChannelFactory channelFactory, EndpointAddress remoteAddress, Uri via)
: this (endpoint.CreateClientRuntime (null), endpoint.Contract, channelFactory.DefaultOpenTimeout, channelFactory.DefaultCloseTimeout, null, channelFactory.OpenedChannelFactory, endpoint.Binding.MessageVersion, remoteAddress, via)
{
channel_factory = channelFactory;
}
public ClientRuntimeChannel (ClientRuntime runtime, ContractDescription contract, TimeSpan openTimeout, TimeSpan closeTimeout, IChannel contextChannel, IChannelFactory factory, MessageVersion messageVersion, EndpointAddress remoteAddress, Uri via)
@@ -108,7 +111,6 @@ namespace System.ServiceModel.MonoInternal
// default values
AllowInitializationUI = true;
OperationTimeout = TimeSpan.FromMinutes (1);
if (contextChannel != null)
channel = contextChannel;
@@ -322,8 +324,10 @@ namespace System.ServiceModel.MonoInternal
}
}
[MonoTODO]
public TimeSpan OperationTimeout { get; set; }
public TimeSpan OperationTimeout {
get { return this.operation_timeout ?? (channel_factory != null ? channel_factory.Endpoint.Binding.SendTimeout : DefaultCommunicationTimeouts.Instance.SendTimeout); }
set { this.operation_timeout = value; }
}
public IOutputSession OutputSession {
get {

View File

@@ -1,4 +1,5 @@
NUnitMoonHelper.cs
../../test-helpers/NetworkHelpers.cs
FeatureBased/Features.Client/AsyncCallTesterProxy.cs
FeatureBased/Features.Client/AsyncPatternServer.cs
FeatureBased/Features.Client/DataContractTesterProxy.cs
@@ -210,3 +211,5 @@ MetadataTests/MetadataSamples.cs
MetadataTests/TestContext.cs
MetadataTests/TestLabel.cs
MetadataTests/ExportTests.cs
../../test-helpers/NetworkHelpers.cs

View File

@@ -43,6 +43,8 @@ using System.Threading;
using System.Xml;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.Channels
{
[TestFixture]
@@ -131,7 +133,7 @@ namespace MonoTests.System.ServiceModel.Channels
CustomBinding binding = new CustomBinding (sbe,
new HttpTransportBindingElement ());
IChannelListener<IReplyChannel> l =
binding.BuildChannelListener<IReplyChannel> (new Uri ("http://localhost:37564"), new BindingParameterCollection ());
binding.BuildChannelListener<IReplyChannel> (new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()), new BindingParameterCollection ());
try {
l.Open ();
} finally {
@@ -171,11 +173,11 @@ namespace MonoTests.System.ServiceModel.Channels
b_res.ReceiveTimeout = b_res.SendTimeout = TimeSpan.FromSeconds (10);
EndpointAddress remaddr = new EndpointAddress (
new Uri ("http://localhost:37564"),
new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()),
new X509CertificateEndpointIdentity (cert2));
CalcProxy proxy = null;
ServiceHost host = new ServiceHost (typeof (CalcService));
host.AddServiceEndpoint (typeof (ICalc), b_res, "http://localhost:37564");
host.AddServiceEndpoint (typeof (ICalc), b_res, "http://localhost:" + NetworkHelpers.FindFreePort ());
ServiceCredentials cred = new ServiceCredentials ();
cred.ServiceCertificate.Certificate = cert;
@@ -240,7 +242,7 @@ namespace MonoTests.System.ServiceModel.Channels
new HttpTransportBindingElement ();
CustomBinding binding = new CustomBinding (sbe, hbe);
host.AddServiceEndpoint (typeof (IFoo),
binding, new Uri ("http://localhost:37564"));
binding, new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()));
ServiceCredentials cred = new ServiceCredentials ();
cred.ServiceCertificate.Certificate =
new X509Certificate2 ("Test/Resources/test.pfx", "mono");

View File

@@ -36,6 +36,8 @@ using System.Text;
using System.Xml;
using NUnit.Framework;
using MonoTests.Helpers;
using Element = System.ServiceModel.Channels.BinaryMessageEncodingBindingElement;
namespace MonoTests.System.ServiceModel.Channels
@@ -191,14 +193,15 @@ namespace MonoTests.System.ServiceModel.Channels
var bindingsvc = new CustomBinding (new BindingElement [] {
new BinaryMessageEncodingBindingElement (),
new TcpTransportBindingElement () });
host.AddServiceEndpoint (typeof (IFoo), bindingsvc, "net.tcp://localhost:37564/");
int port = NetworkHelpers.FindFreePort ();
host.AddServiceEndpoint (typeof (IFoo), bindingsvc, "net.tcp://localhost:" + port + "/");
host.Description.Behaviors.Find<ServiceBehaviorAttribute> ().IncludeExceptionDetailInFaults = true;
host.Open (TimeSpan.FromSeconds (5));
try {
for (int i = 0; i < 2; i++) {
var bindingcli = new NetTcpBinding ();
bindingcli.Security.Mode = SecurityMode.None;
var cli = new ChannelFactory<IFooClient> (bindingcli, new EndpointAddress ("net.tcp://localhost:37564/")).CreateChannel ();
var cli = new ChannelFactory<IFooClient> (bindingcli, new EndpointAddress ("net.tcp://localhost:" + port + "/")).CreateChannel ();
Assert.AreEqual ("test for echo", cli.Echo ("TEST FOR ECHO"), "#1");
var sid = cli.SessionId;
Assert.AreEqual (3000, cli.Add (1000, 2000), "#2");
@@ -207,7 +210,7 @@ namespace MonoTests.System.ServiceModel.Channels
}
} finally {
host.Close (TimeSpan.FromSeconds (5));
var t = new TcpListener (37564);
var t = new TcpListener (port);
t.Start ();
t.Stop ();
}
@@ -220,7 +223,8 @@ namespace MonoTests.System.ServiceModel.Channels
var bindingsvc = new CustomBinding (new BindingElement [] {
new BinaryMessageEncodingBindingElement (),
new HttpTransportBindingElement () });
host.AddServiceEndpoint (typeof (IFoo), bindingsvc, "http://localhost:37564/");
int port = NetworkHelpers.FindFreePort ();
host.AddServiceEndpoint (typeof (IFoo), bindingsvc, "http://localhost:" + port + "/");
host.Description.Behaviors.Find<ServiceBehaviorAttribute> ().IncludeExceptionDetailInFaults = true;
host.Open (TimeSpan.FromSeconds (5));
try {
@@ -228,7 +232,7 @@ namespace MonoTests.System.ServiceModel.Channels
var bindingcli = new CustomBinding (new BindingElement [] {
new BinaryMessageEncodingBindingElement (),
new HttpTransportBindingElement () });
var cli = new ChannelFactory<IFooClient> (bindingcli, new EndpointAddress ("http://localhost:37564/")).CreateChannel ();
var cli = new ChannelFactory<IFooClient> (bindingcli, new EndpointAddress ("http://localhost:" + port + "/")).CreateChannel ();
Assert.AreEqual ("test for echo", cli.Echo ("TEST FOR ECHO"), "#1");
var sid = cli.SessionId;
Assert.AreEqual (3000, cli.Add (1000, 2000), "#2");
@@ -237,7 +241,7 @@ namespace MonoTests.System.ServiceModel.Channels
}
} finally {
host.Close (TimeSpan.FromSeconds (5));
var t = new TcpListener (37564);
var t = new TcpListener (port);
t.Start ();
t.Stop ();
}

View File

@@ -40,6 +40,8 @@ using System.Text;
using System.Xml;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.Channels
{
[TestFixture]
@@ -211,7 +213,7 @@ namespace MonoTests.System.ServiceModel.Channels
new HandlerTransportBindingElement (sender));
EndpointAddress address = new EndpointAddress (
new Uri ("http://localhost:37564"),
new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()),
new X509CertificateEndpointIdentity (new X509Certificate2 ("Test/Resources/test.pfx", "mono")));
ChannelFactory<IRequestChannel> cf =
@@ -259,7 +261,7 @@ namespace MonoTests.System.ServiceModel.Channels
new HandlerTransportBindingElement (sender));
EndpointAddress address = new EndpointAddress (
new Uri ("http://localhost:37564"),
new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()),
new X509CertificateEndpointIdentity (new X509Certificate2 ("Test/Resources/test.pfx", "mono")));
ChannelProtectionRequirements reqs =
@@ -322,7 +324,7 @@ namespace MonoTests.System.ServiceModel.Channels
new HttpTransportBindingElement ());
BindingContext ctx = new BindingContext (
cb, new BindingParameterCollection (),
new Uri ("http://localhost:37564"), String.Empty, ListenUriMode.Unique);
new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()), String.Empty, ListenUriMode.Unique);
new TextMessageEncodingBindingElement ().BuildChannelListener<IReplyChannel> (ctx);
}
@@ -336,7 +338,7 @@ namespace MonoTests.System.ServiceModel.Channels
ServiceHost host = new ServiceHost (typeof (FooService));
host.AddServiceEndpoint (typeof (IFooService),
new CustomBinding (new MyBindingElement (false), new HttpTransportBindingElement ()),
"http://localhost:37564");
"http://localhost:" + NetworkHelpers.FindFreePort ());
host.Open ();
}
@@ -349,7 +351,7 @@ namespace MonoTests.System.ServiceModel.Channels
ServiceHost host = new ServiceHost (typeof (FooService));
host.AddServiceEndpoint (typeof (IFooService),
new CustomBinding (new MyBindingElement (true), new HttpTransportBindingElement ()),
"http://localhost:37564");
"http://localhost:" + NetworkHelpers.FindFreePort ());
host.Open ();
host.Close ();
}
@@ -363,7 +365,7 @@ namespace MonoTests.System.ServiceModel.Channels
ServiceHost host = new ServiceHost (typeof (FooService));
host.AddServiceEndpoint (typeof (IFooService),
new CustomBinding (new MyBindingElement (true), new HttpTransportBindingElement ()),
"http://localhost:37564", new Uri ("foobar", UriKind.Relative));
"http://localhost:" + NetworkHelpers.FindFreePort (), new Uri ("foobar", UriKind.Relative));
}
[Test]
@@ -372,10 +374,10 @@ namespace MonoTests.System.ServiceModel.Channels
{
// MyBindingElement overrides GetProperty<T>() to call GetInnerProperty<T>() (default implementation).
// HttpTransportBindingElement should return Soap11.
ServiceHost host = new ServiceHost (typeof (FooService), new Uri ("http://localhost:37564"));
ServiceHost host = new ServiceHost (typeof (FooService), new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()));
host.AddServiceEndpoint (typeof (IFooService),
new CustomBinding (new MyBindingElement (true), new HttpTransportBindingElement ()),
"http://localhost:37564", new Uri ("foobar", UriKind.Relative));
"http://localhost:" + NetworkHelpers.FindFreePort (), new Uri ("foobar", UriKind.Relative));
host.Open ();
host.Close ();
}

View File

@@ -38,6 +38,8 @@ using System.Threading;
using System.Xml;
using NUnit.Framework;
using MonoTests.Helpers;
#if NET_4_0
using System.Security.Authentication.ExtendedProtection;
#endif
@@ -203,7 +205,7 @@ namespace MonoTests.System.ServiceModel.Channels
var cf = new HttpTransportBindingElement ().BuildChannelFactory<IRequestChannel> (ctx);
Assert.IsTrue (cf is ChannelFactoryBase<IRequestChannel>, "#1");
cf.Open ();
cf.CreateChannel (new EndpointAddress ("http://localhost:8080"), null);
cf.CreateChannel (new EndpointAddress ("http://localhost:" + NetworkHelpers.FindFreePort ()), null);
}
[Test]
@@ -228,7 +230,7 @@ namespace MonoTests.System.ServiceModel.Channels
public void EndpointAddressAndViaMustMatchOnAddressingNone ()
{
try {
var ch = ChannelFactory<IFoo>.CreateChannel (new BasicHttpBinding (), new EndpointAddress ("http://localhost:37564/"), new Uri ("http://localhost:8080/HogeService"));
var ch = ChannelFactory<IFoo>.CreateChannel (new BasicHttpBinding (), new EndpointAddress ("http://localhost:" + NetworkHelpers.FindFreePort () + "/"), new Uri ("http://localhost:" + NetworkHelpers.FindFreePort () + "/HogeService"));
((ICommunicationObject) ch).Close ();
} catch (TargetInvocationException) {
// we throw this exception so far. Since it is
@@ -338,7 +340,7 @@ namespace MonoTests.System.ServiceModel.Channels
BindingContext lbc = new BindingContext (
new CustomBinding (),
new BindingParameterCollection (),
new Uri ("http://localhost:37564"),
new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()),
String.Empty, ListenUriMode.Explicit);
listener = lel.BuildChannelListener<IReplyChannel> (lbc);
@@ -370,7 +372,7 @@ namespace MonoTests.System.ServiceModel.Channels
factory.Open ();
IRequestChannel request = factory.CreateChannel (
new EndpointAddress ("http://localhost:37564"));
new EndpointAddress ("http://localhost:" + NetworkHelpers.FindFreePort ()));
request.Open ();

View File

@@ -41,6 +41,8 @@ using System.ServiceModel.Security.Tokens;
using System.Xml;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.Channels
{
[TestFixture]
@@ -428,7 +430,7 @@ namespace MonoTests.System.ServiceModel.Channels
ClientCredentials cred = new ClientCredentials ();
cred.ClientCertificate.Certificate =
new X509Certificate2 ("Test/Resources/test.pfx", "mono");
IChannelFactory<IReplyChannel> ch = b.BuildChannelFactory<IReplyChannel> (new Uri ("http://localhost:37564"), cred);
IChannelFactory<IReplyChannel> ch = b.BuildChannelFactory<IReplyChannel> (new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()), cred);
try {
ch.Open ();
} finally {
@@ -456,7 +458,7 @@ namespace MonoTests.System.ServiceModel.Channels
ServiceCredentials cred = new ServiceCredentials ();
cred.ServiceCertificate.Certificate =
new X509Certificate2 ("Test/Resources/test.pfx", "mono");
IChannelListener<IReplyChannel> ch = b.BuildChannelListener<IReplyChannel> (new Uri ("http://localhost:37564"), cred);
IChannelListener<IReplyChannel> ch = b.BuildChannelListener<IReplyChannel> (new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()), cred);
try {
ch.Open ();
} finally {
@@ -478,7 +480,7 @@ namespace MonoTests.System.ServiceModel.Channels
new UserNameSecurityTokenParameters ());
Binding b = new CustomBinding (be, new HttpTransportBindingElement ());
X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.pfx", "mono");
EndpointAddress ea = new EndpointAddress (new Uri ("http://localhost:37564"), new X509CertificateEndpointIdentity (cert));
EndpointAddress ea = new EndpointAddress (new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()), new X509CertificateEndpointIdentity (cert));
CalcProxy client = new CalcProxy (b, ea);
client.ClientCredentials.UserName.UserName = "rupert";
client.Sum (1, 2);

View File

@@ -37,6 +37,8 @@ using System.Threading;
using System.Xml;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.Channels
{
[TestFixture]
@@ -173,8 +175,9 @@ namespace MonoTests.System.ServiceModel.Channels
new TcpTransportBindingElement () });
bindingS.ReceiveTimeout = TimeSpan.FromSeconds (5);
bindingS.OpenTimeout = TimeSpan.FromSeconds (20);
int port = NetworkHelpers.FindFreePort ();
host.AddServiceEndpoint (typeof (IFoo),
bindingS, new Uri ("net.tcp://localhost:37564"));
bindingS, new Uri ("net.tcp://localhost:" + port));
host.Description.Behaviors.Find<ServiceBehaviorAttribute> ().IncludeExceptionDetailInFaults = true;
host.Open ();
@@ -182,7 +185,7 @@ namespace MonoTests.System.ServiceModel.Channels
for (int i = 0; i < 2; i++) {
var bindingC = new NetTcpBinding ();
bindingC.Security.Mode = SecurityMode.None;
IFooChannel proxy = new ChannelFactory<IFooChannel> (bindingC, new EndpointAddress ("net.tcp://localhost:37564/")).CreateChannel ();
IFooChannel proxy = new ChannelFactory<IFooChannel> (bindingC, new EndpointAddress ("net.tcp://localhost:" + port + "/")).CreateChannel ();
proxy.Open ();
try {
Assert.AreEqual ("TEST FOR ECHO", proxy.Echo ("TEST FOR ECHO"), "#1");
@@ -212,8 +215,9 @@ namespace MonoTests.System.ServiceModel.Channels
bindingS.Security.Mode = SecurityMode.None;
bindingS.ReceiveTimeout = TimeSpan.FromSeconds (5);
bindingS.OpenTimeout = TimeSpan.FromSeconds (20);
int port = NetworkHelpers.FindFreePort ();
host.AddServiceEndpoint (typeof (IFoo),
bindingS, new Uri ("net.tcp://localhost:37564"));
bindingS, new Uri ("net.tcp://localhost:" + port));
host.Description.Behaviors.Find<ServiceBehaviorAttribute> ().IncludeExceptionDetailInFaults = true;
host.Open ();
@@ -222,7 +226,7 @@ namespace MonoTests.System.ServiceModel.Channels
var bindingC = new NetTcpBinding ();
bindingS.TransferMode = TransferMode.Streamed;
bindingC.Security.Mode = SecurityMode.None;
IFooChannel proxy = new ChannelFactory<IFooChannel> (bindingC, new EndpointAddress ("net.tcp://localhost:37564/")).CreateChannel ();
IFooChannel proxy = new ChannelFactory<IFooChannel> (bindingC, new EndpointAddress ("net.tcp://localhost:" + port + "/")).CreateChannel ();
proxy.Open ();
try {
Assert.AreEqual ("TEST FOR ECHO", proxy.Echo ("TEST FOR ECHO"), "#1");

View File

@@ -38,17 +38,19 @@ using System.ServiceModel;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.Description
{
[TestFixture]
public class MetadataResolverTest
{
string url = "http://localhost:37564/echo/mex";
string url;
//string url = "http://192.168.0.1:8080/echo/mex";
static HttpListener listener;
IAsyncResult current_request;
int remaining;
int remaining, port;
static readonly string mex = File.ReadAllText ("Test/System.ServiceModel.Description/dump.xml");
@@ -58,7 +60,9 @@ namespace MonoTests.System.ServiceModel.Description
if (listener != null)
listener.Stop ();
listener = new HttpListener ();
listener.Prefixes.Add ("http://*:37564/echo/");
port = NetworkHelpers.FindFreePort ();
url = "http://localhost:" + port + "/echo/mex";
listener.Prefixes.Add ("http://*:" + port + "/echo/");
listener.Start ();
current_request = listener.BeginGetContext (OnReceivedRequest, null);
remaining = 1;

View File

@@ -34,6 +34,8 @@ using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.Description
{
[TestFixture]
@@ -73,7 +75,7 @@ namespace MonoTests.System.ServiceModel.Description
b.ImpersonateCallerForAllOperations = true;
b.PrincipalPermissionMode = PrincipalPermissionMode.None;
host.AddServiceEndpoint (typeof (TestService), new BasicHttpBinding (), new Uri ("http://localhost:37564"));
host.AddServiceEndpoint (typeof (TestService), new BasicHttpBinding (), new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()));
host.Open ();
}
@@ -86,7 +88,7 @@ namespace MonoTests.System.ServiceModel.Description
b.ImpersonateCallerForAllOperations = false;
b.PrincipalPermissionMode = PrincipalPermissionMode.None;
host.AddServiceEndpoint (typeof (TestService2), new BasicHttpBinding (), new Uri ("http://localhost:37564"));
host.AddServiceEndpoint (typeof (TestService2), new BasicHttpBinding (), new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()));
host.Open ();
var ed = ((ChannelDispatcher) host.ChannelDispatchers [0]).Endpoints [0];

View File

@@ -36,6 +36,8 @@ using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.ServiceModel.Channels;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.Description
{
[TestFixture]
@@ -66,7 +68,7 @@ namespace MonoTests.System.ServiceModel.Description
[Test]
public void InitializeRuntime1 () {
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:37564"))) {
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:" + NetworkHelpers.FindFreePort ()))) {
host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "e1");
Assert.AreEqual (0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");
@@ -103,7 +105,7 @@ namespace MonoTests.System.ServiceModel.Description
[Test]
public void InitializeRuntime2 () {
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:37564"))) {
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:" + NetworkHelpers.FindFreePort ()))) {
host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");
host.Description.Behaviors.Remove<ServiceDebugBehavior> ();
@@ -122,7 +124,7 @@ namespace MonoTests.System.ServiceModel.Description
[Test]
public void InitializeRuntime3 () {
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:37564"))) {
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:" + NetworkHelpers.FindFreePort ()))) {
host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");
host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageEnabled = false;
@@ -140,9 +142,10 @@ namespace MonoTests.System.ServiceModel.Description
[Test]
public void InitializeRuntime4 () {
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:37564"))) {
int port = NetworkHelpers.FindFreePort ();
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:" + port))) {
host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");
host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = new Uri ("http://localhost:37564/help");
host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = new Uri ("http://localhost:" + port + "/help");
Assert.AreEqual (0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");
@@ -168,7 +171,7 @@ namespace MonoTests.System.ServiceModel.Description
Assert.AreEqual (0, ed.FilterPriority, "FilterPriority");
EndpointAddress ea = ed.EndpointAddress;
Assert.AreEqual (new Uri ("http://localhost:37564/help"), ea.Uri, "Uri");
Assert.AreEqual (new Uri ("http://localhost:" + port + "/help"), ea.Uri, "Uri");
DispatchRuntime dr = ed.DispatchRuntime;
Assert.AreEqual (1, dr.Operations.Count, "Operations.Count");
@@ -186,9 +189,10 @@ namespace MonoTests.System.ServiceModel.Description
[Test]
public void ServiceMetadataExtension1 () {
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:37564"))) {
int port = NetworkHelpers.FindFreePort ();
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:" + port))) {
host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");
host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = new Uri ("http://localhost:37564/help");
host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = new Uri ("http://localhost:" + port + "/help");
try {
host.Open ();
@@ -202,9 +206,10 @@ namespace MonoTests.System.ServiceModel.Description
[Test]
public void ServiceMetadataExtension2 () {
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:37564"))) {
int port = NetworkHelpers.FindFreePort ();
using (ServiceHost host = new ServiceHost (typeof (MyService), CreateUri ("http://localhost:" + port))) {
host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");
host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = CreateUri ("http://localhost:37564/help");
host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = CreateUri ("http://localhost:" + port + "/help");
ServiceMetadataExtension extension = new ServiceMetadataExtension ();
host.Extensions.Add (extension);

Some files were not shown because too many files have changed in this diff Show More