本文整理汇总了C#中System.Web.Services.Discovery.DiscoveryClientProtocol.ResolveAll方法的典型用法代码示例。如果您正苦于以下问题:C# DiscoveryClientProtocol.ResolveAll方法的具体用法?C# DiscoveryClientProtocol.ResolveAll怎么用?C# DiscoveryClientProtocol.ResolveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Services.Discovery.DiscoveryClientProtocol
的用法示例。
在下文中一共展示了DiscoveryClientProtocol.ResolveAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
}
示例2: DiscoverDocuments
DiscoveryClientDocumentCollection DiscoverDocuments()
{
var protocol = new DiscoveryClientProtocol {
AllowAutoRedirect = true,
Credentials = credentials ?? CredentialCache.DefaultCredentials
};
protocol.DiscoverAny(uri);
protocol.ResolveAll();
return protocol.Documents;
}
示例3: ReadServiceDescriptionImporter
/// <summary>Read the specified protocol into an ServiceDescriptionImporter.</summary>
/// <param name="protocol">A DiscoveryClientProtocol containing the service protocol detail.</param>
/// <returns>A ServiceDescriptionImporter for the specified protocol.</returns>
public static ServiceDescriptionImporter ReadServiceDescriptionImporter(DiscoveryClientProtocol protocol)
{
// Service Description Importer
ServiceDescriptionImporter importer = new ServiceDescriptionImporter();
importer.ProtocolName = "Soap";
// Add all the schemas and service descriptions to the importer
protocol.ResolveAll ();
foreach (object doc in protocol.Documents.Values)
{
if (doc is ServiceDescription)
importer.AddServiceDescription((ServiceDescription)doc, null, null);
else if (doc is XmlSchema)
importer.Schemas.Add((XmlSchema)doc);
}
return importer;
}
示例4: Resolve
/// <summary>
/// Resolves metadata from the specified URL.
/// </summary>
/// <param name="url">The URL.</param>
/// <returns>A list of metadata sections.</returns>
public static IEnumerable<MetadataSection> Resolve(string url)
{
MetadataSet metadataSet = new MetadataSet();
DiscoveryClientProtocol discoveryClient = new DiscoveryClientProtocol
{
UseDefaultCredentials = true,
AllowAutoRedirect = true
};
discoveryClient.DiscoverAny(url);
discoveryClient.ResolveAll();
foreach (object document in discoveryClient.Documents.Values)
{
AddDocumentToSet(metadataSet, document);
}
return metadataSet.MetadataSections;
}
示例5: GetServiceDescription
/// <summary>
/// Gets the web service description from the supplied URL.
/// </summary>
/// <param name="url">
/// The URL where XML Web services discovery begins.
/// </param>
/// <param name="username">
/// The username.
/// </param>
/// <param name="password">
/// The password.
/// </param>
/// <returns>
/// The <see cref="WebServiceDescription"/>.
/// </returns>
/// <exception cref="ArgumentNullException">
/// The <paramref name="url"/> parameter is null.
/// </exception>
/// <exception cref="InvalidOperationException">
/// The <paramref name="url"/> parameter is a valid URL, but does not point to a valid discovery document, service description, or XSD schema.
/// </exception>
public WebServiceDescription GetServiceDescription(string url, string username, string password)
{
if (url == null)
throw new ArgumentNullException("url");
url = url.Trim();
var protocol = new DiscoveryClientProtocol { AllowAutoRedirect = true, Credentials = CredentialCache.DefaultCredentials };
if (!string.IsNullOrEmpty(username))
protocol.Credentials = new NetworkCredential(username, password);
try
{
protocol.DiscoverAny(url);
}
catch (InvalidOperationException)
{
if (!url.EndsWith("?WSDL", StringComparison.InvariantCultureIgnoreCase))
protocol.DiscoverAny(url + "?WSDL");
else
throw;
}
protocol.ResolveAll();
var serviceDescription = new WebServiceDescription();
foreach (DictionaryEntry entry in protocol.References)
{
var contractReference = entry.Value as ContractReference;
if (contractReference != null)
serviceDescription.ServiceDescriptions.Add(contractReference.Contract);
var schemaReference = entry.Value as SchemaReference;
if (schemaReference != null)
serviceDescription.XmlSchemas.Add(schemaReference.Schema);
}
return serviceDescription;
}
示例6: ReadServiceDescriptionImporter
/// <summary>Read the specified protocol into an ServiceDescriptionImporter.</summary>
/// <param name="protocol">A DiscoveryClientProtocol containing the service protocol detail.</param>
/// <returns>A ServiceDescriptionImporter for the specified protocol.</returns>
public static ServiceDescriptionImporter ReadServiceDescriptionImporter(DiscoveryClientProtocol protocol)
{
// Service Description Importer
var importer = new ServiceDescriptionImporter();
importer.ProtocolName = "Soap";
// Add all the schemas and service descriptions to the importer
protocol.ResolveAll ();
foreach (object doc in protocol.Documents.Values)
{
var serviceDescription = doc as ServiceDescription;
if (serviceDescription != null)
importer.AddServiceDescription (serviceDescription, null, null);
else {
var xmlSchema = doc as XmlSchema;
if (xmlSchema != null)
importer.Schemas.Add (xmlSchema);
}
}
return importer;
}
示例7: ReadWriteTest
public void ReadWriteTest ()
{
string directory = Path.Combine (Path.GetTempPath (), Path.GetRandomFileName ());
Directory.CreateDirectory (directory);
try {
string url = "http://www.w3schools.com/WebServices/TempConvert.asmx";
var p1 = new DiscoveryClientProtocol ();
p1.DiscoverAny (url);
p1.ResolveAll ();
p1.WriteAll (directory, "Reference.map");
var p2 = new DiscoveryClientProtocol ();
var results = p2.ReadAll (Path.Combine (directory, "Reference.map"));
Assert.AreEqual (2, results.Count);
Assert.AreEqual ("TempConvert.disco", results [0].Filename);
Assert.AreEqual ("TempConvert.wsdl", results [1].Filename);
} finally {
Directory.Delete (directory, true);
}
}
示例8: DownloadMetadata
public Collection<MetadataSection> DownloadMetadata(string serviceUrl)
{
Uri serviceUri = new Uri(serviceUrl);
Collection<MetadataSection> metadataSections;
if (TryDownloadByMetadataExchangeClient(serviceUri, out metadataSections))
{
return metadataSections;
}
else
{
if (TryDownloadByMetadataExchangeClient(GetDefaultMexUri(serviceUri), out metadataSections))
{
return metadataSections;
}
}
bool supporstDiscoveryClientProtocol = serviceUri.Scheme == Uri.UriSchemeHttp || serviceUri.Scheme == Uri.UriSchemeHttps;
if (supporstDiscoveryClientProtocol)
{
DiscoveryClientProtocol disco = new DiscoveryClientProtocol();
disco.AllowAutoRedirect = true;
disco.UseDefaultCredentials = true;
disco.DiscoverAny(serviceUrl);
disco.ResolveAll();
Collection<MetadataSection> result = new Collection<MetadataSection>();
if (disco.Documents.Values != null)
{
foreach (object document in disco.Documents.Values)
{
AddDocumentToResults(document, result);
}
}
return result;
}
return null;
}
示例9: Generate
public model.WebSvc Generate(string filePath)
{
List<wsdlDescription.ServiceDescription> descriptions = new List<wsdlDescription.ServiceDescription>();
List<XmlSchema> schemas = new List<XmlSchema>();
DiscoveryClientProtocol client = new DiscoveryClientProtocol();
//load Document from file
client.AllowAutoRedirect = true;
client.Documents.Clear();
client.DiscoverAny(filePath);
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);
}
}
return Generate(filePath, descriptions, schemas);
}
示例10: DownloadMetadata
private void DownloadMetadata()
{
EndpointAddress epr = new EndpointAddress(this.wsdlUri);
DiscoveryClientProtocol disco = new DiscoveryClientProtocol();
disco.AllowAutoRedirect = true;
disco.UseDefaultCredentials = true;
disco.DiscoverAny(this.wsdlUri);
disco.ResolveAll();
Collection<MetadataSection> results = new Collection<MetadataSection>();
foreach (object document in disco.Documents.Values)
{
AddDocumentToResults(document, results);
}
this.metadataCollection = results;
}
示例11: ProcessRemoteUrls
private void ProcessRemoteUrls(DiscoveryClientProtocol client, StringCollection urls, XmlSchemas schemas,
ServiceDescriptionCollection descriptions)
{
foreach (string text1 in urls)
{
try
{
DiscoveryDocument document1 = client.DiscoverAny(text1);
client.ResolveAll();
continue;
}
catch (Exception exception1)
{
throw new InvalidOperationException("General Error " + text1, exception1);
}
}
foreach (DictionaryEntry entry1 in client.Documents)
{
AddDocument((string) entry1.Key, entry1.Value, schemas, descriptions);
}
}
示例12: DownloadWeb
//TODO: FB client.GetMetadata is not working working on linux, instead use DiscoveryClientProtocol.
//this means that mex bindings are currently not supported on linux
void DownloadWeb(model.IProxy proxy, out List<wsdlDescription.ServiceDescription> descriptions, out List<XmlSchema> schemas)
{
DiscoveryClientProtocol client = new DiscoveryClientProtocol();
if (proxy.ProxyType == model.Proxy.EProxyType.Enabled) {
client.Proxy = new System.Net.WebProxy(proxy.Host, proxy.Port);
client.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
}
descriptions = new List<wsdlDescription.ServiceDescription>();
schemas = new List<XmlSchema>();
//download document
client.AllowAutoRedirect = true;
client.Timeout = _timeoutInSeconds * 1000;
client.Documents.Clear();
client.DiscoverAny(_wsdlEndpoint);
client.ResolveAll();
//generate stub
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);
}
}
}
示例13: ProcessRemoteUrls
private void ProcessRemoteUrls(DiscoveryClientProtocol client, StringCollection urls, XmlSchemas schemas, ServiceDescriptionCollection descriptions)
{
StringEnumerator enumerator = urls.GetEnumerator();
while (enumerator.MoveNext())
{
string current = enumerator.Current;
try
{
DiscoveryDocument document = client.DiscoverAny(current);
client.ResolveAll();
continue;
}
catch (Exception exception)
{
throw new InvalidOperationException("General Error " + current, exception);
}
}
IDictionaryEnumerator enumerator2 = client.Documents.GetEnumerator();
while (enumerator2.MoveNext())
{
DictionaryEntry entry = (DictionaryEntry)enumerator2.Current;
this.AddDocument((string)entry.Key, entry.Value, schemas, descriptions);
}
}
示例14: GetWsDocuments
/// <summary>
/// Gets XML Web Services documents from a Spring resource.
/// </summary>
private DiscoveryClientDocumentCollection GetWsDocuments(IResource resource)
{
try
{
if (ServiceUri is UrlResource ||
ServiceUri is FileSystemResource)
{
DiscoveryClientProtocol dcProtocol = new DiscoveryClientProtocol();
dcProtocol.AllowAutoRedirect = true;
dcProtocol.Credentials = CreateCredentials();
dcProtocol.Proxy = ConfigureProxy();
dcProtocol.DiscoverAny(resource.Uri.AbsoluteUri);
dcProtocol.ResolveAll();
return dcProtocol.Documents;
}
else
{
DiscoveryClientDocumentCollection dcdc = new DiscoveryClientDocumentCollection();
dcdc[resource.Description] = ServiceDescription.Read(resource.InputStream);
return dcdc;
}
}
catch (Exception ex)
{
throw new ArgumentException(String.Format("Couldn't retrieve the description of the web service located at '{0}'.", resource.Description), ex);
}
}
示例15: GenerateWebServiceProxyAssembly
private Assembly GenerateWebServiceProxyAssembly(string NameSpace, string ClassName)
{
object obj = null;
Assembly assembly;
DiscoveryClientProtocol discoveryClientProtocol = new DiscoveryClientProtocol();
if (this._usedefaultcredential.IsPresent)
{
discoveryClientProtocol.UseDefaultCredentials = true;
}
if (base.ParameterSetName.Equals("Credential", StringComparison.OrdinalIgnoreCase))
{
discoveryClientProtocol.Credentials = this._credential.GetNetworkCredential();
}
try
{
discoveryClientProtocol.AllowAutoRedirect = true;
discoveryClientProtocol.DiscoverAny(this._uri.ToString());
discoveryClientProtocol.ResolveAll();
goto Label0;
}
catch (WebException webException1)
{
WebException webException = webException1;
ErrorRecord errorRecord = new ErrorRecord(webException, "WebException", ErrorCategory.ObjectNotFound, this._uri);
if (webException.InnerException != null)
{
errorRecord.ErrorDetails = new ErrorDetails(webException.InnerException.Message);
}
base.WriteError(errorRecord);
assembly = null;
}
catch (InvalidOperationException invalidOperationException1)
{
InvalidOperationException invalidOperationException = invalidOperationException1;
ErrorRecord errorRecord1 = new ErrorRecord(invalidOperationException, "InvalidOperationException", ErrorCategory.InvalidOperation, this._uri);
base.WriteError(errorRecord1);
assembly = null;
}
return assembly;
Label0:
CodeNamespace codeNamespace = new CodeNamespace();
if (!string.IsNullOrEmpty(NameSpace))
{
codeNamespace.Name = NameSpace;
}
if (!string.IsNullOrEmpty(ClassName))
{
CodeTypeDeclaration codeTypeDeclaration = new CodeTypeDeclaration(ClassName);
codeTypeDeclaration.IsClass = true;
codeTypeDeclaration.Attributes = MemberAttributes.Public;
codeNamespace.Types.Add(codeTypeDeclaration);
}
WebReference webReference = new WebReference(discoveryClientProtocol.Documents, codeNamespace);
WebReferenceCollection webReferenceCollection = new WebReferenceCollection();
webReferenceCollection.Add(webReference);
CodeCompileUnit codeCompileUnit = new CodeCompileUnit();
codeCompileUnit.Namespaces.Add(codeNamespace);
WebReferenceOptions webReferenceOption = new WebReferenceOptions();
webReferenceOption.CodeGenerationOptions = CodeGenerationOptions.GenerateProperties | CodeGenerationOptions.GenerateNewAsync | CodeGenerationOptions.GenerateOldAsync;
webReferenceOption.Verbose = true;
CSharpCodeProvider cSharpCodeProvider = new CSharpCodeProvider();
StringCollection stringCollections = ServiceDescriptionImporter.GenerateWebReferences(webReferenceCollection, cSharpCodeProvider, codeCompileUnit, webReferenceOption);
StringBuilder stringBuilder = new StringBuilder();
StringWriter stringWriter = new StringWriter(stringBuilder, CultureInfo.InvariantCulture);
try
{
cSharpCodeProvider.GenerateCodeFromCompileUnit(codeCompileUnit, stringWriter, null);
}
catch (NotImplementedException notImplementedException1)
{
NotImplementedException notImplementedException = notImplementedException1;
ErrorRecord errorRecord2 = new ErrorRecord(notImplementedException, "NotImplementedException", ErrorCategory.ObjectNotFound, this._uri);
base.WriteError(errorRecord2);
}
this.sourceHash = stringBuilder.ToString().GetHashCode();
if (!NewWebServiceProxy.srccodeCache.ContainsKey(this.sourceHash))
{
CompilerParameters compilerParameter = new CompilerParameters();
CompilerResults compilerResult = null;
foreach (string str in stringCollections)
{
base.WriteWarning(str);
}
compilerParameter.ReferencedAssemblies.Add("System.dll");
compilerParameter.ReferencedAssemblies.Add("System.Data.dll");
compilerParameter.ReferencedAssemblies.Add("System.Xml.dll");
compilerParameter.ReferencedAssemblies.Add("System.Web.Services.dll");
compilerParameter.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);
this.GetReferencedAssemblies(typeof(Cmdlet).Assembly, compilerParameter);
compilerParameter.GenerateInMemory = true;
compilerParameter.TreatWarningsAsErrors = false;
compilerParameter.WarningLevel = 4;
compilerParameter.GenerateExecutable = false;
try
{
string[] strArrays = new string[1];
strArrays[0] = stringBuilder.ToString();
compilerResult = cSharpCodeProvider.CompileAssemblyFromSource(compilerParameter, strArrays);
}
catch (NotImplementedException notImplementedException3)
//.........这里部分代码省略.........