public WebServiceDiscoveryResultWCF(DiscoveryClientProtocol protocol, MetadataSet metadata, WebReferenceItem item, ReferenceGroup refGroup, ClientOptions defaultOptions) : base(WebReferencesService.WcfEngine, item) { this.refGroup = refGroup; this.protocol = protocol; this.metadata = metadata; this.defaultOptions = defaultOptions; }
public WebServiceDiscoveryResultWCF (DiscoveryClientProtocol protocol, MetadataSet metadata, WebReferenceItem item, ReferenceGroup refGroup, ClientOptions defaultOptions): base (WebReferencesService.WcfEngine, item) { this.refGroup = refGroup; this.protocol = protocol; this.metadata = metadata; this.defaultOptions = defaultOptions; }
public override WebServiceDiscoveryResult Load (WebReferenceItem item) { FilePath basePath = item.MapFile.FilePath.ParentDirectory; ReferenceGroup resfile = ReferenceGroup.Read (item.MapFile.FilePath); // TODO: Read as MetadataSet DiscoveryClientProtocol protocol = new DiscoveryClientProtocol (); foreach (MetadataFile dcr in resfile.Metadata) { DiscoveryReference dr; switch (dcr.MetadataType) { case "Wsdl": dr = new System.Web.Services.Discovery.ContractReference (); break; case "Disco": dr = new System.Web.Services.Discovery.DiscoveryDocumentReference (); break; case "Schema": dr = new System.Web.Services.Discovery.SchemaReference (); break; default: continue; } dr.Url = dcr.SourceUrl; FileStream fs = new FileStream (basePath.Combine (dcr.FileName), FileMode.Open, FileAccess.Read); protocol.Documents.Add (dr.Url, dr.ReadDocument (fs)); fs.Close (); protocol.References.Add (dr.Url, dr); } return new WebServiceDiscoveryResultWCF (protocol, null, item, resfile); }
ReferenceGroup ConvertMapFile(string mapFile) { DiscoveryClientResultCollection files; using (var prot = new DiscoveryClientProtocol()) files = prot.ReadAll(mapFile); var map = new ReferenceGroup(); if (refGroup != null) { map.ClientOptions = refGroup.ClientOptions; map.ID = refGroup.ID; } else { map.ClientOptions = defaultOptions; map.ID = Guid.NewGuid().ToString(); } var sources = new Dictionary <string, int> (); foreach (DiscoveryClientResult res in files) { string url = res.Url; var uri = new Uri(url); if (!string.IsNullOrEmpty(uri.Query)) { url = url.Substring(0, url.Length - uri.Query.Length); } int nSource; if (!sources.TryGetValue(url, out nSource)) { nSource = sources.Count + 1; sources [url] = nSource; var ms = new MetadataSource(); ms.Address = url; ms.Protocol = uri.Scheme; ms.SourceId = nSource.ToString(); map.MetadataSources.Add(ms); } var file = new MetadataFile(); file.FileName = res.Filename; file.ID = Guid.NewGuid().ToString(); file.SourceId = nSource.ToString(); file.SourceUrl = res.Url; switch (Path.GetExtension(file.FileName).ToLower()) { case ".disco": file.MetadataType = "Disco"; break; case ".wsdl": file.MetadataType = "Wsdl"; break; case ".xsd": file.MetadataType = "Schema"; break; } map.Metadata.Add(file); } map.Save(mapFile); return(map); }
public override string GetServiceURL() { ReferenceGroup resfile = ReferenceGroup.Read(Item.MapFile.FilePath); if (resfile.MetadataSources.Count == 0) { return(null); } return(resfile.MetadataSources [0].Address); }
protected override string GenerateDescriptionFiles(DotNetProject project, FilePath basePath) { if (!project.Items.GetAll <WCFMetadata> ().Any()) { WCFMetadata met = new WCFMetadata(); met.Path = basePath.ParentDirectory; project.Items.Add(met); } WCFMetadataStorage metStor = project.Items.GetAll <WCFMetadataStorage> ().FirstOrDefault(m => m.Path.CanonicalPath == basePath); if (metStor == null) { project.Items.Add(new WCFMetadataStorage() { Path = basePath }); } string file = Path.Combine(basePath, "Reference.svcmap"); if (protocol != null) { protocol.ResolveAll(); protocol.WriteAll(basePath, "Reference.svcmap"); refGroup = ConvertMapFile(file); } else { // TODO ReferenceGroup map = new ReferenceGroup(); map.ClientOptions = InitialClientOptions; map.Save(file); map.ID = Guid.NewGuid().ToString(); refGroup = map; } foreach (MetadataFile mfile in refGroup.Metadata) { project.AddFile(new FilePath(mfile.FileName).ToAbsolute(basePath), BuildAction.None); } return(file); }
public override void Update() { ReferenceGroup resfile = ReferenceGroup.Read(Item.MapFile.FilePath); if (resfile.MetadataSources.Count == 0) { return; } string url = resfile.MetadataSources [0].Address; WebServiceDiscoveryResultWCF wref = (WebServiceDiscoveryResultWCF)WebReferencesService.WcfEngine.Discover(url); if (wref == null) { return; } metadata = wref.metadata; protocol = wref.protocol; GenerateFiles(Item.Project, Item.MapFile.Project.Name, Item.Name); }
protected override string GenerateDescriptionFiles (DotNetProject dotNetProject, FilePath basePath) { if (!dotNetProject.Items.GetAll<WCFMetadata> ().Any ()) { var met = new WCFMetadata (); met.Path = basePath.ParentDirectory; dotNetProject.Items.Add (met); } WCFMetadataStorage metStor = dotNetProject.Items.GetAll<WCFMetadataStorage> ().FirstOrDefault (m => m.Path.CanonicalPath == basePath); if (metStor == null) dotNetProject.Items.Add (new WCFMetadataStorage { Path = basePath }); string file = Path.Combine (basePath, "Reference.svcmap"); if (protocol != null) { protocol.ResolveAll (); protocol.WriteAll (basePath, "Reference.svcmap"); refGroup = ConvertMapFile (file); } else { // TODO var map = new ReferenceGroup (); map.ClientOptions = defaultOptions; map.Save (file); map.ID = Guid.NewGuid ().ToString (); refGroup = map; } foreach (MetadataFile mfile in refGroup.Metadata) dotNetProject.AddFile (new FilePath (mfile.FileName).ToAbsolute (basePath), BuildAction.None); return file; }
ReferenceGroup ConvertMapFile (string mapFile) { DiscoveryClientResultCollection files; using (var prot = new DiscoveryClientProtocol ()) files = prot.ReadAll (mapFile); var map = new ReferenceGroup (); if (refGroup != null) { map.ClientOptions = refGroup.ClientOptions; map.ID = refGroup.ID; } else { map.ClientOptions = defaultOptions; map.ID = Guid.NewGuid ().ToString (); } var sources = new Dictionary<string, int> (); foreach (DiscoveryClientResult res in files) { string url = res.Url; var uri = new Uri (url); if (!string.IsNullOrEmpty (uri.Query)) url = url.Substring (0, url.Length - uri.Query.Length); int nSource; if (!sources.TryGetValue (url, out nSource)) { nSource = sources.Count + 1; sources [url] = nSource; var ms = new MetadataSource (); ms.Address = url; ms.Protocol = uri.Scheme; ms.SourceId = nSource.ToString (); map.MetadataSources.Add (ms); } var file = new MetadataFile (); file.FileName = res.Filename; file.ID = Guid.NewGuid ().ToString (); file.SourceId = nSource.ToString (); file.SourceUrl = res.Url; switch (Path.GetExtension (file.FileName).ToLower ()) { case ".disco": file.MetadataType = "Disco"; break; case ".wsdl": file.MetadataType = "Wsdl"; break; case ".xsd": file.MetadataType = "Schema"; break; } map.Metadata.Add (file); } map.Save (mapFile); return map; }