⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wsdlretrieval.cs

📁 In the previous article, we presented an approach for capturing similarity between words that was co
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Xml;
using System.Web.Services.Description;

namespace UDDI_Explorer
{
    class WSDLRetrieval
    {
        public static bool RetrieveWSDLFile(UDDIService serviceInfo, bool online)
        {
            if (serviceInfo.LocationFile != null && serviceInfo.LocationFile.LastIndexOf(@":\") == -1)
            {
                string strPath = Application.ExecutablePath;
                int i = strPath.LastIndexOf(@"\");
                string strDir = strPath.Substring(0, i + 1) + @"WSDLCache";
                strPath = strDir + "\\" + serviceInfo.LocationFile;
                
                if (!Directory.Exists(strDir))
                {
                    Directory.CreateDirectory (strDir);
                    if (!Directory.Exists(strDir))
                    {
                        throw new Exception("Could not create the WSDLCache folder at the location : " + strDir);
                    }
                }
                serviceInfo.LocationFile = strPath;
            };
            
            if (online)
            {
                try
                {
                    XmlTextReader reader = new XmlTextReader(serviceInfo.Url);
                    ServiceDescription tmpService =
                        ServiceDescription.Read(reader);
                    tmpService.Name = serviceInfo.Url;
                    tmpService.RetrievalUrl = serviceInfo.Url;
                    tmpService.Write(serviceInfo.LocationFile);

                    if (!File.Exists(serviceInfo.LocationFile))
                    {
                        throw new Exception("Could not write the wsdl at the location :" + serviceInfo.LocationFile);
                    };
                }
                catch (Exception)
                {
                    throw new Exception("Could not retrieve the wsdl from the url: " + serviceInfo.Url);
                }


            }
            else
                if (!File.Exists(serviceInfo.LocationFile))
                {
                    throw new Exception("File does not exist");
                };

            return true;
        }

        public static TreeNode WSDLToNode(UDDIService serviceInfo, bool online)
        {
            try
            {
                if (RetrieveWSDLFile(serviceInfo, online))
                {
                    ServiceDescription myService =
                        ServiceDescription.Read(serviceInfo.LocationFile);

                    if (myService.Name == string.Empty || myService.Name == null)
                    {
                        myService.Name = serviceInfo.Url;
                    };
                    if (myService.Name != string.Empty && serviceInfo.Url == string.Empty)
                        serviceInfo.Url = myService.Name;

                    serviceInfo.Descriptions = myService.Documentation;

                    WSDLParser.WSDLParser parse = new WSDLParser.WSDLParser(myService);
                    TreeNode node = new TreeNode();
                    node = parse.ServiceNode;
                    return node;
                }

            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message.ToString());
            }
            finally
            {

            };

            return null;

        }

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -