Beispiel #1
1
		public Binding ()
		{
			extensions = new ServiceDescriptionFormatExtensionCollection (this);
			operations = new OperationBindingCollection (this);
			serviceDescription = null;
			type = XmlQualifiedName.Empty;
		}
Beispiel #2
0
		public Import ()
		{
			extensions = new ServiceDescriptionFormatExtensionCollection (this);
			location = String.Empty;
			ns = String.Empty;
			serviceDescription = null;
		}
		public static bool CheckConformance (WsiClaims claims, ServiceDescription service, BasicProfileViolationCollection violations)
		{
			ServiceDescriptionCollection col = new ServiceDescriptionCollection ();
			col.Add (service);
			ConformanceCheckContext ctx = new ConformanceCheckContext (col, violations);
			return Check (claims, ctx, col);
		}
		public void SetUpFixture()
		{
			project = WebReferenceTestHelper.CreateTestProject("C#");
			project.FileName = FileName.Create("C:\\projects\\test\\foo.csproj");

			protocol = new DiscoveryClientProtocol();
			DiscoveryDocumentReference discoveryRef = new DiscoveryDocumentReference();
			discoveryRef.Url = updateFromUrl;
			protocol.References.Add(discoveryRef);
			
			ContractReference contractRef = new ContractReference();
			contractRef.Url = "http://localhost/test.asmx?wsdl";
			contractRef.ClientProtocol = new DiscoveryClientProtocol();
			ServiceDescription desc = new ServiceDescription();
			contractRef.ClientProtocol.Documents.Add(contractRef.Url, desc);
			protocol.References.Add(contractRef);
			
			WebReferenceTestHelper.InitializeProjectBindings();
			
			webReference = new SD.WebReference(project, updateFromUrl, name, proxyNamespace, protocol);
			
			webReferenceUrl = webReference.WebReferenceUrl;
			discoFileProjectItem = WebReferenceTestHelper.GetFileProjectItem(webReference.Items, "Web References\\localhost\\test.disco", ItemType.None);
			referenceMapFileProjectItem = WebReferenceTestHelper.GetFileProjectItem(webReference.Items, "Web References\\localhost\\Reference.map", ItemType.None);
			wsdlFileProjectItem = WebReferenceTestHelper.GetFileProjectItem(webReference.Items, "Web References\\localhost\\test.wsdl", ItemType.None); 
			proxyFileProjectItem = WebReferenceTestHelper.GetFileProjectItem(webReference.Items, "Web References\\localhost\\Reference.cs", ItemType.Compile);
			webReferencesProjectItem = (WebReferencesProjectItem)WebReferenceTestHelper.GetProjectItem(webReference.Items, "Web References\\", ItemType.WebReferences);
			webServicesReferenceProjectItem = (ReferenceProjectItem)WebReferenceTestHelper.GetProjectItem(webReference.Items, ItemType.Reference);
		}
        private static WsdlNS.ServiceDescription GetSingleWsdl(List<WsdlNS.ServiceDescription> wsdls)
        {
            // Use WSDL that has the contracts as the base for single WSDL
            WsdlNS.ServiceDescription singleWsdl = wsdls.First(wsdl => wsdl.PortTypes.Count > 0);
            if (singleWsdl == null)
            {
                singleWsdl = new WsdlNS.ServiceDescription();
            }
            else
            {
                singleWsdl.Types.Schemas.Clear();
                singleWsdl.Imports.Clear();
            }

            Dictionary<XmlQualifiedName, XmlQualifiedName> bindingReferenceChanges = new Dictionary<XmlQualifiedName, XmlQualifiedName>();
            foreach (WsdlNS.ServiceDescription wsdl in wsdls)
            {
                if (wsdl != singleWsdl)
                {
                    MergeWsdl(singleWsdl, wsdl, bindingReferenceChanges);
                }              
            }

            EnsureSingleNamespace(singleWsdl, bindingReferenceChanges);
            return singleWsdl;
        }
		public override void FixtureSetUp()
		{
			base.FixtureSetUp();
			project = WebReferenceTestHelper.CreateTestProject("C#");
			project.FileName = FileName.Create("C:\\projects\\test\\foo.csproj");

			protocol = new DiscoveryClientProtocol();
			DiscoveryDocumentReference discoveryRef = new DiscoveryDocumentReference();
			discoveryRef.Url = updateFromUrl;
			protocol.References.Add(discoveryRef);
			
			ContractReference contractRef = new ContractReference();
			contractRef.Url = "http://localhost/test.asmx?wsdl";
			contractRef.ClientProtocol = new DiscoveryClientProtocol();
			ServiceDescription desc = new ServiceDescription();
			contractRef.ClientProtocol.Documents.Add(contractRef.Url, desc);
			protocol.References.Add(contractRef);
			
			WebReferenceTestHelper.InitializeProjectBindings();
			
			webReference = new Gui.WebReference(project, updateFromUrl, name, proxyNamespace, protocol);
			
			foreach (ProjectItem item in webReference.Items) {
				ProjectService.AddProjectItem(project, item);
			}
			webReferencesProjectItem = webReference.WebReferencesProjectItem;
		}
 private static Binding GetSoapBinding(ServiceDescription description, string bindingName)
 {
     var soapBindings = description.GetSoapBindings()
         .Where(binding => binding.Name == bindingName)
         .OrderByDescending(binding => binding.Type.Name);
     return soapBindings.FirstOrDefault();
 }
		public override void FixtureSetUp()
		{
			base.FixtureSetUp();
			project = WebReferenceTestHelper.CreateTestProject("C#");
			WebReferencesProjectItem item = new WebReferencesProjectItem(project);
			item.Include = "Web References\\";
			ProjectService.AddProjectItem(project, item);

			protocol = new DiscoveryClientProtocol();
			DiscoveryDocumentReference discoveryRef = new DiscoveryDocumentReference();
			discoveryRef.Url = updateFromUrl;
			protocol.References.Add(discoveryRef);

			ContractReference contractRef = new ContractReference();
			contractRef.Url = "http://localhost/test.asmx?wsdl";
			contractRef.ClientProtocol = new DiscoveryClientProtocol();
			ServiceDescription desc = new ServiceDescription();
			contractRef.ClientProtocol.Documents.Add(contractRef.Url, desc);
			protocol.References.Add(contractRef);

			WebReferenceTestHelper.InitializeProjectBindings();

			webReference = new Gui.WebReference(project, updateFromUrl, name, proxyNamespace, protocol);
			webReferencesProjectItem = WebReferenceTestHelper.GetProjectItem(webReference.Items, "Web References\\", ItemType.WebReferences);
		}
		public int Add (ServiceDescription serviceDescription) 
		{
			if (importer != null)
				importer.OnServiceDescriptionAdded (serviceDescription, null, null);
			Insert (Count, serviceDescription);
			return (Count - 1);
		}
		public void SetUpFixture()
		{
			project = WebReferenceTestHelper.CreateTestProject("C#");
			project.FileName = "C:\\projects\\test\\foo.csproj";
			
			ReferenceProjectItem referenceItem = new ReferenceProjectItem(project, "System.Web.Services");
			ProjectService.AddProjectItem(project, referenceItem);
			
			protocol = new DiscoveryClientProtocol();
			DiscoveryDocumentReference discoveryRef = new DiscoveryDocumentReference();
			discoveryRef.Url = updateFromUrl;
			protocol.References.Add(discoveryRef);
			
			ContractReference contractRef = new ContractReference();
			contractRef.Url = "http://localhost/test.asmx?wsdl";
			contractRef.ClientProtocol = new DiscoveryClientProtocol();
			ServiceDescription desc = new ServiceDescription();
			contractRef.ClientProtocol.Documents.Add(contractRef.Url, desc);
			protocol.References.Add(contractRef);
			
			WebReferenceTestHelper.InitializeLanguageBindings();
			
			webReference = new SD.WebReference(project, updateFromUrl, name, proxyNamespace, protocol);
			webServicesReferenceProjectItem = (ReferenceProjectItem)WebReferenceTestHelper.GetProjectItem(webReference.Items, ItemType.Reference);
		}
    public SoapEditorProxy(Connections.ConnectionData connData, ServiceDescription description, XmlSchemaSet schemas)
    {
      _connData = connData;
      _descrip = description;
      _schemas = schemas;
      _helper = new XmlCompletionDataProvider(schemas, "http://schemas.xmlsoap.org/soap/envelope/"
        , "soapenv", () => "xmlns:soap=\"" + description.TargetNamespace + "\""
        , e => (e.Name == "Envelope" && e.QualifiedName.Namespace == "http://schemas.xmlsoap.org/soap/envelope/")
          || TypeMatchesAction(e.QualifiedName, this.Action));

      _baseUrl = new Uri(_connData.Url).GetLeftPart(UriPartial.Path);
      switch (_connData.Authentication)
      {
        case Connections.Authentication.Windows:
          _cred = CredentialCache.DefaultNetworkCredentials;
          break;
        case Connections.Authentication.Explicit:
          _cred = new NetworkCredential(_connData.UserName, _connData.Password);
          break;
      }

      _actionUrls = _descrip.Services.OfType<Service>()
        .SelectMany(s => s.Ports.OfType<Port>().Where(SoapPort))
        .SelectMany(p => _descrip.Bindings[p.Binding.Name].Operations.OfType<OperationBinding>())
        .Select(o => new { Name = o.Name, Address = o.Extensions.OfType<SoapOperationBinding>().First().SoapAction })
        .Distinct()
        .ToDictionary(a => a.Name, a => a.Address);
    }
		public override void FixtureSetUp()
		{
			base.FixtureSetUp();
			// Set up the project.
			MSBuildBasedProject project = WebReferenceTestHelper.CreateTestProject("C#");
			project.FileName = FileName.Create("c:\\projects\\test\\foo.csproj");
			
			// Web references item.
			WebReferencesProjectItem webReferencesItem = new WebReferencesProjectItem(project);
			webReferencesItem.Include = "Web References\\";
			ProjectService.AddProjectItem(project, webReferencesItem);
			
			// Web reference url.
			WebReferenceUrl webReferenceUrl = new WebReferenceUrl(project);
			webReferenceUrl.Include = "http://localhost/test.asmx";
			webReferenceUrl.UpdateFromURL = "http://localhost/test.asmx";
			webReferenceUrl.RelPath = "Web References\\localhost";
			ProjectService.AddProjectItem(project, webReferenceUrl);
			
			FileProjectItem discoFileItem = new FileProjectItem(project, ItemType.None);
			discoFileItem.Include = "Web References\\localhost\\test.disco";
			ProjectService.AddProjectItem(project, discoFileItem);

			FileProjectItem wsdlFileItem = new FileProjectItem(project, ItemType.None);
			wsdlFileItem.Include = "Web References\\localhost\\test.wsdl";
			ProjectService.AddProjectItem(project, wsdlFileItem);
			
			// Proxy
			FileProjectItem proxyItem = new FileProjectItem(project, ItemType.Compile);
			proxyItem.Include = "Web References\\localhost\\Reference.cs";
			proxyItem.DependentUpon = "Reference.map";
			ProjectService.AddProjectItem(project, proxyItem);
			
			// Reference map.
			FileProjectItem mapItem = new FileProjectItem(project, ItemType.None);
			mapItem.Include = "Web References\\localhost\\Reference.map";
			ProjectService.AddProjectItem(project, mapItem);
			
			// System.Web.Services reference.
			ReferenceProjectItem webServicesReferenceItem = new ReferenceProjectItem(project, "System.Web.Services");
			ProjectService.AddProjectItem(project, webServicesReferenceItem);
			
			// Set up the web reference.
			DiscoveryClientProtocol	protocol = new DiscoveryClientProtocol();
			DiscoveryDocumentReference discoveryRef = new DiscoveryDocumentReference();
			discoveryRef.Url = "http://localhost/new.asmx";
			protocol.References.Add(discoveryRef);
			
			ContractReference contractRef = new ContractReference();
			contractRef.Url = "http://localhost/new.asmx?wsdl";
			contractRef.ClientProtocol = new DiscoveryClientProtocol();
			ServiceDescription desc = new ServiceDescription();
			contractRef.ClientProtocol.Documents.Add(contractRef.Url, desc);
			protocol.References.Add(contractRef);
			
			WebReferenceTestHelper.InitializeProjectBindings();
			
			var webReference = new Gui.WebReference(project, "http://localhost/new.asmx", "localhost", "ProxyNamespace", protocol);
			changes = webReference.GetChanges(project);
		}
