[WCF]: New WsdlImporter nunit tests and sample wsdl docs.
authorMartin Baulig <martin.baulig@xamarin.com>
Mon, 26 Nov 2012 23:52:06 +0000 (00:52 +0100)
committerMartin Baulig <martin.baulig@xamarin.com>
Mon, 26 Nov 2012 23:56:37 +0000 (00:56 +0100)
This adds a bunch of new nunit tests and sample wsdl docs to
test the import of endpoints and bindings using WsdlImporter.

31 files changed:
mcs/class/System.ServiceModel/Makefile
mcs/class/System.ServiceModel/System.ServiceModel_test.dll.sources
mcs/class/System.ServiceModel/Test/MetadataTests/AssemblyInfo.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/BindingTestAssertions.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/ExportUtil.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/ExportUtil.csproj [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/ImportTests_Misc.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/ImportTests_Tests.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/MetadataSamples.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/MetadataTests.csproj [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/MetadataTests.sln [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/README.txt [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp_MessageSecurity.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp_Mtom.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp_NtlmAuth.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp_TransportSecurity.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp_TransportWithMessageCredential.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttps.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttps_Certificate.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttps_NtlmAuth.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttps_TransportWithMessageCredential.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp_MessageSecurity.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp_ReliableSession.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp_TransferMode.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp_TransportSecurity.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp_TransportWithMessageCredential.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/Resources/http-error.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/TestContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/MetadataTests/TestLabel.cs [new file with mode: 0644]

index 85f8666ad662c6b7bbc8c578ccaf06c163b4abe2..1aaf90fae44cf7210f605f6816acee19aeaa6187 100755 (executable)
@@ -48,7 +48,8 @@ TEST_EXTRA_FILES = \
        Test/XmlFiles/* \
        Test/System.ServiceModel.Channels/soap-fault*.xml \
        Test/System.ServiceModel.Channels/binary-message.raw \
-       Test/System.ServiceModel.Description/dump.xml
+       Test/System.ServiceModel.Description/dump.xml \
+       Test/MetadataTests/Resources/*
 
 EXTRA_DISTFILES = $(RESOURCE_FILES) $(TEST_EXTRA_FILES)
 
index bd6d6c3438e2eb45ec2fb493b55de75a648d6707..48c9e1c6cbf45d9e320131a377602d3809ea61b1 100644 (file)
@@ -200,3 +200,9 @@ System.ServiceModel/TransactionProtocolTest.cs
 System.ServiceModel/UriSchemeKeyedCollectionTest.cs
 System.ServiceModel/WSFederationHttpBindingTest.cs
 System.ServiceModel/WSHttpBindingTest.cs
+MetadataTests/BindingTestAssertions.cs
+MetadataTests/ImportTests_Misc.cs
+MetadataTests/ImportTests_Tests.cs
+MetadataTests/MetadataSamples.cs
+MetadataTests/TestContext.cs
+MetadataTests/TestLabel.cs
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/AssemblyInfo.cs b/mcs/class/System.ServiceModel/Test/MetadataTests/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..6b4eab1
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// AssemblyInfo.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2012 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes. 
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("MetadataTests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Xamarin")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("Xamarin Inc. (http://www.xamarin.com)")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly, 
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/BindingTestAssertions.cs b/mcs/class/System.ServiceModel/Test/MetadataTests/BindingTestAssertions.cs
new file mode 100644 (file)
index 0000000..7c547ae
--- /dev/null
@@ -0,0 +1,585 @@
+//
+// Test.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2012 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Net;
+using System.Net.Security;
+using System.Xml;
+using System.Text;
+using System.Collections.Generic;
+using System.ServiceModel;
+using System.ServiceModel.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using NUnit.Framework;
+using NUnit.Framework.Constraints;
+using NUnit.Framework.SyntaxHelpers;
+
+using WS = System.Web.Services.Description;
+
+namespace MonoTests.System.ServiceModel.MetadataTests {
+
+       public static class BindingTestAssertions {
+
+               const string WspNamespace = "http://schemas.xmlsoap.org/ws/2004/09/policy";
+
+               public static void CheckImportErrors (WsdlImporter importer, TestLabel label)
+               {
+                       bool foundErrors = false;
+                       foreach (var error in importer.Errors) {
+                               if (error.IsWarning)
+                                       Console.WriteLine ("WARNING ({0}): {1}", label, error.Message);
+                               else {
+                                       Console.WriteLine ("ERROR ({0}): {1}", label, error.Message);
+                                       foundErrors = true;
+                               }
+                       }
+
+                       if (foundErrors)
+                               Assert.Fail ("Found import errors", label);
+               }
+
+               static void CheckSoapBinding (object extension, string transport, TestLabel label)
+               {
+                       label.EnterScope ("soap");
+                       Assert.That (extension, Is.InstanceOfType (typeof (WS.SoapBinding)), label.Get ());
+                       var soap = (WS.SoapBinding)extension;
+                       Assert.That (soap.Style, Is.EqualTo (WS.SoapBindingStyle.Document), label.Get ());
+                       Assert.That (soap.Transport, Is.EqualTo (transport), label.Get ());
+                       Assert.That (soap.Required, Is.False, label.Get ());
+                       label.LeaveScope ();
+               }
+
+               public static void CheckBasicHttpBinding (
+                       Binding binding, string scheme, BasicHttpSecurityMode security,
+                       WSMessageEncoding encoding, HttpClientCredentialType clientCred,
+                       AuthenticationSchemes authScheme, TestLabel label)
+               {
+                       label.EnterScope ("http");
+
+                       if (security == BasicHttpSecurityMode.Message) {
+                               Assert.That (binding, Is.InstanceOfType (typeof(CustomBinding)), label.Get ());
+                       } else {
+                               Assert.That (binding, Is.InstanceOfType (typeof(BasicHttpBinding)), label.Get ());
+                               var basicHttp = (BasicHttpBinding)binding;
+                               Assert.That (basicHttp.EnvelopeVersion, Is.EqualTo (EnvelopeVersion.Soap11), label.Get ());
+                               Assert.That (basicHttp.MessageVersion, Is.EqualTo (MessageVersion.Soap11), label.Get ());
+                               Assert.That (basicHttp.Scheme, Is.EqualTo (scheme), label.Get ());
+                               Assert.That (basicHttp.TransferMode, Is.EqualTo (TransferMode.Buffered), label.Get ());
+                               Assert.That (basicHttp.MessageEncoding, Is.EqualTo (encoding), label.Get ());
+                               Assert.That (basicHttp.Security, Is.Not.Null, label.Get ());
+                               Assert.That (basicHttp.Security.Mode, Is.EqualTo (security), label.Get ());
+                               Assert.That (basicHttp.Security.Transport.ClientCredentialType, Is.EqualTo (clientCred), label.Get ());
+                               Assert.That (basicHttp.Security.Message.AlgorithmSuite, Is.EqualTo (SecurityAlgorithmSuite.Basic256), label.Get ());
+                       }
+
+                       label.EnterScope ("elements");
+
+                       var elements = binding.CreateBindingElements ();
+                       Assert.That (elements, Is.Not.Null, label.Get ());
+                       if ((security == BasicHttpSecurityMode.Message) ||
+                               (security == BasicHttpSecurityMode.TransportWithMessageCredential))
+                               Assert.That (elements.Count, Is.EqualTo (3), label.Get ());
+                       else
+                               Assert.That (elements.Count, Is.EqualTo (2), label.Get ());
+                       
+                       TextMessageEncodingBindingElement textElement = null;
+                       TransportSecurityBindingElement securityElement = null;
+                       HttpTransportBindingElement transportElement = null;
+                       AsymmetricSecurityBindingElement asymmSecurityElement = null;
+                       MtomMessageEncodingBindingElement mtomElement = null;
+                       
+                       foreach (var element in elements) {
+                               if (element is TextMessageEncodingBindingElement)
+                                       textElement = (TextMessageEncodingBindingElement)element;
+                               else if (element is HttpTransportBindingElement)
+                                       transportElement = (HttpTransportBindingElement)element;
+                               else if (element is TransportSecurityBindingElement)
+                                       securityElement = (TransportSecurityBindingElement)element;
+                               else if (element is AsymmetricSecurityBindingElement)
+                                       asymmSecurityElement = (AsymmetricSecurityBindingElement)element;
+                               else if (element is MtomMessageEncodingBindingElement)
+                                       mtomElement = (MtomMessageEncodingBindingElement)element;
+                               else
+                                       Assert.Fail (string.Format (
+                                               "Unknown element: {0}", element.GetType ()), label.Get ());
+                       }
+
+                       label.EnterScope ("text");
+                       if (encoding == WSMessageEncoding.Text) {
+                               Assert.That (textElement, Is.Not.Null, label.Get ());
+                               Assert.That (textElement.WriteEncoding, Is.InstanceOfType (typeof(UTF8Encoding)), label.Get ());
+                       } else {
+                               Assert.That (textElement, Is.Null, label.Get ());
+                       }
+                       label.LeaveScope ();
+
+                       label.EnterScope ("mtom");
+                       if (encoding == WSMessageEncoding.Mtom) {
+                               Assert.That (mtomElement, Is.Not.Null, label.Get ());
+                       } else {
+                               Assert.That (mtomElement, Is.Null, label.Get ());
+                       }
+                       label.LeaveScope ();
+
+                       label.EnterScope ("security");
+                       if (security == BasicHttpSecurityMode.TransportWithMessageCredential) {
+                               Assert.That (securityElement, Is.Not.Null, label.Get ());
+                               Assert.That (securityElement.SecurityHeaderLayout,
+                                            Is.EqualTo (SecurityHeaderLayout.Lax), label.Get ());
+                       } else {
+                               Assert.That (securityElement, Is.Null, label.Get ());
+                       }
+                       label.LeaveScope ();
+
+                       label.EnterScope ("asymmetric");
+                       if (security == BasicHttpSecurityMode.Message) {
+                               Assert.That (asymmSecurityElement, Is.Not.Null, label.Get ());
+                       } else {
+                               Assert.That (asymmSecurityElement, Is.Null, label.Get ());
+                       }
+                       label.LeaveScope ();
+
+                       label.EnterScope ("transport");
+                       Assert.That (transportElement, Is.Not.Null, label.Get ());
+                       
+                       Assert.That (transportElement.Realm, Is.Empty, label.Get ());
+                       Assert.That (transportElement.Scheme, Is.EqualTo (scheme), label.Get ());
+                       Assert.That (transportElement.TransferMode, Is.EqualTo (TransferMode.Buffered), label.Get ());
+
+                       label.EnterScope ("auth");
+                       Assert.That (transportElement.AuthenticationScheme, Is.EqualTo (authScheme), label.Get ());
+                       label.LeaveScope (); // auth
+                       label.LeaveScope (); // transport
+                       label.LeaveScope (); // elements
+                       label.LeaveScope (); // http
+               }
+
+               static void CheckEndpoint (ServiceEndpoint endpoint, string uri, TestLabel label)
+               {
+                       label.EnterScope ("endpoint");
+                       Assert.That (endpoint.ListenUri, Is.EqualTo (new Uri (uri)), label.Get ());
+                       Assert.That (endpoint.ListenUriMode, Is.EqualTo (ListenUriMode.Explicit), label.Get ());
+                       Assert.That (endpoint.Contract, Is.Not.Null, label.Get ());
+                       Assert.That (endpoint.Contract.Name, Is.EqualTo ("MyContract"), label.Get ());
+                       Assert.That (endpoint.Address, Is.Not.Null, label.Get ());
+                       Assert.That (endpoint.Address.Uri, Is.EqualTo (new Uri (uri)), label.Get ());
+                       Assert.That (endpoint.Address.Identity, Is.Null, label.Get ());
+                       Assert.That (endpoint.Address.Headers, Is.Not.Null, label.Get ());
+                       Assert.That (endpoint.Address.Headers.Count, Is.EqualTo (0), label.Get ());
+                       label.LeaveScope ();
+               }
+
+               public static void BasicHttpBinding (
+                       MetadataSet doc, WSMessageEncoding encoding, TestLabel label)
+               {
+                       BasicHttpBinding (
+                               doc, BasicHttpSecurityMode.None, encoding,
+                               HttpClientCredentialType.None, AuthenticationSchemes.Anonymous,
+                               label);
+               }
+
+               public static void BasicHttpBinding (
+                       MetadataSet doc, BasicHttpSecurityMode security, TestLabel label)
+               {
+                       BasicHttpBinding (
+                               doc, security, WSMessageEncoding.Text,
+                               HttpClientCredentialType.None, AuthenticationSchemes.Anonymous,
+                               label);
+               }
+               
+               public static void BasicHttpBinding (
+                       MetadataSet doc, BasicHttpSecurityMode security, WSMessageEncoding encoding,
+                       HttpClientCredentialType clientCred, AuthenticationSchemes authScheme,
+                       TestLabel label)
+               {
+                       label.EnterScope ("basicHttpBinding");
+
+                       var sd = (WS.ServiceDescription)doc.MetadataSections [0].Metadata;
+
+                       label.EnterScope ("wsdl");
+                       label.EnterScope ("bindings");
+                       Assert.That (sd.Bindings.Count, Is.EqualTo (1), label.Get ());
+
+                       var binding = sd.Bindings [0];
+                       Assert.That (binding.ExtensibleAttributes, Is.Null, label.Get ());
+                       Assert.That (binding.Extensions, Is.Not.Null, label.Get ());
+
+                       switch (security) {
+                       case BasicHttpSecurityMode.None:
+                               if (encoding == WSMessageEncoding.Mtom)
+                                       Assert.That (binding.Extensions.Count, Is.EqualTo (2), label.Get ());
+                               else
+                                       Assert.That (binding.Extensions.Count, Is.EqualTo (1), label.Get ());
+                               break;
+                       case BasicHttpSecurityMode.Message:
+                       case BasicHttpSecurityMode.Transport:
+                       case BasicHttpSecurityMode.TransportWithMessageCredential:
+                               if (encoding == WSMessageEncoding.Mtom)
+                                       throw new InvalidOperationException ();
+                               Assert.That (binding.Extensions.Count, Is.EqualTo (2), label.Get ());
+                               break;
+                       case BasicHttpSecurityMode.TransportCredentialOnly:
+                               Assert.That (binding.Extensions.Count, Is.EqualTo (2), label.Get ());
+                               break;
+                       default:
+                               throw new InvalidOperationException ();
+                       }
+                       label.LeaveScope ();
+
+                       WS.SoapBinding soap = null;
+                       XmlElement xml = null;
+
+                       foreach (var ext in binding.Extensions) {
+                               if (ext is WS.SoapBinding)
+                                       soap = (WS.SoapBinding)ext;
+                               else if (ext is XmlElement)
+                                       xml = (XmlElement)ext;
+                       }
+
+                       CheckSoapBinding (soap, WS.SoapBinding.HttpTransport, label);
+                       label.LeaveScope ();
+
+                       if (security != BasicHttpSecurityMode.None) {
+                               label.EnterScope ("policy-xml");
+                               
+                               Assert.That (xml, Is.Not.Null, label.Get ());
+                               
+                               Assert.That (xml.NamespaceURI, Is.EqualTo (WspNamespace), label.Get ());
+                               Assert.That (xml.LocalName, Is.EqualTo ("PolicyReference"), label.Get ());
+                               
+                               label.LeaveScope ();
+                       }
+
+                       var importer = new WsdlImporter (doc);
+
+                       label.EnterScope ("bindings");
+                       var bindings = importer.ImportAllBindings ();
+                       CheckImportErrors (importer, label);
+
+                       Assert.That (bindings, Is.Not.Null, label.Get ());
+                       Assert.That (bindings.Count, Is.EqualTo (1), label.Get ());
+
+                       string scheme;
+                       if ((security == BasicHttpSecurityMode.Transport) ||
+                           (security == BasicHttpSecurityMode.TransportWithMessageCredential))
+                               scheme = "https";
+                       else
+                               scheme = "http";
+
+                       CheckBasicHttpBinding (
+                               bindings [0], scheme, security, encoding, clientCred,
+                               authScheme, label);
+                       label.LeaveScope ();
+
+                       label.EnterScope ("endpoints");
+                       var endpoints = importer.ImportAllEndpoints ();
+                       CheckImportErrors (importer, label);
+
+                       Assert.That (endpoints, Is.Not.Null, label.Get ());
+                       Assert.That (endpoints.Count, Is.EqualTo (1), label.Get ());
+
+                       CheckEndpoint (endpoints [0], MetadataSamples.HttpUri, label);
+                       label.LeaveScope ();
+
+                       label.LeaveScope ();
+               }
+
+               public static void BasicHttpsBinding (
+                       MetadataSet doc, BasicHttpSecurityMode security, WSMessageEncoding encoding,
+                       HttpClientCredentialType clientCred, AuthenticationSchemes authScheme,
+                       TestLabel label)
+               {
+                       label.EnterScope ("basicHttpsBinding");
+
+                       var sd = (WS.ServiceDescription)doc.MetadataSections [0].Metadata;
+
+                       label.EnterScope ("wsdl");
+
+                       Assert.That (sd.Extensions, Is.Not.Null, label.Get ());
+                       Assert.That (sd.Extensions.Count, Is.EqualTo (1), label.Get ());
+                       Assert.That (sd.Extensions [0], Is.InstanceOfType (typeof (XmlElement)), label.Get ());
+
+                       label.EnterScope ("extensions");
+                       var extension = (XmlElement)sd.Extensions [0];
+                       Assert.That (extension.NamespaceURI, Is.EqualTo (WspNamespace), label.Get ());
+                       Assert.That (extension.LocalName, Is.EqualTo ("Policy"), label.Get ());
+                       label.LeaveScope ();
+
+                       label.EnterScope ("bindings");
+                       Assert.That (sd.Bindings.Count, Is.EqualTo (1), label.Get ());
+                       var binding = sd.Bindings [0];
+                       Assert.That (binding.ExtensibleAttributes, Is.Null, label.Get ());
+                       Assert.That (binding.Extensions, Is.Not.Null, label.Get ());
+                       Assert.That (binding.Extensions.Count, Is.EqualTo (2), label.Get ());
+                       label.LeaveScope ();
+
+                       WS.SoapBinding soap = null;
+                       XmlElement xml = null;
+
+                       foreach (var ext in binding.Extensions) {
+                               if (ext is WS.SoapBinding)
+                                       soap = (WS.SoapBinding)ext;
+                               else if (ext is XmlElement)
+                                       xml = (XmlElement)ext;
+                       }
+
+                       CheckSoapBinding (soap, WS.SoapBinding.HttpTransport, label);
+
+                       label.EnterScope ("policy-xml");
+
+                       Assert.That (xml, Is.Not.Null, label.Get ());
+                       
+                       Assert.That (xml.NamespaceURI, Is.EqualTo (WspNamespace), label.Get ());
+                       Assert.That (xml.LocalName, Is.EqualTo ("PolicyReference"), label.Get ());
+
+                       label.LeaveScope ();
+                       label.LeaveScope (); // wsdl
+
+                       var importer = new WsdlImporter (doc);
+
+                       label.EnterScope ("bindings");
+                       var bindings = importer.ImportAllBindings ();
+                       CheckImportErrors (importer, label);
+                       Assert.That (bindings, Is.Not.Null, label.Get ());
+                       Assert.That (bindings.Count, Is.EqualTo (1), label.Get ());
+
+                       CheckBasicHttpBinding (
+                               bindings [0], "https", security, encoding,
+                               clientCred, authScheme, label);
+                       label.LeaveScope ();
+
+                       label.EnterScope ("endpoints");
+                       var endpoints = importer.ImportAllEndpoints ();
+                       CheckImportErrors (importer, label);
+                       Assert.That (endpoints, Is.Not.Null, label.Get ());
+                       Assert.That (endpoints.Count, Is.EqualTo (1), label.Get ());
+                       
+                       CheckEndpoint (endpoints [0], MetadataSamples.HttpsUri, label);
+                       label.LeaveScope ();
+
+                       label.LeaveScope ();
+               }
+
+               public static void CheckNetTcpBinding (
+                       Binding binding, SecurityMode security, bool reliableSession,
+                       TransferMode transferMode, TestLabel label)
+               {
+                       label.EnterScope ("net-tcp");
+                       if (security == SecurityMode.Message) {
+                               Assert.That (binding, Is.InstanceOfType (typeof(CustomBinding)), label.Get ());
+                       } else {
+                               Assert.That (binding, Is.InstanceOfType (typeof(NetTcpBinding)), label.Get ());
+                               var netTcp = (NetTcpBinding)binding;
+                               Assert.That (netTcp.EnvelopeVersion, Is.EqualTo (EnvelopeVersion.Soap12), label.Get ());
+                               Assert.That (netTcp.MessageVersion, Is.EqualTo (MessageVersion.Soap12WSAddressing10), label.Get ());
+                               Assert.That (netTcp.Scheme, Is.EqualTo ("net.tcp"), label.Get ());
+                               Assert.That (netTcp.TransferMode, Is.EqualTo (transferMode), label.Get ());
+
+                               label.EnterScope ("security");
+                               Assert.That (netTcp.Security, Is.Not.Null, label.Get ());
+                               Assert.That (netTcp.Security.Mode, Is.EqualTo (security), label.Get ());
+
+                               Assert.That (netTcp.Security.Transport, Is.Not.Null, label.Get ());
+                               Assert.That (netTcp.Security.Transport.ProtectionLevel, Is.EqualTo (ProtectionLevel.EncryptAndSign), label.Get ());
+                               Assert.That (netTcp.Security.Transport.ClientCredentialType, Is.EqualTo (TcpClientCredentialType.Windows), label.Get ());
+                               label.LeaveScope ();
+                       }
+
+                       label.EnterScope ("elements");
+                       
+                       var elements = binding.CreateBindingElements ();
+                       Assert.That (elements, Is.Not.Null, label.Get ());
+
+                       TcpTransportBindingElement transportElement = null;
+                       TransactionFlowBindingElement transactionFlowElement = null;
+                       BinaryMessageEncodingBindingElement encodingElement = null;
+                       WindowsStreamSecurityBindingElement windowsStreamElement = null;
+                       ReliableSessionBindingElement reliableSessionElement = null;
+                       TransportSecurityBindingElement transportSecurityElement = null;
+                       SslStreamSecurityBindingElement sslStreamElement = null;
+                       SymmetricSecurityBindingElement symmSecurityElement = null;
+                       
+                       foreach (var element in elements) {
+                               if (element is TcpTransportBindingElement)
+                                       transportElement = (TcpTransportBindingElement)element;
+                               else if (element is TransactionFlowBindingElement)
+                                       transactionFlowElement = (TransactionFlowBindingElement)element;
+                               else if (element is BinaryMessageEncodingBindingElement)
+                                       encodingElement = (BinaryMessageEncodingBindingElement)element;
+                               else if (element is WindowsStreamSecurityBindingElement)
+                                       windowsStreamElement = (WindowsStreamSecurityBindingElement)element;
+                               else if (element is ReliableSessionBindingElement)
+                                       reliableSessionElement = (ReliableSessionBindingElement)element;
+                               else if (element is TransportSecurityBindingElement)
+                                       transportSecurityElement = (TransportSecurityBindingElement)element;
+                               else if (element is SslStreamSecurityBindingElement)
+                                       sslStreamElement = (SslStreamSecurityBindingElement)element;
+                               else if (element is SymmetricSecurityBindingElement)
+                                       symmSecurityElement = (SymmetricSecurityBindingElement)element;
+                               else
+                                       Assert.Fail (string.Format (
+                                               "Unknown element `{0}'.", element.GetType ()), label.Get ());
+                       }
+
+                       label.EnterScope ("windows-stream");
+                       if (security == SecurityMode.Transport) {
+                               Assert.That (windowsStreamElement, Is.Not.Null, label.Get ());
+                               Assert.That (windowsStreamElement.ProtectionLevel, Is.EqualTo (ProtectionLevel.EncryptAndSign), label.Get ());
+                       } else {
+                               Assert.That (windowsStreamElement, Is.Null, label.Get ());
+                       }
+                       label.LeaveScope ();
+
+                       label.EnterScope ("reliable-session");
+                       if (reliableSession) {
+                               Assert.That (reliableSessionElement, Is.Not.Null, label.Get ());
+                       } else {
+                               Assert.That (reliableSessionElement, Is.Null, label.Get ());
+                       }
+                       label.LeaveScope ();
+
+                       label.EnterScope ("encoding");
+                       Assert.That (encodingElement, Is.Not.Null, label.Get ());
+                       label.LeaveScope ();
+
+                       label.EnterScope ("transaction");
+                       if (security == SecurityMode.Message) {
+                               Assert.That (transactionFlowElement, Is.Null, label.Get ());
+                       } else {
+                               Assert.That (transactionFlowElement, Is.Not.Null, label.Get ());
+                       }
+                       label.LeaveScope ();
+
+                       label.EnterScope ("transport");
+                       Assert.That (transportElement, Is.Not.Null, label.Get ());
+
+                       Assert.That (transportElement.Scheme, Is.EqualTo ("net.tcp"), label.Get ());
+                       Assert.That (transportElement.TransferMode, Is.EqualTo (transferMode), label.Get ());
+                       label.LeaveScope (); // transport
+
+                       label.EnterScope ("security");
+                       switch (security) {
+                       case SecurityMode.None:
+                       case SecurityMode.Transport:
+                               Assert.That (transportSecurityElement, Is.Null, label.Get ());
+                               Assert.That (sslStreamElement, Is.Null, label.Get ());
+                               Assert.That (symmSecurityElement, Is.Null, label.Get ());
+                               break;
+                       case SecurityMode.TransportWithMessageCredential:
+                               Assert.That (transportSecurityElement, Is.Not.Null, label.Get ());
+                               Assert.That (sslStreamElement, Is.Not.Null, label.Get ());
+                               Assert.That (symmSecurityElement, Is.Null, label.Get ());
+                               break;
+                       case SecurityMode.Message:
+                               Assert.That (transportSecurityElement, Is.Null, label.Get ());
+                               Assert.That (sslStreamElement, Is.Null, label.Get ());
+                               Assert.That (symmSecurityElement, Is.Not.Null, label.Get ());
+                               break;
+                       default:
+                               throw new InvalidOperationException ();
+                       }
+                       label.LeaveScope ();
+
+                       label.LeaveScope (); // elements
+                       label.LeaveScope (); // net-tcp
+               }
+
+               public static void NetTcpBinding (
+                       MetadataSet doc, SecurityMode security, bool reliableSession,
+                       TransferMode transferMode, TestLabel label)
+               {
+                       label.EnterScope ("netTcpBinding");
+
+                       var sd = (WS.ServiceDescription)doc.MetadataSections [0].Metadata;
+
+                       label.EnterScope ("wsdl");
+
+                       label.EnterScope ("extensions");
+                       Assert.That (sd.Extensions, Is.Not.Null, label.Get ());
+                       Assert.That (sd.Extensions.Count, Is.EqualTo (1), label.Get ());
+                       Assert.That (sd.Extensions [0], Is.InstanceOfType (typeof(XmlElement)), label.Get ());
+                       
+                       var extension = (XmlElement)sd.Extensions [0];
+                       Assert.That (extension.NamespaceURI, Is.EqualTo (WspNamespace), label.Get ());
+                       Assert.That (extension.LocalName, Is.EqualTo ("Policy"), label.Get ());
+                       label.LeaveScope ();
+
+                       label.EnterScope ("bindings");
+                       Assert.That (sd.Bindings.Count, Is.EqualTo (1), label.Get ());
+                       var binding = sd.Bindings [0];
+                       Assert.That (binding.ExtensibleAttributes, Is.Null, label.Get ());
+                       Assert.That (binding.Extensions, Is.Not.Null, label.Get ());
+                       Assert.That (binding.Extensions.Count, Is.EqualTo (2), label.Get ());
+
+                       WS.SoapBinding soap = null;
+                       XmlElement xml = null;
+                       
+                       foreach (var ext in binding.Extensions) {
+                               if (ext is WS.SoapBinding)
+                                       soap = (WS.SoapBinding)ext;
+                               else if (ext is XmlElement)
+                                       xml = (XmlElement)ext;
+                       }
+                       
+                       CheckSoapBinding (soap, "http://schemas.microsoft.com/soap/tcp", label);
+
+                       label.EnterScope ("policy-xml");
+                       Assert.That (xml, Is.Not.Null, label.Get ());
+                       
+                       Assert.That (xml.NamespaceURI, Is.EqualTo (WspNamespace), label.Get ());
+                       Assert.That (xml.LocalName, Is.EqualTo ("PolicyReference"), label.Get ());
+                       label.LeaveScope ();
+
+                       label.LeaveScope (); // wsdl
+
+                       var importer = new WsdlImporter (doc);
+
+                       label.EnterScope ("bindings");
+                       var bindings = importer.ImportAllBindings ();
+                       CheckImportErrors (importer, label);
+                       Assert.That (bindings, Is.Not.Null, label.Get ());
+                       Assert.That (bindings.Count, Is.EqualTo (1), label.Get ());
+                       
+                       CheckNetTcpBinding (
+                               bindings [0], security, reliableSession,
+                               transferMode, label);
+                       label.LeaveScope ();
+
+                       label.EnterScope ("endpoints");
+                       var endpoints = importer.ImportAllEndpoints ();
+                       CheckImportErrors (importer, label);
+                       Assert.That (endpoints, Is.Not.Null, label.Get ());
+                       Assert.That (endpoints.Count, Is.EqualTo (1), label.Get ());
+                       
+                       CheckEndpoint (endpoints [0], MetadataSamples.NetTcpUri, label);
+                       label.LeaveScope ();
+
+                       label.LeaveScope ();
+               }
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/ExportUtil.cs b/mcs/class/System.ServiceModel/Test/MetadataTests/ExportUtil.cs
new file mode 100644 (file)
index 0000000..c113808
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// Main.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2012 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+
+namespace MonoTests.System.ServiceModel.MetadataTests {
+
+       public static class ExportUtil {
+               public static void Main (string[] args)
+               {
+                       MetadataSamples.Export ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/ExportUtil.csproj b/mcs/class/System.ServiceModel/Test/MetadataTests/ExportUtil.csproj
new file mode 100644 (file)
index 0000000..4b304af
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>10.0.0</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{D4C1B0BD-3488-441C-92B9-7E017041E137}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>ExportUtil</RootNamespace>
+    <AssemblyName>ExportUtil</AssemblyName>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>True</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>False</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG;</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <Externalconsole>True</Externalconsole>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>True</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <Externalconsole>True</Externalconsole>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.ServiceModel" />
+    <Reference Include="System.Xml" />
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.Web.Services" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AssemblyInfo.cs" />
+    <Compile Include="ExportUtil.cs" />
+    <Compile Include="MetadataSamples.cs" />
+    <Compile Include="TestContext.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/ImportTests_Misc.cs b/mcs/class/System.ServiceModel/Test/MetadataTests/ImportTests_Misc.cs
new file mode 100644 (file)
index 0000000..7ce6e53
--- /dev/null
@@ -0,0 +1,281 @@
+//
+// Test_Misc.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2012 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Net;
+using System.Xml;
+using System.Text;
+using System.Collections.Generic;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using NUnit.Framework;
+using NUnit.Framework.Constraints;
+using NUnit.Framework.SyntaxHelpers;
+
+using WS = System.Web.Services.Description;
+
+namespace MonoTests.System.ServiceModel.MetadataTests {
+
+       public partial class ImportTests {
+
+               [Test]
+               public void BasicHttpBinding_ImportBinding ()
+               {
+                       var label = new TestLabel ("BasicHttpBinding_ImportBinding");
+                       
+                       var doc = TestContext.GetMetadata ("BasicHttp");
+                       var sd = (WS.ServiceDescription)doc.MetadataSections [0].Metadata;
+                       var wsdlBinding = sd.Bindings [0];
+                       
+                       var importer = new WsdlImporter (doc);
+                       
+                       Assert.That (sd.Bindings, Is.Not.Null, label.Get ());
+                       Assert.That (sd.Bindings.Count, Is.EqualTo (1), label.Get ());
+                       
+                       var binding = importer.ImportBinding (wsdlBinding);
+                       BindingTestAssertions.CheckImportErrors (importer, label);
+                       Assert.That (binding, Is.Not.Null, label.Get ());
+               }
+               
+               [Test]
+               public void BasicHttpBinding_ImportEndpoint ()
+               {
+                       var label = new TestLabel ("BasicHttpBinding_ImportEndpoint");
+                       
+                       var doc = TestContext.GetMetadata ("BasicHttp");
+                       var sd = (WS.ServiceDescription)doc.MetadataSections [0].Metadata;
+                       
+                       label.EnterScope ("wsdl");
+                       Assert.That (sd.Services, Is.Not.Null, label.Get ());
+                       Assert.That (sd.Services.Count, Is.EqualTo (1), label.Get ());
+                       
+                       var service = sd.Services [0];
+                       Assert.That (service.Ports, Is.Not.Null, label.Get ());
+                       Assert.That (service.Ports.Count, Is.EqualTo (1), label.Get ());
+                       label.LeaveScope ();
+                       
+                       var importer = new WsdlImporter (doc);
+                       
+                       var port = importer.ImportEndpoint (service.Ports [0]);
+                       BindingTestAssertions.CheckImportErrors (importer, label);
+                       Assert.That (port, Is.Not.Null, label.Get ());
+               }
+               
+               [Test]
+               public void BasicHttpBinding_Error ()
+               {
+                       var label = new TestLabel ("BasicHttpBinding_Error");
+                       
+                       var doc = TestContext.GetMetadata ("http-error.xml");
+                       var sd = (WS.ServiceDescription)doc.MetadataSections [0].Metadata;
+                       var wsdlBinding = sd.Bindings [0];
+                       
+                       var importer = new WsdlImporter (doc);
+                       
+                       label.EnterScope ("all");
+                       
+                       var bindings = importer.ImportAllBindings ();
+                       Assert.That (bindings, Is.Not.Null, label.Get ());
+                       Assert.That (bindings.Count, Is.EqualTo (0), label.Get ());
+                       
+                       label.EnterScope ("errors");
+                       Assert.That (importer.Errors, Is.Not.Null, label.Get ());
+                       Assert.That (importer.Errors.Count, Is.EqualTo (1), label.Get ());
+                       
+                       var error = importer.Errors [0];
+                       Assert.That (error.IsWarning, Is.False, label.Get ());
+                       label.LeaveScope ();
+                       label.LeaveScope ();
+                       
+                       label.EnterScope ("single");
+                       
+                       try {
+                               importer.ImportBinding (wsdlBinding);
+                               Assert.Fail (label.Get ());
+                       } catch {
+                               ;
+                       }
+                       
+                       Assert.That (importer.Errors.Count, Is.EqualTo (1), label.Get ());
+                       
+                       label.LeaveScope ();
+                       
+                       label.EnterScope ("single-first");
+                       
+                       var importer2 = new WsdlImporter (doc);
+                       
+                       try {
+                               importer2.ImportBinding (wsdlBinding);
+                               Assert.Fail (label.Get ());
+                       } catch {
+                               ;
+                       }
+                       
+                       Assert.That (importer2.Errors.Count, Is.EqualTo (1), label.Get ());
+                       
+                       try {
+                               importer2.ImportBinding (wsdlBinding);
+                               Assert.Fail (label.Get ());
+                       } catch {
+                               ;
+                       }
+                       
+                       var bindings2 = importer.ImportAllBindings ();
+                       Assert.That (bindings2, Is.Not.Null, label.Get ());
+                       Assert.That (bindings2.Count, Is.EqualTo (0), label.Get ());
+                       
+                       label.LeaveScope ();
+               }
+               
+               [Test]
+               public void BasicHttpBinding_Error2 ()
+               {
+                       var label = new TestLabel ("BasicHttpBinding_Error2");
+                       
+                       var doc = TestContext.GetMetadata ("http-error.xml");
+                       var sd = (WS.ServiceDescription)doc.MetadataSections [0].Metadata;
+                       
+                       label.EnterScope ("wsdl");
+                       Assert.That (sd.Services, Is.Not.Null, label.Get ());
+                       Assert.That (sd.Services.Count, Is.EqualTo (1), label.Get ());
+                       
+                       var service = sd.Services [0];
+                       Assert.That (service.Ports, Is.Not.Null, label.Get ());
+                       Assert.That (service.Ports.Count, Is.EqualTo (1), label.Get ());
+                       label.LeaveScope ();
+                       
+                       var importer = new WsdlImporter (doc);
+                       
+                       label.EnterScope ("all");
+                       
+                       var endpoints = importer.ImportAllEndpoints ();
+                       Assert.That (endpoints, Is.Not.Null, label.Get ());
+                       Assert.That (endpoints.Count, Is.EqualTo (0), label.Get ());
+                       
+                       label.EnterScope ("errors");
+                       Assert.That (importer.Errors, Is.Not.Null, label.Get ());
+                       Assert.That (importer.Errors.Count, Is.EqualTo (2), label.Get ());
+                       
+                       Assert.That (importer.Errors [0].IsWarning, Is.False, label.Get ());
+                       Assert.That (importer.Errors [1].IsWarning, Is.False, label.Get ());
+                       label.LeaveScope ();
+                       label.LeaveScope ();
+                       
+                       label.EnterScope ("single");
+                       
+                       try {
+                               importer.ImportEndpoint (service.Ports [0]);
+                               Assert.Fail (label.Get ());
+                       } catch {
+                               ;
+                       }
+                       
+                       Assert.That (importer.Errors.Count, Is.EqualTo (2), label.Get ());
+                       
+                       label.LeaveScope ();
+                       
+                       label.EnterScope ("single-first");
+                       
+                       var importer2 = new WsdlImporter (doc);
+                       
+                       try {
+                               importer2.ImportEndpoint (service.Ports [0]);
+                               Assert.Fail (label.Get ());
+                       } catch {
+                               ;
+                       }
+                       
+                       Assert.That (importer2.Errors.Count, Is.EqualTo (2), label.Get ());
+                       
+                       try {
+                               importer2.ImportEndpoint (service.Ports [0]);
+                               Assert.Fail (label.Get ());
+                       } catch {
+                               ;
+                       }
+                       
+                       var endpoints2 = importer.ImportAllEndpoints ();
+                       Assert.That (endpoints2, Is.Not.Null, label.Get ());
+                       Assert.That (endpoints2.Count, Is.EqualTo (0), label.Get ());
+                       
+                       label.LeaveScope ();
+               }
+               
+               [Test]
+               public void BasicHttpBinding_ImportEndpoints ()
+               {
+                       var label = new TestLabel ("BasicHttpBinding_ImportEndpoints");
+                       
+                       var doc = TestContext.GetMetadata ("BasicHttp");
+                       var sd = (WS.ServiceDescription)doc.MetadataSections [0].Metadata;
+                       
+                       label.EnterScope ("wsdl");
+                       Assert.That (sd.Bindings, Is.Not.Null, label.Get ());
+                       Assert.That (sd.Bindings.Count, Is.EqualTo (1), label.Get ());
+                       var binding = sd.Bindings [0];
+                       
+                       Assert.That (sd.Services, Is.Not.Null, label.Get ());
+                       Assert.That (sd.Services.Count, Is.EqualTo (1), label.Get ());
+                       var service = sd.Services [0];
+                       
+                       Assert.That (service.Ports, Is.Not.Null, label.Get ());
+                       Assert.That (service.Ports.Count, Is.EqualTo (1), label.Get ());
+                       var port = service.Ports [0];
+                       
+                       Assert.That (sd.PortTypes, Is.Not.Null, label.Get ());
+                       Assert.That (sd.PortTypes.Count, Is.EqualTo (1), label.Get ());
+                       var portType = sd.PortTypes [0];
+                       
+                       label.LeaveScope ();
+                       
+                       var importer = new WsdlImporter (doc);
+                       
+                       label.EnterScope ("by-service");
+                       var byService = importer.ImportEndpoints (service);
+                       BindingTestAssertions.CheckImportErrors (importer, label);
+                       Assert.That (byService, Is.Not.Null, label.Get ());
+                       Assert.That (byService.Count, Is.EqualTo (1), label.Get ());
+                       label.LeaveScope ();
+                       
+                       label.EnterScope ("by-binding");
+                       var byBinding = importer.ImportEndpoints (binding);
+                       BindingTestAssertions.CheckImportErrors (importer, label);
+                       Assert.That (byBinding, Is.Not.Null, label.Get ());
+                       Assert.That (byBinding.Count, Is.EqualTo (1), label.Get ());
+                       label.LeaveScope ();
+                       
+                       label.EnterScope ("by-port-type");
+                       var byPortType = importer.ImportEndpoints (portType);
+                       BindingTestAssertions.CheckImportErrors (importer, label);
+                       Assert.That (byPortType, Is.Not.Null, label.Get ());
+                       Assert.That (byPortType.Count, Is.EqualTo (1), label.Get ());
+                       label.LeaveScope ();
+               }
+
+       }
+}
+
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/ImportTests_Tests.cs b/mcs/class/System.ServiceModel/Test/MetadataTests/ImportTests_Tests.cs
new file mode 100644 (file)
index 0000000..11a60b8
--- /dev/null
@@ -0,0 +1,257 @@
+//
+// Testcases.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2012 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Net;
+using System.Xml;
+using System.Text;
+using System.Collections.Generic;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using NUnit.Framework;
+using NUnit.Framework.Constraints;
+using NUnit.Framework.SyntaxHelpers;
+
+using WS = System.Web.Services.Description;
+
+namespace MonoTests.System.ServiceModel.MetadataTests {
+
+       [TestFixture]
+       [Category ("NotWorking")]
+       [Category ("MetadataTests")]
+       public partial class ImportTests {
+
+               [Test]
+               public void BasicHttp ()
+               {
+                       var doc = TestContext.GetMetadata ("BasicHttp");
+                       var label = new TestLabel ("BasicHttp");
+
+                       BindingTestAssertions.BasicHttpBinding (doc, BasicHttpSecurityMode.None, label);
+               }
+               
+               [Test]
+               public void BasicHttp_TransportSecurity ()
+               {
+                       var doc = TestContext.GetMetadata ("BasicHttp_TransportSecurity");
+                       var label = new TestLabel ("BasicHttp_TransportSecurity");
+
+                       BindingTestAssertions.BasicHttpBinding (doc, BasicHttpSecurityMode.Transport, label);
+               }
+               
+               [Test]
+               [Category ("NotWorking")]
+               public void BasicHttp_MessageSecurity ()
+               {
+                       var doc = TestContext.GetMetadata ("BasicHttp_MessageSecurity");
+                       var label = new TestLabel ("BasicHttp_MessageSecurity");
+
+                       BindingTestAssertions.BasicHttpBinding (doc, BasicHttpSecurityMode.Message, label);
+               }
+               
+               [Test]
+               [Category ("NotWorking")]
+               public void BasicHttp_TransportWithMessageCredential ()
+               {
+                       var doc = TestContext.GetMetadata ("BasicHttp_TransportWithMessageCredential");
+                       var label = new TestLabel ("BasicHttp_TransportWithMessageCredential");
+
+                       BindingTestAssertions.BasicHttpBinding (
+                               doc, BasicHttpSecurityMode.TransportWithMessageCredential, label);
+               }
+               
+               [Test]
+               public void BasicHttp_Mtom ()
+               {
+                       var doc = TestContext.GetMetadata ("BasicHttp_Mtom");
+                       var label = new TestLabel ("BasicHttp_Mtom");
+
+                       BindingTestAssertions.BasicHttpBinding (
+                               doc, WSMessageEncoding.Mtom, label);
+               }
+
+               [Test]
+               public void BasicHttp_NtlmAuth ()
+               {
+                       var doc = TestContext.GetMetadata ("BasicHttp_NtlmAuth");
+                       var label = new TestLabel ("BasicHttp_NtlmAuth");
+                       
+                       BindingTestAssertions.BasicHttpBinding (
+                               doc, BasicHttpSecurityMode.TransportCredentialOnly, WSMessageEncoding.Text,
+                               HttpClientCredentialType.Ntlm, AuthenticationSchemes.Ntlm,
+                               label);
+               }
+
+               [Test]
+               public void BasicHttps ()
+               {
+                       var doc = TestContext.GetMetadata ("BasicHttps");
+                       var label = new TestLabel ("BasicHttps");
+
+                       BindingTestAssertions.BasicHttpsBinding (
+                               doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
+                               HttpClientCredentialType.None, AuthenticationSchemes.Anonymous,
+                               label);
+               }
+               
+               [Test]
+               public void BasicHttps_NtlmAuth ()
+               {
+                       var doc = TestContext.GetMetadata ("BasicHttps_NtlmAuth");
+                       var label = new TestLabel ("BasicHttps_NtlmAuth");
+
+                       BindingTestAssertions.BasicHttpsBinding (
+                               doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
+                               HttpClientCredentialType.Ntlm, AuthenticationSchemes.Ntlm,
+                               label);
+               }
+               
+               [Test]
+               [Category ("NotWorking")]
+               public void BasicHttps_Certificate ()
+               {
+                       var doc = TestContext.GetMetadata ("BasicHttps_Certificate");
+                       var label = new TestLabel ("BasicHttps_Certificate");
+
+                       BindingTestAssertions.BasicHttpsBinding (
+                               doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
+                               HttpClientCredentialType.Certificate, AuthenticationSchemes.Anonymous,
+                               label);
+               }
+               
+               [Test]
+               [Category ("NotWorking")]
+               public void BasicHttps_TransportWithMessageCredential ()
+               {
+                       var doc = TestContext.GetMetadata ("BasicHttps_TransportWithMessageCredential");
+                       var label = new TestLabel ("BasicHttps_TransportWithMessageCredential");
+
+                       BindingTestAssertions.BasicHttpsBinding (
+                               doc, BasicHttpSecurityMode.TransportWithMessageCredential,
+                               WSMessageEncoding.Text, HttpClientCredentialType.None,
+                               AuthenticationSchemes.Anonymous, label);
+               }
+               
+               [Test]
+               public void NetTcp ()
+               {
+                       var doc = TestContext.GetMetadata ("NetTcp");
+                       var label = new TestLabel ("NetTcp");
+                       BindingTestAssertions.NetTcpBinding (
+                               doc, SecurityMode.None, false, TransferMode.Buffered, label);
+               }
+
+               [Test]
+               public void NetTcp_TransferMode ()
+               {
+                       var doc = TestContext.GetMetadata ("NetTcp_TransferMode");
+
+                       var label = new TestLabel ("NetTcp_TransferMode");
+                       BindingTestAssertions.NetTcpBinding (
+                               doc, SecurityMode.None, false,
+                               TransferMode.Streamed, label);
+               }
+
+               [Test]
+               public void NetTcp_TransportSecurity ()
+               {
+                       var doc = TestContext.GetMetadata ("NetTcp_TransportSecurity");
+                       var label = new TestLabel ("NetTcp_TransportSecurity");
+                       BindingTestAssertions.NetTcpBinding (
+                               doc, SecurityMode.Transport, false,
+                               TransferMode.Buffered, label);
+               }
+               
+               [Test]
+               [Category ("NotWorking")]
+               public void NetTcp_MessageSecurity ()
+               {
+                       var doc = TestContext.GetMetadata ("NetTcp_MessageSecurity");
+                       var label = new TestLabel ("NetTcp_MessageSecurity");
+                       BindingTestAssertions.NetTcpBinding (
+                               doc, SecurityMode.Message, false,
+                               TransferMode.Buffered, label);
+               }
+               
+               [Test]
+               [Category ("NotWorking")]
+               public void NetTcp_TransportWithMessageCredential ()
+               {
+                       var doc = TestContext.GetMetadata ("NetTcp_TransportWithMessageCredential");
+                       var label = new TestLabel ("NetTcp_TransportWithMessageCredential");
+
+                       BindingTestAssertions.NetTcpBinding (
+                               doc, SecurityMode.TransportWithMessageCredential, false,
+                               TransferMode.Buffered, label);
+               }
+
+               [Test]
+               public void NetTcp_Binding ()
+               {
+                       var label = new TestLabel ("NetTcp_Binding");
+
+                       label.EnterScope ("None");
+                       BindingTestAssertions.CheckNetTcpBinding (
+                               new NetTcpBinding (SecurityMode.None), SecurityMode.None,
+                               false, TransferMode.Buffered, label);
+                       label.LeaveScope ();
+
+                       label.EnterScope ("Transport");
+                       BindingTestAssertions.CheckNetTcpBinding (
+                               new NetTcpBinding (SecurityMode.Transport), SecurityMode.Transport,
+                               false, TransferMode.Buffered, label);
+                       label.LeaveScope ();
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void NetTcp_Binding2 ()
+               {
+                       var label = new TestLabel ("NetTcp_Binding2");
+
+                       label.EnterScope ("TransportWithMessageCredential");
+                       BindingTestAssertions.CheckNetTcpBinding (
+                               new NetTcpBinding (SecurityMode.TransportWithMessageCredential),
+                               SecurityMode.TransportWithMessageCredential, false,
+                               TransferMode.Buffered, label);
+                       label.LeaveScope ();
+               }
+               
+               [Test]
+               [Category ("NotWorking")]
+               public void NetTcp_ReliableSession ()
+               {
+                       var doc = TestContext.GetMetadata ("NetTcp_ReliableSession");
+                       var label = new TestLabel ("NetTcp_ReliableSession");
+                       BindingTestAssertions.NetTcpBinding (
+                               doc, SecurityMode.None, true,
+                               TransferMode.Buffered, label);
+               }
+       }
+
+}
+
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/MetadataSamples.cs b/mcs/class/System.ServiceModel/Test/MetadataTests/MetadataSamples.cs
new file mode 100644 (file)
index 0000000..d467571
--- /dev/null
@@ -0,0 +1,372 @@
+//
+// MetadataProvider.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2012 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using System.IO;
+using System.Reflection;
+using System.ServiceModel;
+using System.ServiceModel.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Configuration;
+using WS = System.Web.Services.Description;
+
+namespace MonoTests.System.ServiceModel.MetadataTests {
+
+       public static class MetadataSamples  {
+
+               internal const string HttpUri = "http://tempuri.org/TestHttp/";
+               internal const string HttpsUri = "https://tempuri.org/TestHttps/";
+               internal const string NetTcpUri = "net-tcp://tempuri.org:8000/TestNetTcp/";
+               internal const string CustomUri = "custom://tempuri.org:8000/Test/";
+
+               [MetadataSample]
+               public static MetadataSet BasicHttp ()
+               {
+                       var exporter = new WsdlExporter ();
+                       
+                       var cd = new ContractDescription ("MyContract");
+                       
+                       exporter.ExportEndpoint (new ServiceEndpoint (
+                               cd, new BasicHttpBinding (), new EndpointAddress (HttpUri)));
+                       
+                       var doc = exporter.GetGeneratedMetadata ();
+                       return doc;
+               }
+
+               [MetadataSample]
+               public static MetadataSet BasicHttp_TransportSecurity ()
+               {
+                       var exporter = new WsdlExporter ();
+                       
+                       var cd = new ContractDescription ("MyContract");
+                       
+                       var binding = new BasicHttpBinding ();
+                       binding.Security.Mode = BasicHttpSecurityMode.Transport;
+                       
+                       exporter.ExportEndpoint (new ServiceEndpoint (
+                               cd, binding, new EndpointAddress (HttpUri)));
+                       
+                       var doc = exporter.GetGeneratedMetadata ();
+                       return doc;
+               }
+
+               [MetadataSample]
+               public static MetadataSet BasicHttp_MessageSecurity ()
+               {
+                       var exporter = new WsdlExporter ();
+                       
+                       var cd = new ContractDescription ("MyContract");
+                       
+                       var binding = new BasicHttpBinding ();
+                       binding.Security.Mode = BasicHttpSecurityMode.Message;
+                       binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.Certificate;
+                       
+                       exporter.ExportEndpoint (new ServiceEndpoint (
+                               cd, binding, new EndpointAddress (HttpUri)));
+                       
+                       var doc = exporter.GetGeneratedMetadata ();
+                       return doc;
+               }
+               
+               [MetadataSample]
+               public static MetadataSet BasicHttp_TransportWithMessageCredential ()
+               {
+                       var exporter = new WsdlExporter ();
+                       
+                       var cd = new ContractDescription ("MyContract");
+                       
+                       var binding = new BasicHttpBinding ();
+                       binding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential;
+                       
+                       exporter.ExportEndpoint (new ServiceEndpoint (
+                               cd, binding, new EndpointAddress (HttpUri)));
+                       
+                       var doc = exporter.GetGeneratedMetadata ();
+                       return doc;
+               }
+               
+               [MetadataSample]
+               public static MetadataSet BasicHttp_Mtom ()
+               {
+                       var exporter = new WsdlExporter ();
+                       
+                       var cd = new ContractDescription ("MyContract");
+                       
+                       var binding = new BasicHttpBinding ();
+                       binding.MessageEncoding = WSMessageEncoding.Mtom;
+                       
+                       exporter.ExportEndpoint (new ServiceEndpoint (
+                               cd, binding, new EndpointAddress (HttpUri)));
+                       
+                       var doc = exporter.GetGeneratedMetadata ();
+                       return doc;
+               }
+
+               [MetadataSample]
+               public static MetadataSet BasicHttp_NtlmAuth ()
+               {
+                       var exporter = new WsdlExporter ();
+                       
+                       var cd = new ContractDescription ("MyContract");
+                       
+                       var binding = new BasicHttpBinding (BasicHttpSecurityMode.TransportCredentialOnly);
+                       binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
+                       
+                       exporter.ExportEndpoint (new ServiceEndpoint (
+                               cd, binding, new EndpointAddress (HttpUri)));
+                       
+                       var doc = exporter.GetGeneratedMetadata ();
+                       return doc;
+               }
+               
+#if FIXME && NET_4_5
+               [MetadataSample]
+               public static MetadataSet BasicHttps ()
+               {
+                       var exporter = new WsdlExporter ();
+                       
+                       var cd = new ContractDescription ("MyContract");
+                       
+                       exporter.ExportEndpoint (new ServiceEndpoint (
+                               cd, new BasicHttpsBinding (), new EndpointAddress (HttpsUri)));
+                       
+                       var doc = exporter.GetGeneratedMetadata ();
+                       return doc;
+               }
+               
+               [MetadataSample]
+               public static MetadataSet BasicHttps_NtlmAuth ()
+               {
+                       var exporter = new WsdlExporter ();
+                       
+                       var cd = new ContractDescription ("MyContract");
+                       
+                       var binding = new BasicHttpsBinding ();
+                       
+                       binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
+                       
+                       exporter.ExportEndpoint (new ServiceEndpoint (
+                               cd, binding, new EndpointAddress (HttpsUri)));
+                       
+                       var doc = exporter.GetGeneratedMetadata ();
+                       return doc;
+               }
+               
+               [MetadataSample]
+               public static MetadataSet BasicHttps_Certificate ()
+               {
+                       var exporter = new WsdlExporter ();
+                       
+                       var cd = new ContractDescription ("MyContract");
+                       
+                       var binding = new BasicHttpsBinding ();
+                       binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
+                       
+                       exporter.ExportEndpoint (new ServiceEndpoint (
+                               cd, binding, new EndpointAddress (HttpsUri)));
+                       
+                       var doc = exporter.GetGeneratedMetadata ();
+                       return doc;
+               }
+               
+               [MetadataSample]
+               public static MetadataSet BasicHttps_TransportWithMessageCredential ()
+               {
+                       var exporter = new WsdlExporter ();
+                       
+                       var cd = new ContractDescription ("MyContract");
+                       
+                       var binding = new BasicHttpsBinding (BasicHttpsSecurityMode.TransportWithMessageCredential);
+                       
+                       exporter.ExportEndpoint (new ServiceEndpoint (
+                               cd, binding, new EndpointAddress (HttpsUri)));
+                       
+                       var doc = exporter.GetGeneratedMetadata ();
+                       return doc;
+               }
+#endif
+               
+               [MetadataSample]
+               public static MetadataSet NetTcp ()
+               {
+                       var exporter = new WsdlExporter ();
+                       
+                       var cd = new ContractDescription ("MyContract");
+                       
+                       exporter.ExportEndpoint (new ServiceEndpoint (
+                               cd, new NetTcpBinding (SecurityMode.None, false),
+                               new EndpointAddress (NetTcpUri)));
+                       
+                       var doc = exporter.GetGeneratedMetadata ();
+                       return doc;
+               }
+               
+               [MetadataSample]
+               public static MetadataSet NetTcp_TransportSecurity ()
+               {
+                       var exporter = new WsdlExporter ();
+                       
+                       var cd = new ContractDescription ("MyContract");
+                       
+                       exporter.ExportEndpoint (new ServiceEndpoint (
+                               cd, new NetTcpBinding (SecurityMode.Transport, false),
+                               new EndpointAddress (NetTcpUri)));
+                       
+                       var doc = exporter.GetGeneratedMetadata ();
+                       return doc;
+               }
+               
+               [MetadataSample]
+               public static MetadataSet NetTcp_MessageSecurity ()
+               {
+                       var exporter = new WsdlExporter ();
+                       
+                       var cd = new ContractDescription ("MyContract");
+                       
+                       exporter.ExportEndpoint (new ServiceEndpoint (
+                               cd, new NetTcpBinding (SecurityMode.Message, false),
+                               new EndpointAddress (NetTcpUri)));
+                       
+                       var doc = exporter.GetGeneratedMetadata ();
+                       return doc;
+               }
+               
+               [MetadataSample]
+               public static MetadataSet NetTcp_TransportWithMessageCredential ()
+               {
+                       var exporter = new WsdlExporter ();
+                       
+                       var cd = new ContractDescription ("MyContract");
+                       
+                       exporter.ExportEndpoint (new ServiceEndpoint (
+                               cd, new NetTcpBinding (SecurityMode.TransportWithMessageCredential, false),
+                               new EndpointAddress (NetTcpUri)));
+                       
+                       var doc = exporter.GetGeneratedMetadata ();
+                       return doc;
+               }
+
+               [MetadataSample]
+               public static MetadataSet NetTcp_ReliableSession ()
+               {
+                       var exporter = new WsdlExporter ();
+                       
+                       var cd = new ContractDescription ("MyContract");
+                       
+                       var binding = new NetTcpBinding (SecurityMode.None, true);
+                       
+                       exporter.ExportEndpoint (new ServiceEndpoint (
+                               cd, binding, new EndpointAddress (NetTcpUri)));
+                       
+                       var doc = exporter.GetGeneratedMetadata ();
+                       return doc;
+               }
+               
+               [MetadataSample]
+               public static MetadataSet NetTcp_TransferMode ()
+               {
+                       var exporter = new WsdlExporter ();
+                       
+                       var cd = new ContractDescription ("MyContract");
+                       
+                       var binding = new NetTcpBinding (SecurityMode.None, false);
+                       binding.TransferMode = TransferMode.Streamed;
+
+                       exporter.ExportEndpoint (new ServiceEndpoint (
+                               cd, binding, new EndpointAddress (NetTcpUri)));
+                       
+                       var doc = exporter.GetGeneratedMetadata ();
+                       return doc;
+               }
+
+               public static void Export ()
+               {
+                       var bf = BindingFlags.Public | BindingFlags.Static;
+                       foreach (var method in typeof (MetadataSamples).GetMethods (bf)) {
+                               MetadataSampleAttribute sampleAttr = null;
+                               foreach (var obj in method.GetCustomAttributes (false)) {
+                                       var cattr = obj as MetadataSampleAttribute;
+                                       if (cattr != null) {
+                                               sampleAttr = cattr;
+                                               break;
+                                       }
+                               }
+
+                               if (sampleAttr == null)
+                                       continue;
+
+                               var name = sampleAttr.Name ?? method.Name;
+                               var doc = (MetadataSet)method.Invoke (null, null);
+                               TestContext.SaveMetadata (name, doc);
+                       }
+               }
+
+               public static MetadataSet GetMetadataByName (string name)
+               {
+                       if (name.EndsWith (".xml"))
+                               name = name.Substring (name.Length - 4);
+
+                       var bf = BindingFlags.Public | BindingFlags.Static;
+                       foreach (var method in typeof (MetadataSamples).GetMethods (bf)) {
+                               MetadataSampleAttribute sampleAttr = null;
+                               foreach (var obj in method.GetCustomAttributes (false)) {
+                                       var cattr = obj as MetadataSampleAttribute;
+                                       if (cattr != null) {
+                                               sampleAttr = cattr;
+                                               break;
+                                       }
+                               }
+                               
+                               if (sampleAttr == null)
+                                       continue;
+                               
+                               if (!name.Equals (sampleAttr.Name ?? method.Name))
+                                       continue;
+
+                               return (MetadataSet)method.Invoke (null, null);
+                       }
+
+                       throw new InvalidOperationException ();
+               }
+
+               public class MetadataSampleAttribute : Attribute {
+                       
+                       public MetadataSampleAttribute ()
+                       {
+                       }
+                       
+                       public MetadataSampleAttribute (string name)
+                       {
+                               Name = name;
+                       }
+                       
+                       public string Name {
+                               get; set;
+                       }
+                       
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/MetadataTests.csproj b/mcs/class/System.ServiceModel/Test/MetadataTests/MetadataTests.csproj
new file mode 100644 (file)
index 0000000..0d66d75
--- /dev/null
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>10.0.0</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{7731D464-5152-4A1B-AACB-6B5A7CA9ACAA}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <RootNamespace>MetadataTests</RootNamespace>
+    <AssemblyName>MetadataTests</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>True</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>False</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG;USE_EMBEDDED_METADATA</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>False</ConsolePause>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>True</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>False</ConsolePause>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="nunit.framework" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.ServiceModel" />
+    <Reference Include="System.Web.Services" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AssemblyInfo.cs" />
+    <Compile Include="BindingTestAssertions.cs" />
+    <Compile Include="ImportTests_Misc.cs" />
+    <Compile Include="ImportTests_Tests.cs" />
+    <Compile Include="MetadataSamples.cs" />
+    <Compile Include="TestContext.cs" />
+    <Compile Include="TestLabel.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <ItemGroup>
+    <None Include="README.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Resources\" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Resources\BasicHttp.xml" />
+    <EmbeddedResource Include="Resources\BasicHttp_MessageSecurity.xml" />
+    <EmbeddedResource Include="Resources\BasicHttp_Mtom.xml" />
+    <EmbeddedResource Include="Resources\BasicHttp_NtlmAuth.xml" />
+    <EmbeddedResource Include="Resources\BasicHttp_TransportSecurity.xml" />
+    <EmbeddedResource Include="Resources\BasicHttp_TransportWithMessageCredential.xml" />
+    <EmbeddedResource Include="Resources\BasicHttps.xml" />
+    <EmbeddedResource Include="Resources\BasicHttps_Certificate.xml" />
+    <EmbeddedResource Include="Resources\BasicHttps_NtlmAuth.xml" />
+    <EmbeddedResource Include="Resources\BasicHttps_TransportWithMessageCredential.xml" />
+    <EmbeddedResource Include="Resources\NetTcp.xml" />
+    <EmbeddedResource Include="Resources\NetTcp_MessageSecurity.xml" />
+    <EmbeddedResource Include="Resources\NetTcp_ReliableSession.xml" />
+    <EmbeddedResource Include="Resources\NetTcp_TransferMode.xml" />
+    <EmbeddedResource Include="Resources\NetTcp_TransportSecurity.xml" />
+    <EmbeddedResource Include="Resources\NetTcp_TransportWithMessageCredential.xml" />
+    <EmbeddedResource Include="Resources\http-error.xml" />
+  </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/MetadataTests.sln b/mcs/class/System.ServiceModel/Test/MetadataTests/MetadataTests.sln
new file mode 100644 (file)
index 0000000..3086179
--- /dev/null
@@ -0,0 +1,26 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 11.00\r
+# Visual Studio 2010\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MetadataTests", "MetadataTests.csproj", "{7731D464-5152-4A1B-AACB-6B5A7CA9ACAA}"\r
+EndProject\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExportUtil", "ExportUtil.csproj", "{D4C1B0BD-3488-441C-92B9-7E017041E137}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Any CPU = Debug|Any CPU\r
+               Release|Any CPU = Release|Any CPU\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {7731D464-5152-4A1B-AACB-6B5A7CA9ACAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {7731D464-5152-4A1B-AACB-6B5A7CA9ACAA}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {7731D464-5152-4A1B-AACB-6B5A7CA9ACAA}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {7731D464-5152-4A1B-AACB-6B5A7CA9ACAA}.Release|Any CPU.Build.0 = Release|Any CPU\r
+               {D4C1B0BD-3488-441C-92B9-7E017041E137}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {D4C1B0BD-3488-441C-92B9-7E017041E137}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {D4C1B0BD-3488-441C-92B9-7E017041E137}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {D4C1B0BD-3488-441C-92B9-7E017041E137}.Release|Any CPU.Build.0 = Release|Any CPU\r
+       EndGlobalSection\r
+       GlobalSection(MonoDevelopProperties) = preSolution\r
+               StartupItem = MetadataTests.csproj\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/README.txt b/mcs/class/System.ServiceModel/Test/MetadataTests/README.txt
new file mode 100644 (file)
index 0000000..a1ed18e
--- /dev/null
@@ -0,0 +1,54 @@
+Metadata Tests
+==============
+
+These tests can be run either as part of System.ServiceModel_test_<profile>.dll
+or as the stand-alone MetadataTests.dll, which bundles all the XML files as
+embedded resources.
+
+Generating and updating the XML Samples:
+========================================
+
+Mono's WsdlExporter is not yet capable of generating the wsdl files that
+are used as test input here.
+
+To generate the XML files, compile the ExportUtil.exe tool either by using the
+ExportUtil.csproj or compiling it manually:
+
+  mcs -r:System.ServiceModel -r:System.Web.Services ExportUtil.cs MetadataSamples.cs TestContext.cs 
+
+Then copy the binary to a Windows machine and run it there.  This will generate a bunch of
+.xml files.  Run dos2unix on them and copy them into the Resources/ subdirectory.
+
+Adding new Tests:
+=================
+
+To add a new test, add a method with the [MetadataaSample] attribute to
+MetadataSamples.cs, like this:
+
+       [MetadataSample]
+       public static MetadataSet MyXML ()
+       {
+               ....
+       }
+
+You may also specify a name:
+
+       [MetadataSample ("MyXML")]
+       public static MetadataSet RandomMethodName ()   
+       {
+       }
+
+Re-compile ExportUtil.exe and it will produce a new 'MyXML.xml' file.
+
+Then write a new test case:
+
+       [Test]
+       public void MyXML ()
+       {
+               var doc = TestContext.GetMetadata ("MyXML");
+               ... test it here
+       }
+
+The idea behind the 'TestContext' class is to allow "self-hosting" at a
+later time, ie. use Mono's WsdlExporter to generate the metadata instead
+of loading the on-disk file without having to modify a bunch of tests.
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp.xml
new file mode 100644 (file)
index 0000000..82ce03c
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="BasicHttpBinding_MyContract" type="tns:MyContract">
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="BasicHttpBinding_MyContract" binding="tns:BasicHttpBinding_MyContract">
+          <soap:address location="http://tempuri.org/TestHttp/" />
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp_MessageSecurity.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp_MessageSecurity.xml
new file mode 100644 (file)
index 0000000..7a442ff
--- /dev/null
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsp:Policy wsu:Id="BasicHttpBinding_MyContract_policy">
+        <wsp:ExactlyOne>
+          <wsp:All>
+            <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy>
+                <sp:InitiatorToken>
+                  <wsp:Policy>
+                    <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+                      <wsp:Policy>
+                        <sp:WssX509V3Token10 />
+                      </wsp:Policy>
+                    </sp:X509Token>
+                  </wsp:Policy>
+                </sp:InitiatorToken>
+                <sp:RecipientToken>
+                  <wsp:Policy>
+                    <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+                      <wsp:Policy>
+                        <sp:WssX509V3Token10 />
+                      </wsp:Policy>
+                    </sp:X509Token>
+                  </wsp:Policy>
+                </sp:RecipientToken>
+                <sp:AlgorithmSuite>
+                  <wsp:Policy>
+                    <sp:Basic256 />
+                  </wsp:Policy>
+                </sp:AlgorithmSuite>
+                <sp:Layout>
+                  <wsp:Policy>
+                    <sp:Lax />
+                  </wsp:Policy>
+                </sp:Layout>
+                <sp:IncludeTimestamp />
+                <sp:OnlySignEntireHeadersAndBody />
+              </wsp:Policy>
+            </sp:AsymmetricBinding>
+            <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy>
+                <sp:MustSupportRefKeyIdentifier />
+                <sp:MustSupportRefIssuerSerial />
+              </wsp:Policy>
+            </sp:Wss10>
+          </wsp:All>
+        </wsp:ExactlyOne>
+      </wsp:Policy>
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="BasicHttpBinding_MyContract" type="tns:MyContract">
+        <wsp:PolicyReference URI="#BasicHttpBinding_MyContract_policy" />
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="BasicHttpBinding_MyContract" binding="tns:BasicHttpBinding_MyContract">
+          <soap:address location="http://tempuri.org/TestHttp/" />
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp_Mtom.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp_Mtom.xml
new file mode 100644 (file)
index 0000000..9e827c0
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsp:Policy wsu:Id="BasicHttpBinding_MyContract_policy">
+        <wsp:ExactlyOne>
+          <wsp:All>
+            <wsoma:OptimizedMimeSerialization xmlns:wsoma="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" />
+          </wsp:All>
+        </wsp:ExactlyOne>
+      </wsp:Policy>
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="BasicHttpBinding_MyContract" type="tns:MyContract">
+        <wsp:PolicyReference URI="#BasicHttpBinding_MyContract_policy" />
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="BasicHttpBinding_MyContract" binding="tns:BasicHttpBinding_MyContract">
+          <soap:address location="http://tempuri.org/TestHttp/" />
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp_NtlmAuth.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp_NtlmAuth.xml
new file mode 100644 (file)
index 0000000..e865018
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsp:Policy wsu:Id="BasicHttpBinding_MyContract_policy">
+        <wsp:ExactlyOne>
+          <wsp:All>
+            <http:NtlmAuthentication xmlns:http="http://schemas.microsoft.com/ws/06/2004/policy/http" />
+          </wsp:All>
+        </wsp:ExactlyOne>
+      </wsp:Policy>
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="BasicHttpBinding_MyContract" type="tns:MyContract">
+        <wsp:PolicyReference URI="#BasicHttpBinding_MyContract_policy" />
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="BasicHttpBinding_MyContract" binding="tns:BasicHttpBinding_MyContract">
+          <soap:address location="http://tempuri.org/TestHttp/" />
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp_TransportSecurity.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp_TransportSecurity.xml
new file mode 100644 (file)
index 0000000..82ab01b
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsp:Policy wsu:Id="BasicHttpBinding_MyContract_policy">
+        <wsp:ExactlyOne>
+          <wsp:All>
+            <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy>
+                <sp:TransportToken>
+                  <wsp:Policy>
+                    <sp:HttpsToken RequireClientCertificate="false" />
+                  </wsp:Policy>
+                </sp:TransportToken>
+                <sp:AlgorithmSuite>
+                  <wsp:Policy>
+                    <sp:Basic256 />
+                  </wsp:Policy>
+                </sp:AlgorithmSuite>
+                <sp:Layout>
+                  <wsp:Policy>
+                    <sp:Strict />
+                  </wsp:Policy>
+                </sp:Layout>
+              </wsp:Policy>
+            </sp:TransportBinding>
+          </wsp:All>
+        </wsp:ExactlyOne>
+      </wsp:Policy>
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="BasicHttpBinding_MyContract" type="tns:MyContract">
+        <wsp:PolicyReference URI="#BasicHttpBinding_MyContract_policy" />
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="BasicHttpBinding_MyContract" binding="tns:BasicHttpBinding_MyContract">
+          <soap:address location="http://tempuri.org/TestHttp/" />
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp_TransportWithMessageCredential.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttp_TransportWithMessageCredential.xml
new file mode 100644 (file)
index 0000000..0905542
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsp:Policy wsu:Id="BasicHttpBinding_MyContract_policy">
+        <wsp:ExactlyOne>
+          <wsp:All>
+            <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy>
+                <sp:TransportToken>
+                  <wsp:Policy>
+                    <sp:HttpsToken RequireClientCertificate="false" />
+                  </wsp:Policy>
+                </sp:TransportToken>
+                <sp:AlgorithmSuite>
+                  <wsp:Policy>
+                    <sp:Basic256 />
+                  </wsp:Policy>
+                </sp:AlgorithmSuite>
+                <sp:Layout>
+                  <wsp:Policy>
+                    <sp:Lax />
+                  </wsp:Policy>
+                </sp:Layout>
+                <sp:IncludeTimestamp />
+              </wsp:Policy>
+            </sp:TransportBinding>
+            <sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy>
+                <sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+                  <wsp:Policy>
+                    <sp:WssUsernameToken10 />
+                  </wsp:Policy>
+                </sp:UsernameToken>
+              </wsp:Policy>
+            </sp:SignedSupportingTokens>
+            <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy />
+            </sp:Wss10>
+          </wsp:All>
+        </wsp:ExactlyOne>
+      </wsp:Policy>
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="BasicHttpBinding_MyContract" type="tns:MyContract">
+        <wsp:PolicyReference URI="#BasicHttpBinding_MyContract_policy" />
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="BasicHttpBinding_MyContract" binding="tns:BasicHttpBinding_MyContract">
+          <soap:address location="http://tempuri.org/TestHttp/" />
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttps.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttps.xml
new file mode 100644 (file)
index 0000000..9ed00e4
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsp:Policy wsu:Id="BasicHttpsBinding_MyContract_policy">
+        <wsp:ExactlyOne>
+          <wsp:All>
+            <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy>
+                <sp:TransportToken>
+                  <wsp:Policy>
+                    <sp:HttpsToken RequireClientCertificate="false" />
+                  </wsp:Policy>
+                </sp:TransportToken>
+                <sp:AlgorithmSuite>
+                  <wsp:Policy>
+                    <sp:Basic256 />
+                  </wsp:Policy>
+                </sp:AlgorithmSuite>
+                <sp:Layout>
+                  <wsp:Policy>
+                    <sp:Strict />
+                  </wsp:Policy>
+                </sp:Layout>
+              </wsp:Policy>
+            </sp:TransportBinding>
+          </wsp:All>
+        </wsp:ExactlyOne>
+      </wsp:Policy>
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="BasicHttpsBinding_MyContract" type="tns:MyContract">
+        <wsp:PolicyReference URI="#BasicHttpsBinding_MyContract_policy" />
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="BasicHttpsBinding_MyContract" binding="tns:BasicHttpsBinding_MyContract">
+          <soap:address location="https://tempuri.org/TestHttps/" />
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttps_Certificate.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttps_Certificate.xml
new file mode 100644 (file)
index 0000000..f8b19cc
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsp:Policy wsu:Id="BasicHttpsBinding_MyContract_policy">
+        <wsp:ExactlyOne>
+          <wsp:All>
+            <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy>
+                <sp:TransportToken>
+                  <wsp:Policy>
+                    <sp:HttpsToken RequireClientCertificate="true" />
+                  </wsp:Policy>
+                </sp:TransportToken>
+                <sp:AlgorithmSuite>
+                  <wsp:Policy>
+                    <sp:Basic256 />
+                  </wsp:Policy>
+                </sp:AlgorithmSuite>
+                <sp:Layout>
+                  <wsp:Policy>
+                    <sp:Strict />
+                  </wsp:Policy>
+                </sp:Layout>
+              </wsp:Policy>
+            </sp:TransportBinding>
+          </wsp:All>
+        </wsp:ExactlyOne>
+      </wsp:Policy>
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="BasicHttpsBinding_MyContract" type="tns:MyContract">
+        <wsp:PolicyReference URI="#BasicHttpsBinding_MyContract_policy" />
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="BasicHttpsBinding_MyContract" binding="tns:BasicHttpsBinding_MyContract">
+          <soap:address location="https://tempuri.org/TestHttps/" />
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttps_NtlmAuth.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttps_NtlmAuth.xml
new file mode 100644 (file)
index 0000000..ad6772e
--- /dev/null
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsp:Policy wsu:Id="BasicHttpsBinding_MyContract_policy">
+        <wsp:ExactlyOne>
+          <wsp:All>
+            <http:NtlmAuthentication xmlns:http="http://schemas.microsoft.com/ws/06/2004/policy/http" />
+            <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy>
+                <sp:TransportToken>
+                  <wsp:Policy>
+                    <sp:HttpsToken RequireClientCertificate="false" />
+                  </wsp:Policy>
+                </sp:TransportToken>
+                <sp:AlgorithmSuite>
+                  <wsp:Policy>
+                    <sp:Basic256 />
+                  </wsp:Policy>
+                </sp:AlgorithmSuite>
+                <sp:Layout>
+                  <wsp:Policy>
+                    <sp:Strict />
+                  </wsp:Policy>
+                </sp:Layout>
+              </wsp:Policy>
+            </sp:TransportBinding>
+          </wsp:All>
+        </wsp:ExactlyOne>
+      </wsp:Policy>
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="BasicHttpsBinding_MyContract" type="tns:MyContract">
+        <wsp:PolicyReference URI="#BasicHttpsBinding_MyContract_policy" />
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="BasicHttpsBinding_MyContract" binding="tns:BasicHttpsBinding_MyContract">
+          <soap:address location="https://tempuri.org/TestHttps/" />
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttps_TransportWithMessageCredential.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/BasicHttps_TransportWithMessageCredential.xml
new file mode 100644 (file)
index 0000000..f688906
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsp:Policy wsu:Id="BasicHttpsBinding_MyContract_policy">
+        <wsp:ExactlyOne>
+          <wsp:All>
+            <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy>
+                <sp:TransportToken>
+                  <wsp:Policy>
+                    <sp:HttpsToken RequireClientCertificate="false" />
+                  </wsp:Policy>
+                </sp:TransportToken>
+                <sp:AlgorithmSuite>
+                  <wsp:Policy>
+                    <sp:Basic256 />
+                  </wsp:Policy>
+                </sp:AlgorithmSuite>
+                <sp:Layout>
+                  <wsp:Policy>
+                    <sp:Lax />
+                  </wsp:Policy>
+                </sp:Layout>
+                <sp:IncludeTimestamp />
+              </wsp:Policy>
+            </sp:TransportBinding>
+            <sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy>
+                <sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+                  <wsp:Policy>
+                    <sp:WssUsernameToken10 />
+                  </wsp:Policy>
+                </sp:UsernameToken>
+              </wsp:Policy>
+            </sp:SignedSupportingTokens>
+            <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy />
+            </sp:Wss10>
+          </wsp:All>
+        </wsp:ExactlyOne>
+      </wsp:Policy>
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="BasicHttpsBinding_MyContract" type="tns:MyContract">
+        <wsp:PolicyReference URI="#BasicHttpsBinding_MyContract_policy" />
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="BasicHttpsBinding_MyContract" binding="tns:BasicHttpsBinding_MyContract">
+          <soap:address location="https://tempuri.org/TestHttps/" />
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp.xml
new file mode 100644 (file)
index 0000000..7edf87a
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsp:Policy wsu:Id="NetTcpBinding_MyContract_policy">
+        <wsp:ExactlyOne>
+          <wsp:All>
+            <msb:BinaryEncoding xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1" />
+            <wsaw:UsingAddressing />
+          </wsp:All>
+        </wsp:ExactlyOne>
+      </wsp:Policy>
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="NetTcpBinding_MyContract" type="tns:MyContract">
+        <wsp:PolicyReference URI="#NetTcpBinding_MyContract_policy" />
+        <soap12:binding transport="http://schemas.microsoft.com/soap/tcp" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="NetTcpBinding_MyContract" binding="tns:NetTcpBinding_MyContract">
+          <soap12:address location="net-tcp://tempuri.org:8000/TestNetTcp/" />
+          <wsa10:EndpointReference>
+            <wsa10:Address>net-tcp://tempuri.org:8000/TestNetTcp/</wsa10:Address>
+          </wsa10:EndpointReference>
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp_MessageSecurity.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp_MessageSecurity.xml
new file mode 100644 (file)
index 0000000..5953464
--- /dev/null
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsp:Policy wsu:Id="NetTcpBinding_MyContract_policy">
+        <wsp:ExactlyOne>
+          <wsp:All>
+            <sp:SymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy>
+                <sp:ProtectionToken>
+                  <wsp:Policy>
+                    <sp:SecureConversationToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+                      <wsp:Policy>
+                        <sp:RequireDerivedKeys />
+                        <sp:BootstrapPolicy>
+                          <wsp:Policy>
+                            <sp:SignedParts>
+                              <sp:Body />
+                              <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing" />
+                              <sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing" />
+                              <sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing" />
+                              <sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing" />
+                              <sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing" />
+                              <sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing" />
+                              <sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing" />
+                            </sp:SignedParts>
+                            <sp:EncryptedParts>
+                              <sp:Body />
+                            </sp:EncryptedParts>
+                            <sp:SymmetricBinding>
+                              <wsp:Policy>
+                                <sp:ProtectionToken>
+                                  <wsp:Policy>
+                                    <sp:SpnegoContextToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+                                      <wsp:Policy>
+                                        <sp:RequireDerivedKeys />
+                                      </wsp:Policy>
+                                    </sp:SpnegoContextToken>
+                                  </wsp:Policy>
+                                </sp:ProtectionToken>
+                                <sp:AlgorithmSuite>
+                                  <wsp:Policy>
+                                    <sp:Basic256 />
+                                  </wsp:Policy>
+                                </sp:AlgorithmSuite>
+                                <sp:Layout>
+                                  <wsp:Policy>
+                                    <sp:Strict />
+                                  </wsp:Policy>
+                                </sp:Layout>
+                                <sp:IncludeTimestamp />
+                                <sp:EncryptSignature />
+                                <sp:OnlySignEntireHeadersAndBody />
+                              </wsp:Policy>
+                            </sp:SymmetricBinding>
+                            <sp:Wss11>
+                              <wsp:Policy />
+                            </sp:Wss11>
+                            <sp:Trust10>
+                              <wsp:Policy>
+                                <sp:MustSupportIssuedTokens />
+                                <sp:RequireClientEntropy />
+                                <sp:RequireServerEntropy />
+                              </wsp:Policy>
+                            </sp:Trust10>
+                          </wsp:Policy>
+                        </sp:BootstrapPolicy>
+                      </wsp:Policy>
+                    </sp:SecureConversationToken>
+                  </wsp:Policy>
+                </sp:ProtectionToken>
+                <sp:AlgorithmSuite>
+                  <wsp:Policy>
+                    <sp:Basic256 />
+                  </wsp:Policy>
+                </sp:AlgorithmSuite>
+                <sp:Layout>
+                  <wsp:Policy>
+                    <sp:Strict />
+                  </wsp:Policy>
+                </sp:Layout>
+                <sp:IncludeTimestamp />
+                <sp:OnlySignEntireHeadersAndBody />
+              </wsp:Policy>
+            </sp:SymmetricBinding>
+            <sp:Wss11 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy />
+            </sp:Wss11>
+            <sp:Trust10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy>
+                <sp:MustSupportIssuedTokens />
+                <sp:RequireClientEntropy />
+                <sp:RequireServerEntropy />
+              </wsp:Policy>
+            </sp:Trust10>
+            <msb:BinaryEncoding xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1" />
+            <wsaw:UsingAddressing />
+          </wsp:All>
+        </wsp:ExactlyOne>
+      </wsp:Policy>
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="NetTcpBinding_MyContract" type="tns:MyContract">
+        <wsp:PolicyReference URI="#NetTcpBinding_MyContract_policy" />
+        <soap12:binding transport="http://schemas.microsoft.com/soap/tcp" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="NetTcpBinding_MyContract" binding="tns:NetTcpBinding_MyContract">
+          <soap12:address location="net-tcp://tempuri.org:8000/TestNetTcp/" />
+          <wsa10:EndpointReference>
+            <wsa10:Address>net-tcp://tempuri.org:8000/TestNetTcp/</wsa10:Address>
+          </wsa10:EndpointReference>
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp_ReliableSession.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp_ReliableSession.xml
new file mode 100644 (file)
index 0000000..85d1bd0
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsp:Policy wsu:Id="NetTcpBinding_MyContract_policy">
+        <wsp:ExactlyOne>
+          <wsp:All>
+            <wsrm:RMAssertion xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm/policy">
+              <wsrm:InactivityTimeout Milliseconds="600000" />
+              <wsrm:AcknowledgementInterval Milliseconds="200" />
+            </wsrm:RMAssertion>
+            <msb:BinaryEncoding xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1" />
+            <wsaw:UsingAddressing />
+          </wsp:All>
+        </wsp:ExactlyOne>
+      </wsp:Policy>
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="NetTcpBinding_MyContract" type="tns:MyContract">
+        <wsp:PolicyReference URI="#NetTcpBinding_MyContract_policy" />
+        <soap12:binding transport="http://schemas.microsoft.com/soap/tcp" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="NetTcpBinding_MyContract" binding="tns:NetTcpBinding_MyContract">
+          <soap12:address location="net-tcp://tempuri.org:8000/TestNetTcp/" />
+          <wsa10:EndpointReference>
+            <wsa10:Address>net-tcp://tempuri.org:8000/TestNetTcp/</wsa10:Address>
+          </wsa10:EndpointReference>
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp_TransferMode.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp_TransferMode.xml
new file mode 100644 (file)
index 0000000..f8c5e45
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsp:Policy wsu:Id="NetTcpBinding_MyContract_policy">
+        <wsp:ExactlyOne>
+          <wsp:All>
+            <msb:BinaryEncoding xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1" />
+            <msf:Streamed xmlns:msf="http://schemas.microsoft.com/ws/2006/05/framing/policy" />
+            <wsaw:UsingAddressing />
+          </wsp:All>
+        </wsp:ExactlyOne>
+      </wsp:Policy>
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="NetTcpBinding_MyContract" type="tns:MyContract">
+        <wsp:PolicyReference URI="#NetTcpBinding_MyContract_policy" />
+        <soap12:binding transport="http://schemas.microsoft.com/soap/tcp" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="NetTcpBinding_MyContract" binding="tns:NetTcpBinding_MyContract">
+          <soap12:address location="net-tcp://tempuri.org:8000/TestNetTcp/" />
+          <wsa10:EndpointReference>
+            <wsa10:Address>net-tcp://tempuri.org:8000/TestNetTcp/</wsa10:Address>
+          </wsa10:EndpointReference>
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp_TransportSecurity.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp_TransportSecurity.xml
new file mode 100644 (file)
index 0000000..3ba464a
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsp:Policy wsu:Id="NetTcpBinding_MyContract_policy">
+        <wsp:ExactlyOne>
+          <wsp:All>
+            <msb:BinaryEncoding xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1" />
+            <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy>
+                <sp:TransportToken>
+                  <wsp:Policy>
+                    <msf:WindowsTransportSecurity xmlns:msf="http://schemas.microsoft.com/ws/2006/05/framing/policy">
+                      <msf:ProtectionLevel>EncryptAndSign</msf:ProtectionLevel>
+                    </msf:WindowsTransportSecurity>
+                  </wsp:Policy>
+                </sp:TransportToken>
+                <sp:AlgorithmSuite>
+                  <wsp:Policy>
+                    <sp:Basic256 />
+                  </wsp:Policy>
+                </sp:AlgorithmSuite>
+                <sp:Layout>
+                  <wsp:Policy>
+                    <sp:Strict />
+                  </wsp:Policy>
+                </sp:Layout>
+              </wsp:Policy>
+            </sp:TransportBinding>
+            <wsaw:UsingAddressing />
+          </wsp:All>
+        </wsp:ExactlyOne>
+      </wsp:Policy>
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="NetTcpBinding_MyContract" type="tns:MyContract">
+        <wsp:PolicyReference URI="#NetTcpBinding_MyContract_policy" />
+        <soap12:binding transport="http://schemas.microsoft.com/soap/tcp" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="NetTcpBinding_MyContract" binding="tns:NetTcpBinding_MyContract">
+          <soap12:address location="net-tcp://tempuri.org:8000/TestNetTcp/" />
+          <wsa10:EndpointReference>
+            <wsa10:Address>net-tcp://tempuri.org:8000/TestNetTcp/</wsa10:Address>
+          </wsa10:EndpointReference>
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp_TransportWithMessageCredential.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/NetTcp_TransportWithMessageCredential.xml
new file mode 100644 (file)
index 0000000..9d26993
--- /dev/null
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsp:Policy wsu:Id="NetTcpBinding_MyContract_policy">
+        <wsp:ExactlyOne>
+          <wsp:All>
+            <msb:BinaryEncoding xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1" />
+            <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy>
+                <sp:TransportToken>
+                  <wsp:Policy>
+                    <msf:SslTransportSecurity xmlns:msf="http://schemas.microsoft.com/ws/2006/05/framing/policy" />
+                  </wsp:Policy>
+                </sp:TransportToken>
+                <sp:AlgorithmSuite>
+                  <wsp:Policy>
+                    <sp:Basic256 />
+                  </wsp:Policy>
+                </sp:AlgorithmSuite>
+                <sp:Layout>
+                  <wsp:Policy>
+                    <sp:Strict />
+                  </wsp:Policy>
+                </sp:Layout>
+                <sp:IncludeTimestamp />
+              </wsp:Policy>
+            </sp:TransportBinding>
+            <sp:EndorsingSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy>
+                <sp:SecureConversationToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+                  <wsp:Policy>
+                    <sp:BootstrapPolicy>
+                      <wsp:Policy>
+                        <sp:SignedParts>
+                          <sp:Body />
+                          <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing" />
+                          <sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing" />
+                          <sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing" />
+                          <sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing" />
+                          <sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing" />
+                          <sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing" />
+                          <sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing" />
+                        </sp:SignedParts>
+                        <sp:EncryptedParts>
+                          <sp:Body />
+                        </sp:EncryptedParts>
+                        <sp:TransportBinding>
+                          <wsp:Policy>
+                            <sp:TransportToken>
+                              <wsp:Policy>
+                                <msf:SslTransportSecurity xmlns:msf="http://schemas.microsoft.com/ws/2006/05/framing/policy" />
+                              </wsp:Policy>
+                            </sp:TransportToken>
+                            <sp:AlgorithmSuite>
+                              <wsp:Policy>
+                                <sp:Basic256 />
+                              </wsp:Policy>
+                            </sp:AlgorithmSuite>
+                            <sp:Layout>
+                              <wsp:Policy>
+                                <sp:Strict />
+                              </wsp:Policy>
+                            </sp:Layout>
+                            <sp:IncludeTimestamp />
+                          </wsp:Policy>
+                        </sp:TransportBinding>
+                        <sp:EndorsingSupportingTokens>
+                          <wsp:Policy>
+                            <sp:SpnegoContextToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+                              <wsp:Policy />
+                            </sp:SpnegoContextToken>
+                          </wsp:Policy>
+                        </sp:EndorsingSupportingTokens>
+                        <sp:Wss11>
+                          <wsp:Policy />
+                        </sp:Wss11>
+                        <sp:Trust10>
+                          <wsp:Policy>
+                            <sp:MustSupportIssuedTokens />
+                            <sp:RequireClientEntropy />
+                            <sp:RequireServerEntropy />
+                          </wsp:Policy>
+                        </sp:Trust10>
+                      </wsp:Policy>
+                    </sp:BootstrapPolicy>
+                  </wsp:Policy>
+                </sp:SecureConversationToken>
+              </wsp:Policy>
+            </sp:EndorsingSupportingTokens>
+            <sp:Wss11 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy />
+            </sp:Wss11>
+            <sp:Trust10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+              <wsp:Policy>
+                <sp:MustSupportIssuedTokens />
+                <sp:RequireClientEntropy />
+                <sp:RequireServerEntropy />
+              </wsp:Policy>
+            </sp:Trust10>
+            <wsaw:UsingAddressing />
+          </wsp:All>
+        </wsp:ExactlyOne>
+      </wsp:Policy>
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="NetTcpBinding_MyContract" type="tns:MyContract">
+        <wsp:PolicyReference URI="#NetTcpBinding_MyContract_policy" />
+        <soap12:binding transport="http://schemas.microsoft.com/soap/tcp" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="NetTcpBinding_MyContract" binding="tns:NetTcpBinding_MyContract">
+          <soap12:address location="net-tcp://tempuri.org:8000/TestNetTcp/" />
+          <wsa10:EndpointReference>
+            <wsa10:Address>net-tcp://tempuri.org:8000/TestNetTcp/</wsa10:Address>
+          </wsa10:EndpointReference>
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/http-error.xml b/mcs/class/System.ServiceModel/Test/MetadataTests/Resources/http-error.xml
new file mode 100644 (file)
index 0000000..d8678d5
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Metadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex">
+  <wsx:MetadataSection xmlns="" Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/">
+    <wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" name="service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+      <wsdl:types />
+      <wsdl:portType name="MyContract" />
+      <wsdl:binding name="BasicHttpBinding_MyContract" type="tns:NonExisting">
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
+      </wsdl:binding>
+      <wsdl:service name="service">
+        <wsdl:port name="BasicHttpBinding_MyContract" binding="tns:BasicHttpBinding_MyContract">
+          <soap:address location="http://tempuri.org/TestHttp/" />
+        </wsdl:port>
+      </wsdl:service>
+    </wsdl:definitions>
+  </wsx:MetadataSection>
+</Metadata>
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/TestContext.cs b/mcs/class/System.ServiceModel/Test/MetadataTests/TestContext.cs
new file mode 100644 (file)
index 0000000..7757e2a
--- /dev/null
@@ -0,0 +1,104 @@
+//
+// ITestContext.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2012 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.IO;
+using System.Xml;
+using System.Reflection;
+using System.ServiceModel.Description;
+
+namespace MonoTests.System.ServiceModel.MetadataTests {
+
+       public static class TestContext {
+
+               #region Public API
+
+               public static MetadataSet GetMetadata (string name)
+               {
+#if USE_EMBEDDED_METADATA
+                       return LoadMetadataFromResource (name);
+#else
+                       return LoadMetadataFromFile (name);
+#endif
+               }
+
+               public static void SaveMetadata (string name, MetadataSet metadata)
+               {
+                       SaveMetadataToFile (name, metadata);
+               }
+
+               #endregion
+
+               internal static MetadataSet LoadMetadataFromFile (string name)
+               {
+                       var asm = Assembly.GetExecutingAssembly ();
+                       if (!name.EndsWith (".xml"))
+                               name = name + ".xml";
+                       var uri = new Uri (asm.CodeBase);
+                       var path = Path.GetDirectoryName (uri.AbsolutePath);
+                       path = Path.Combine (path, "Test");
+                       path = Path.Combine (path, "MetadataTests");
+                       path = Path.Combine (path, "Resources");
+                       var filename = Path.Combine (path, name);
+                       using (var stream = new StreamReader (filename)) {
+                               var reader = new XmlTextReader (stream);
+                               return MetadataSet.ReadFrom (reader);
+                       }
+               }
+
+               internal static MetadataSet LoadMetadataFromResource (string name)
+               {
+                       var asm = Assembly.GetExecutingAssembly ();
+                       if (!name.EndsWith (".xml"))
+                               name = name + ".xml";
+                       
+                       var resname = "MetadataTests.Resources." + name;
+                       using (var stream = asm.GetManifestResourceStream (resname)) {
+                               if (stream == null)
+                                       throw new InvalidOperationException (
+                                               "No such resource: " + name);
+                               var reader = new XmlTextReader (stream);
+                               return MetadataSet.ReadFrom (reader);
+                       }
+               }
+               
+               internal static void SaveMetadataToFile (string name, MetadataSet metadata)
+               {
+                       var filename = name + ".xml";
+                       if (File.Exists (filename))
+                               return;
+
+                       using (var file = new StreamWriter (filename, false)) {
+                               var writer = new XmlTextWriter (file);
+                               writer.Formatting = Formatting.Indented;
+                               metadata.WriteTo (writer);
+                       }
+
+                       Console.WriteLine ("Exported {0}.", filename);
+               }
+       }
+}
+
diff --git a/mcs/class/System.ServiceModel/Test/MetadataTests/TestLabel.cs b/mcs/class/System.ServiceModel/Test/MetadataTests/TestLabel.cs
new file mode 100644 (file)
index 0000000..76bd1ff
--- /dev/null
@@ -0,0 +1,138 @@
+//
+// TestLabel.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2012 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using System.Text;
+using System.Collections.Generic;
+
+namespace MonoTests.System.ServiceModel.MetadataTests {
+
+       public class TestLabel {
+
+               List<Scope> scopes;
+               string delimiter;
+               Style defaultStyle;
+
+               public enum Style {
+                       Letter,
+                       Number,
+                       HexNumer
+               }
+
+               public TestLabel (string prefix)
+                       : this (prefix, ".", Style.Letter)
+               {
+               }
+
+               public TestLabel (string prefix, string delimiter, Style style)
+               {
+                       if ((prefix == null) || (prefix.Equals (string.Empty)))
+                               throw new ArgumentException ("Cannot be null or empty.", "prefix");
+                       if (delimiter == null)
+                               throw new ArgumentNullException ("delimiter");
+
+                       scopes = new List<Scope> ();
+                       scopes.Add (new Scope (prefix, style));
+
+                       this.delimiter = delimiter;
+                       this.defaultStyle = style;
+               }
+
+               class Scope {
+                       public readonly string Text;
+                       public readonly Style Style;
+                       int id;
+
+                       public Scope (string text, Style style)
+                       {
+                               this.Text = text;
+                               this.Style = style;
+                               this.id = 0;
+                       }
+
+                       public int GetID ()
+                       {
+                               return ++id;
+                       }
+               }
+
+               public void EnterScope (string scope)
+               {
+                       scopes.Add (new Scope (scope, defaultStyle));
+               }
+
+               public void LeaveScope ()
+               {
+                       if (scopes.Count <= 1)
+                               throw new InvalidOperationException ();
+                       scopes.RemoveAt (scopes.Count - 1);
+               }
+
+               public string Get ()
+               {
+                       var sb = new StringBuilder ();
+                       for (int i = 0; i < scopes.Count; i++) {
+                               sb.Append (scopes [i].Text);
+                               sb.Append (delimiter);
+                       }
+
+                       var scope = scopes [scopes.Count - 1];
+                       var id = scope.GetID ();
+
+                       switch (scope.Style) {
+                       case Style.Letter:
+                               if (id <= 26)
+                                       sb.Append ((char)('a' + id - 1));
+                               else
+                                       goto case Style.Number;
+                               break;
+
+                       case Style.Number:
+                               sb.Append (id);
+                               break;
+
+                       case Style.HexNumer:
+                               sb.AppendFormat ("{0:x2}", id);
+                               break;
+                       }
+
+                       return sb.ToString ();
+               }
+
+               public override string ToString ()
+               {
+                       var sb = new StringBuilder ();
+                       sb.Append ("[");
+                       for (int i = 0; i < scopes.Count; i++) {
+                               if (i > 0)
+                                       sb.Append (delimiter);
+                               sb.Append (scopes [i].Text);
+                       }
+                       sb.Append ("]");
+                       return sb.ToString ();
+               }
+       }
+}
+