本文整理汇总了C#中System.Web.Services.Discovery.DiscoveryClientProtocol类的典型用法代码示例。如果您正苦于以下问题:C# DiscoveryClientProtocol类的具体用法?C# DiscoveryClientProtocol怎么用?C# DiscoveryClientProtocol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DiscoveryClientProtocol类属于System.Web.Services.Discovery命名空间,在下文中一共展示了DiscoveryClientProtocol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FixtureSetUp
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;
}
示例2: SetUpFixture
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);
}
示例3: DownloadFile
//MetadataExchangeClient can only download data from a local wsdl file, if it is a file we user the DiscoveryClientProtocol
void DownloadFile(out List<wsdlDescription.ServiceDescription> descriptions, out List<XmlSchema> schemas)
{
descriptions = new List<wsdlDescription.ServiceDescription>();
schemas = new List<XmlSchema>();
DiscoveryClientProtocol client = new DiscoveryClientProtocol();
//download document
client.AllowAutoRedirect = true;
client.Timeout = _timeoutInSeconds * 1000;
client.Documents.Clear();
client.DiscoverAny(_wsdlEndpoint);
client.ResolveAll();
foreach (var v in client.Documents.Values) {
if (v is wsdlDescription.ServiceDescription) {
descriptions.Add((wsdlDescription.ServiceDescription)v);
}
else if (v is XmlSchema) {
schemas.Add((XmlSchema)v);
}
}
}
示例4: FixtureSetUp
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);
}
示例5: FixtureSetUp
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);
}
示例6: SetUpFixture
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);
}
示例7: GetDocumentNoParse
private static DiscoveryDocument GetDocumentNoParse(ref string url, DiscoveryClientProtocol client)
{
DiscoveryDocument document2;
DiscoveryDocument document = (DiscoveryDocument) client.Documents[url];
if (document != null)
{
return document;
}
string contentType = null;
Stream stream = client.Download(ref url, ref contentType);
try
{
XmlTextReader xmlReader = new XmlTextReader(new StreamReader(stream, RequestResponseUtils.GetEncoding(contentType))) {
WhitespaceHandling = WhitespaceHandling.Significant,
XmlResolver = null,
DtdProcessing = DtdProcessing.Prohibit
};
if (!DiscoveryDocument.CanRead(xmlReader))
{
ArgumentException innerException = new ArgumentException(System.Web.Services.Res.GetString("WebInvalidFormat"));
throw new InvalidOperationException(System.Web.Services.Res.GetString("WebMissingDocument", new object[] { url }), innerException);
}
document2 = DiscoveryDocument.Read(xmlReader);
}
finally
{
stream.Close();
}
return document2;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:DiscoveryDocumentReference.cs
示例8: DiscoResolve
protected DiscoveryClientProtocol DiscoResolve (string url)
{
// Checks the availablity of any services
var protocol = new DiscoveryClientProtocol ();
var creds = new AskCredentials ();
protocol.Credentials = creds;
bool unauthorized;
do {
unauthorized = false;
creds.Reset ();
try {
protocol.DiscoverAny (url);
} catch (WebException wex) {
var wr = wex.Response as HttpWebResponse;
if (!creds.Canceled && wr != null && wr.StatusCode == HttpStatusCode.Unauthorized) {
unauthorized = true;
continue;
}
throw;
}
} while (unauthorized);
if (protocol != null) {
creds.Store ();
if (protocol.References.Count == 0)
return null;
}
return protocol;
}
示例9: WebServiceDiscoveryResultWCF
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;
}
示例10: Generate
static void Generate(string url, TextWriter writer)
{
var cr = new ContractReference();
cr.Url = url;
var protocol = new DiscoveryClientProtocol();
var wc = new WebClient();
using (var stream = wc.OpenRead(cr.Url))
protocol.Documents.Add(cr.Url, cr.ReadDocument(stream));
var mset = ToMetadataSet(protocol);
var importer = new WsdlImporter(mset);
var xsdImporter = new XsdDataContractImporter();
var options = new ImportOptions();
options.ReferencedCollectionTypes.Add(typeof(LinkedList<>));
xsdImporter.Options = options;
importer.State.Add(typeof(XsdDataContractImporter), xsdImporter);
Collection<ContractDescription> contracts = importer.ImportAllContracts();
CodeCompileUnit ccu = new CodeCompileUnit();
CodeNamespace cns = new CodeNamespace("TestNamespace");
ccu.Namespaces.Add(cns);
var generator = new ServiceContractGenerator(ccu);
foreach (var cd in contracts)
generator.GenerateServiceContractType(cd);
var provider = new CSharpCodeProvider();
provider.GenerateCodeFromCompileUnit(ccu, writer, null);
}
示例11: WebReference
public WebReference(IProject project, string url, string name, string proxyNamespace, DiscoveryClientProtocol protocol)
{
this.project = project;
this.url = url;
this.protocol = protocol;
this.proxyNamespace = proxyNamespace;
this.name = name;
GetRelativePath();
}
示例12: DiscoverWebServiceMetadata
void DiscoverWebServiceMetadata(object sender, DoWorkEventArgs e)
{
Uri url = (Uri)e.Argument;
var client = new DiscoveryClientProtocol();
client.Credentials = GetCredentials();
DiscoveryDocument document = client.DiscoverAny(url.AbsoluteUri);
client.ResolveOneLevel();
e.Result = new ServiceReferenceDiscoveryEventArgs(client.References);
}
示例13: DiscoverDocuments
DiscoveryClientDocumentCollection DiscoverDocuments()
{
var protocol = new DiscoveryClientProtocol {
AllowAutoRedirect = true,
Credentials = credentials ?? CredentialCache.DefaultCredentials
};
protocol.DiscoverAny(uri);
protocol.ResolveAll();
return protocol.Documents;
}
示例14: GetServiceDescriptions
public static ServiceDescriptionCollection GetServiceDescriptions(DiscoveryClientProtocol protocol)
{
ServiceDescriptionCollection services = new ServiceDescriptionCollection();
protocol.ResolveOneLevel();
foreach (DictionaryEntry entry in protocol.References) {
ContractReference contractRef = entry.Value as ContractReference;
if (contractRef != null) {
services.Add(contractRef.Contract);
}
}
return services;
}
示例15: SetupFixture
public void SetupFixture()
{
project = WebReferenceTestHelper.CreateTestProject("C#");
project.FileName = "C:\\Projects\\Web.csproj";
WebReferencesProjectItem item = new WebReferencesProjectItem(project);
item.Include = "Foo\\";
ProjectService.AddProjectItem(project, item);
protocol = new DiscoveryClientProtocol();
WebReferenceTestHelper.InitializeProjectBindings();
webReference = new SD.WebReference(project, updateFromUrl, name, proxyNamespace, protocol);
webReferenceUrl = (WebReferenceUrl)WebReferenceTestHelper.GetProjectItem(webReference.Items, ItemType.WebReferenceUrl);
}