Beispiel #13
0
        /// <summary>
        /// Generate a DPWSClientProxy source file from a wsdl service description.
        /// </summary>
        /// <param name="serviceDesc">A valid wsdl service description.</param>
        public void GenerateClientProxy(ServiceDescription serviceDesc, TargetPlatform platform)
        {
            // Well here's a nasty used in an attempt to make up a name
            string clientProxyClassName = serviceDesc.Name;
            string clientProxyNs = CodeGenUtils.GenerateDotNetNamespace(serviceDesc.TargetNamespace);
            string filename = serviceDesc.Name + "ClientProxy.cs";

            ClientProxies clientProxies = new ClientProxies(clientProxyNs);

            foreach (PortType portType in serviceDesc.PortTypes)
            {
                ClientProxy clientProxy = new ClientProxy(portType.Name, platform);
                foreach (Operation operation in portType.Operations)
                {
                    // Create action names
                    // Apply special naming rules if this is a notification (event) operation
                    string inAction = serviceDesc.TargetNamespace + "/" + operation.Name + "Request";
                    string outAction = serviceDesc.TargetNamespace + "/" + operation.Name + ((operation.Messages.Flow == OperationFlow.Notification) ? "" : "Response");
                    clientProxy.AddOperation(operation, inAction, outAction);
                }

                foreach (Message message in serviceDesc.Messages)
                {
                    clientProxy.Messages.Add(message);
                }

                if (clientProxy.ServiceOperations.Count > 0)
                    clientProxies.Add(clientProxy);
            }

            ClientProxyGenerator clientProxyGen = new ClientProxyGenerator();
            clientProxyGen.GenerateCode(filename, clientProxies);
        }
Beispiel #14
0
        /// <summary>
        /// Generate a DPWSHostedService source file from a Wsdl service description.
        /// </summary>
        /// <param name="serviceDesc">A valid wsdl service description.</param>
        public void GenerateHostedService(ServiceDescription serviceDesc, TargetPlatform platform)
        {
            // Well here's a nasty used in an attempt to make up a name
            string hostedServiceClassName = serviceDesc.Name;
            string hostedServiceNs = CodeGenUtils.GenerateDotNetNamespace(serviceDesc.TargetNamespace);
            string filename = serviceDesc.Name + "HostedService.cs";

            HostedServices hostedServices = new HostedServices(hostedServiceNs);

            foreach (PortType portType in serviceDesc.PortTypes)
            {
                HostedService hostedService = new HostedService(portType.Name, hostedServiceNs, platform);
                foreach (Operation operation in portType.Operations)
                {
                    // Create action names
                    // Apply special naming rules if this is a notification (event) operation
                    string inAction = serviceDesc.TargetNamespace + "/" + operation.Name + "Request";
                    string outAction = serviceDesc.TargetNamespace + "/" + operation.Name + ((operation.Messages.Flow == OperationFlow.Notification) ? "" : "Response");
                    hostedService.AddOperation(operation, inAction, outAction);
                }

                foreach (Message message in serviceDesc.Messages)
                {
                    hostedService.Messages.Add(message);
                }
            }

            HostedServiceGenerator hostedServiceGen = new HostedServiceGenerator();
            hostedServiceGen.GenerateCode(filename, hostedServices);
        }
Beispiel #15
0
        /// <summary>
        /// Open specified Wsdl file and parse content into ServiceDescription hierarchy. Method attempts
        /// to Import external schema references.
        /// </summary>
        /// <param name="fileName">A valid Wsdl file name.</param>
        /// <exception cref="FileNotFoundException">If specified file is cannot be opened.</exception>
        public void ParseWsdl(string fileName, List<string> schemaRefs)
        {
            isParsing = true;
            Logger.WriteLine("Reading WSDL file: " + fileName, LogLevel.Normal);

            // Use a validating xml reader to validate the schema. If it checks out
            // we only have to worry about building code fragements and data contracts.
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ValidationType = ValidationType.Schema;
            settings.ValidationFlags = XmlSchemaValidationFlags.AllowXmlAttributes |
                XmlSchemaValidationFlags.ProcessIdentityConstraints |
                XmlSchemaValidationFlags.ProcessInlineSchema |
                XmlSchemaValidationFlags.ProcessSchemaLocation |
                XmlSchemaValidationFlags.ReportValidationWarnings;

            // Create the reader
            settings.ValidationEventHandler += new ValidationEventHandler(Settings_ValidationEventHandler);

            XmlReader reader = XmlReader.Create(fileName, settings);

            if (!ServiceDescription.CanRead(reader)) throw new InvalidOperationException("The WSDL file is not compatible.");

            // Parse the Wsdl
            m_svcDesc = ServiceDescription.Read(reader, true);
            reader.Close();

            List<string> importFiles = new List<string>();
            importFiles.Add(fileName);

            ParseWsdl(m_svcDesc, schemaRefs, settings, importFiles);
        }
		internal int Add (ServiceDescription serviceDescription, string appSettingUrlKey, string appSettingBaseUrl)
		{
			if (importer != null)
				importer.OnServiceDescriptionAdded (serviceDescription, appSettingUrlKey, appSettingBaseUrl);
			Insert (Count, serviceDescription);
			return (Count - 1);
		}
Beispiel #17
0
		public PortType ()
		{
			operations = new OperationCollection (this);
			serviceDescription = null;
#if NET_2_0
			extensions = new ServiceDescriptionFormatExtensionCollection (this);
#endif
		}
		public Message ()
		{
#if !NET_2_0
			name = String.Empty;
#endif
			parts = new MessagePartCollection (this);
			serviceDescription = null;
		}
 public Schema Build(ServiceDescription description, string bindingName, Assembly assembly)
 {
     var binding = GetSoapBinding(description, bindingName);
     var serviceType = GetServiceType(binding, assembly);
     return new Schema {
         TypeName = serviceType.Name,
         Entities = BuildEntities(serviceType, binding)
     };
 }
		public Service ()
		{
			extensions = new ServiceDescriptionFormatExtensionCollection (this);
#if !NET_2_0
			name = String.Empty;
#endif
			ports = new PortCollection (this);
			serviceDescription = null;
		}
		CodeNamespace GenerateCodeFromWsdl (ServiceDescription sd)
		{
			ServiceDescriptionImporter imp =
				new ServiceDescriptionImporter ();
			imp.AddServiceDescription (sd, null, null);
			CodeNamespace cns = new CodeNamespace ();
			imp.Import (cns, null);
			return cns;
		}
Beispiel #22
0
		public Binding ()
		{
			extensions = new ServiceDescriptionFormatExtensionCollection (this);
#if !NET_2_0
			name = String.Empty;
#endif
			operations = new OperationBindingCollection (this);
			serviceDescription = null;
			type = XmlQualifiedName.Empty;
		}
		public void TestAddServiceDescriptionWithoutTargetNS ()
		{
			const string serviceDescriptionNamespace = "testServiceDescription";
			
			ServiceDescription sd = new ServiceDescription ();	
			sdc.Add (sd);

			Assertion.AssertEquals (1, sdc.Count);
			Assertion.AssertNull (sdc[serviceDescriptionNamespace]);
		}
Beispiel #24
0
		public Message ()
		{
#if !NET_2_0
			name = String.Empty;
#endif
#if NET_2_0
			extensions = new ServiceDescriptionFormatExtensionCollection (this);
#endif
			parts = new MessagePartCollection (this);
			serviceDescription = null;
		}
		public void TestAddServiceDescriptionWithTargetNS ()
		{
			const string serviceDescriptionNamespace = "http://some.urn";
			
			ServiceDescription sd = new ServiceDescription ();
			sd.TargetNamespace = serviceDescriptionNamespace;
			
			sdc.Add (sd);

			Assertion.AssertEquals (1, sdc.Count);
			Assertion.AssertEquals (sd, sdc[serviceDescriptionNamespace]);
		}
Beispiel #26
0
        /// <summary>
        /// Merge WSDL and XSD in filename and write it to destination
        /// </summary>
        /// <param name="first"></param>
        /// <param name="second"></param>
        public static ServiceDescription Merge(ServiceDescription firstWsdl, ServiceDescription secondWsdl)
        {
            foreach (XmlSchema xmlSchema in secondWsdl.Types.Schemas)
            {
                foreach (var include in xmlSchema.Includes.OfType<XmlSchemaImport>())
                {
                    var ns = include.Namespace;
                    var uri = include.SchemaLocation;

                    var firstSchema = firstWsdl.Types.Schemas.OfType<XmlSchema>().First();
                    if (!firstSchema.Includes.OfType<XmlSchemaImport>().Any(x => x.Namespace == ns && x.SchemaLocation == uri))
                    {
                        firstSchema.Includes.Add(include);
                    }
                }
            }

            foreach (Message message in secondWsdl.Messages)
            {
                if (firstWsdl.Messages.OfType<Message>().All(m => m.Name != message.Name))
                {
                    firstWsdl.Messages.Add(message);
                }
            }

            foreach (PortType portType in secondWsdl.PortTypes)
            {
                if (firstWsdl.PortTypes.OfType<PortType>().All(m => m.Name != portType.Name))
                {
                    firstWsdl.PortTypes.Add(portType);
                }
            }

            foreach (Binding binding in secondWsdl.Bindings)
            {
                if (firstWsdl.Bindings.OfType<Binding>().All(m => m.Name != binding.Name))
                {
                    firstWsdl.Bindings.Add(binding);
                }
            }

            foreach (Service service in secondWsdl.Services)
            {
                if (firstWsdl.Services.OfType<Service>().All(m => m.Name != service.Name))
                {
                    firstWsdl.Services.Add(service);
                }
            }

            return firstWsdl;
        }
        public void GetServiceDescription_Returns_TheServiceDescription()
        {
            // Arrange.
            const string Url = "http://www.example.com/TestService.svc";
            const string Username = "Test User";
            const string Password = "Test Password";

            Mock.Arrange(() => Arg.IsAny<DiscoveryClientProtocol>().DiscoverAny(Url)).DoNothing();
            Mock.Arrange(() => Arg.IsAny<DiscoveryClientProtocol>().ResolveAll()).DoNothing();

            var contract1 = new ServiceDescription();
            var contractReference1 = Mock.Create<ContractReference>(Behavior.Loose);
            Mock.Arrange(() => contractReference1.Contract).Returns(contract1);
            Mock.Arrange(() => contractReference1.Url).Returns("contract1");

            var contract2 = new ServiceDescription();
            var contractReference2 = Mock.Create<ContractReference>(Behavior.Loose);
            Mock.Arrange(() => contractReference2.Contract).Returns(contract2);
            Mock.Arrange(() => contractReference2.Url).Returns("contract2");
            
            var schema1 = new XmlSchema();
            var schemaReference1 = Mock.Create<SchemaReference>(Behavior.Loose);
            Mock.Arrange(() => schemaReference1.Schema).Returns(schema1);
            Mock.Arrange(() => schemaReference1.Url).Returns("schema1");
            
            var schema2 = new XmlSchema();
            var schemaReference2 = Mock.Create<SchemaReference>(Behavior.Loose);
            Mock.Arrange(() => schemaReference2.Schema).Returns(schema2);
            Mock.Arrange(() => schemaReference2.Url).Returns("schema2");

            var references = new DiscoveryClientReferenceCollection { contractReference1, contractReference2, schemaReference1, schemaReference2 };
            Mock.Arrange(() => Arg.IsAny<DiscoveryClientProtocol>().References).Returns(references);

            var retriever = new WebServiceDescriptionRetriever();

            // Act.
            var serviceDescription = retriever.GetServiceDescription(Url, Username, Password);

            // Assert.
            Mock.Assert(() => Arg.IsAny<DiscoveryClientProtocol>().DiscoverAny(Url), Occurs.Once());
            Mock.Assert(() => Arg.IsAny<DiscoveryClientProtocol>().ResolveAll(), Occurs.Once());

            Assert.IsNotNull(serviceDescription);
            Assert.AreEqual(2, serviceDescription.ServiceDescriptions.Count);
            Assert.IsTrue(serviceDescription.ServiceDescriptions.Contains(contract1));
            Assert.IsTrue(serviceDescription.ServiceDescriptions.Contains(contract2));
            
            Assert.AreEqual(2, serviceDescription.XmlSchemas.Count);
            Assert.IsTrue(serviceDescription.XmlSchemas.Contains(schema1));
            Assert.IsTrue(serviceDescription.XmlSchemas.Contains(schema2));
        }
		public void Ctor ()
		{
			ServiceDescription sd = new ServiceDescription ();
			Assert.IsNotNull (sd.Bindings);
			Assert.IsNotNull (sd.Extensions);
			Assert.IsNotNull (sd.Imports);
			Assert.IsNotNull (sd.Messages);
			Assert.IsNotNull (sd.PortTypes);
			Assert.IsNotNull (sd.Services);
			Assert.IsNotNull (sd.Types);

			Assert.IsNull (sd.ServiceDescriptions);
			Assert.IsNull (sd.TargetNamespace);
		}
 public static string GetServiceName(ServiceDescription description)
 {
     if (description.Name != null) {
         return description.Name;
     } else if (!String.IsNullOrEmpty(description.RetrievalUrl)) {
         Uri uri = new Uri(description.RetrievalUrl);
         if (uri.Segments.Length > 0) {
             return uri.Segments[uri.Segments.Length - 1];
         } else {
             return uri.Host;
         }
     }
     return String.Empty;
 }
		/// <summary>Read the service description for a specified uri.</summary>
		/// <param name="uri">A string containing the unique reference identifier for the service.</param>
		/// <returns>A ServiceDescription for the specified uri.</returns>
		public static ServiceDescription ReadServiceDescription(string uri) 
		{
			ServiceDescription desc = new ServiceDescription();
			try 
			{
				HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
				WebResponse response  = request.GetResponse();
			
				desc = ServiceDescription.Read(response.GetResponseStream());
				response.Close();
				desc.RetrievalUrl = uri;
			} 
			catch (Exception) {} 
			
			return desc;
		}